@@ -2855,8 +2855,13 @@ Symbol findConstructor(DiagnosticPosition pos, Env<AttrContext> env,
28552855 List <Type > typeargtypes ,
28562856 boolean allowBoxing ,
28572857 boolean useVarargs ) {
2858- return findMethod (env , site , names .init , argtypes ,
2859- typeargtypes , allowBoxing , useVarargs );
2858+ Symbol sym = findMethod (env , site ,
2859+ names .init , argtypes ,
2860+ typeargtypes , allowBoxing ,
2861+ useVarargs );
2862+ chk .checkDeprecated (pos , env .info .scope .owner , sym );
2863+ chk .checkPreview (pos , sym );
2864+ return sym ;
28602865 }
28612866
28622867 /** Resolve constructor using diamond inference.
@@ -2878,7 +2883,7 @@ Symbol resolveDiamond(DiagnosticPosition pos,
28782883 new BasicLookupHelper (names .init , site , argtypes , typeargtypes ) {
28792884 @ Override
28802885 Symbol doLookup (Env <AttrContext > env , MethodResolutionPhase phase ) {
2881- return findDiamond (env , site , argtypes , typeargtypes ,
2886+ return findDiamond (pos , env , site , argtypes , typeargtypes ,
28822887 phase .isBoxingRequired (),
28832888 phase .isVarargsRequired ());
28842889 }
@@ -2901,6 +2906,29 @@ Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Sym
29012906 }});
29022907 }
29032908
2909+ /** Find the constructor using diamond inference and do some checks(deprecated and preview).
2910+ * @param pos The position to use for error reporting.
2911+ * @param env The environment current at the constructor invocation.
2912+ * @param site The type of class for which a constructor is searched.
2913+ * The scope of this class has been touched in attribution.
2914+ * @param argtypes The types of the constructor invocation's value arguments.
2915+ * @param typeargtypes The types of the constructor invocation's type arguments.
2916+ * @param allowBoxing Allow boxing conversions of arguments.
2917+ * @param useVarargs Box trailing arguments into an array for varargs.
2918+ */
2919+ private Symbol findDiamond (DiagnosticPosition pos ,
2920+ Env <AttrContext > env ,
2921+ Type site ,
2922+ List <Type > argtypes ,
2923+ List <Type > typeargtypes ,
2924+ boolean allowBoxing ,
2925+ boolean useVarargs ) {
2926+ Symbol sym = findDiamond (env , site , argtypes , typeargtypes , allowBoxing , useVarargs );
2927+ chk .checkDeprecated (pos , env .info .scope .owner , sym );
2928+ chk .checkPreview (pos , sym );
2929+ return sym ;
2930+ }
2931+
29042932 /** This method scans all the constructor symbol in a given class scope -
29052933 * assuming that the original scope contains a constructor of the kind:
29062934 * {@code Foo(X x, Y y)}, where X,Y are class type-variables declared in Foo,
0 commit comments