@@ -2883,7 +2883,7 @@ Symbol resolveDiamond(DiagnosticPosition pos,
28832883 new BasicLookupHelper (names .init , site , argtypes , typeargtypes ) {
28842884 @ Override
28852885 Symbol doLookup (Env <AttrContext > env , MethodResolutionPhase phase ) {
2886- return findDiamond (env , site , argtypes , typeargtypes ,
2886+ return findDiamond (pos , env , site , argtypes , typeargtypes ,
28872887 phase .isBoxingRequired (),
28882888 phase .isVarargsRequired ());
28892889 }
@@ -2896,23 +2896,50 @@ Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Sym
28962896 } else {
28972897 final JCDiagnostic details = sym .kind == WRONG_MTH ?
28982898 ((InapplicableSymbolError )sym .baseSymbol ()).errCandidate ().snd :
2899- null ;
2899+ null ;
29002900 sym = new DiamondError (sym , currentResolutionContext );
29012901 sym = accessMethod (sym , pos , site , names .init , true , argtypes , typeargtypes );
29022902 env .info .pendingResolutionPhase = currentResolutionContext .step ;
29032903 }
29042904 }
29052905 return sym ;
2906- }});
2906+ }
2907+ });
29072908 }
29082909
2909- /** This method scans all the constructor symbol in a given class scope -
2910- * assuming that the original scope contains a constructor of the kind:
2911- * {@code Foo(X x, Y y)}, where X,Y are class type-variables declared in Foo,
2912- * a method check is executed against the modified constructor type:
2913- * {@code <X,Y>Foo<X,Y>(X x, Y y)}. This is crucial in order to enable diamond
2914- * inference. The inferred return type of the synthetic constructor IS
2915- * the inferred type for the diamond operator.
2910+ /**
2911+ * Find the constructor using diamond inference and do some checks(deprecated and preview).
2912+ *
2913+ * @param pos The position to use for error reporting.
2914+ * @param env The environment current at the constructor invocation.
2915+ * @param site The type of class for which a constructor is searched.
2916+ * The scope of this class has been touched in attribution.
2917+ * @param argtypes The types of the constructor invocation's value arguments.
2918+ * @param typeargtypes The types of the constructor invocation's type arguments.
2919+ * @param allowBoxing Allow boxing conversions of arguments.
2920+ * @param useVarargs Box trailing arguments into an array for varargs.
2921+ */
2922+ private Symbol findDiamond (DiagnosticPosition pos ,
2923+ Env <AttrContext > env ,
2924+ Type site ,
2925+ List <Type > argtypes ,
2926+ List <Type > typeargtypes ,
2927+ boolean allowBoxing ,
2928+ boolean useVarargs ) {
2929+ Symbol sym = findDiamond (env , site , argtypes , typeargtypes , allowBoxing , useVarargs );
2930+ chk .checkDeprecated (pos , env .info .scope .owner , sym );
2931+ chk .checkPreview (pos , sym );
2932+ return sym ;
2933+ }
2934+
2935+ /**
2936+ * This method scans all the constructor symbol in a given class scope -
2937+ * assuming that the original scope contains a constructor of the kind:
2938+ * {@code Foo(X x, Y y)}, where X,Y are class type-variables declared in Foo,
2939+ * a method check is executed against the modified constructor type:
2940+ * {@code <X,Y>Foo<X,Y>(X x, Y y)}. This is crucial in order to enable diamond
2941+ * inference. The inferred return type of the synthetic constructor IS
2942+ * the inferred type for the diamond operator.
29162943 */
29172944 private Symbol findDiamond (Env <AttrContext > env ,
29182945 Type site ,
0 commit comments