Skip to content

Commit c4de5fa

Browse files
committed
Fall back to the previos version.
1 parent 1d06ad1 commit c4de5fa

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4459,10 +4459,15 @@ else if (ownOuter.hasTag(CLASS) && site != ownOuter) {
44594459
}
44604460

44614461
// Emit a `deprecation' warning if symbol is deprecated.
4462-
chk.checkDeprecated(tree.pos(), env.info.scope.owner, sym);
4463-
chk.checkSunAPI(tree.pos(), sym);
4464-
chk.checkProfile(tree.pos(), sym);
4465-
chk.checkPreview(tree.pos(), sym);
4462+
// (for constructors (but not for constructor references), the error
4463+
// was given when the constructor was resolved)
4464+
4465+
if (sym.name != names.init || tree.hasTag(REFERENCE)) {
4466+
chk.checkDeprecated(tree.pos(), env.info.scope.owner, sym);
4467+
chk.checkSunAPI(tree.pos(), sym);
4468+
chk.checkProfile(tree.pos(), sym);
4469+
chk.checkPreview(tree.pos(), sym);
4470+
}
44664471

44674472
// If symbol is a variable, check that its type and
44684473
// kind are compatible with the prototype and protokind.

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)