@@ -2919,7 +2919,7 @@ Symbol resolveDiamond(DiagnosticPosition pos,
29192919 new BasicLookupHelper (names .init , site , argtypes , typeargtypes ) {
29202920 @ Override
29212921 Symbol doLookup (Env <AttrContext > env , MethodResolutionPhase phase ) {
2922- return findDiamond (env , site , argtypes , typeargtypes ,
2922+ return findDiamond (pos , env , site , argtypes , typeargtypes ,
29232923 phase .isBoxingRequired (),
29242924 phase .isVarargsRequired ());
29252925 }
@@ -2942,6 +2942,29 @@ Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Sym
29422942 }});
29432943 }
29442944
2945+ /** Find the constructor using diamond inference and do some checks(deprecated and preview).
2946+ * @param pos The position to use for error reporting.
2947+ * @param env The environment current at the constructor invocation.
2948+ * @param site The type of class for which a constructor is searched.
2949+ * The scope of this class has been touched in attribution.
2950+ * @param argtypes The types of the constructor invocation's value arguments.
2951+ * @param typeargtypes The types of the constructor invocation's type arguments.
2952+ * @param allowBoxing Allow boxing conversions of arguments.
2953+ * @param useVarargs Box trailing arguments into an array for varargs.
2954+ */
2955+ private Symbol findDiamond (DiagnosticPosition pos ,
2956+ Env <AttrContext > env ,
2957+ Type site ,
2958+ List <Type > argtypes ,
2959+ List <Type > typeargtypes ,
2960+ boolean allowBoxing ,
2961+ boolean useVarargs ) {
2962+ Symbol sym = findDiamond (env , site , argtypes , typeargtypes , allowBoxing , useVarargs );
2963+ chk .checkDeprecated (pos , env .info .scope .owner , sym );
2964+ chk .checkPreview (pos , sym );
2965+ return sym ;
2966+ }
2967+
29452968 /** This method scans all the constructor symbol in a given class scope -
29462969 * assuming that the original scope contains a constructor of the kind:
29472970 * {@code Foo(X x, Y y)}, where X,Y are class type-variables declared in Foo,
0 commit comments