Skip to content

Commit 66671b0

Browse files
committed
Check @deprecated annotation in method Attr.checkIdInternal. Remove the redundant warning code
1 parent 1d2a73c commit 66671b0

File tree

2 files changed

+7
-40
lines changed

2 files changed

+7
-40
lines changed

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

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

44614461
// Emit a `deprecation' warning if symbol is deprecated.
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-
}
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);
44714466

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

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

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,13 +2855,8 @@ Symbol findConstructor(DiagnosticPosition pos, Env<AttrContext> env,
28552855
List<Type> typeargtypes,
28562856
boolean allowBoxing,
28572857
boolean 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;
2858+
return findMethod(env, site, names.init, argtypes,
2859+
typeargtypes, allowBoxing, useVarargs);
28652860
}
28662861

28672862
/** Resolve constructor using diamond inference.
@@ -2883,7 +2878,7 @@ Symbol resolveDiamond(DiagnosticPosition pos,
28832878
new BasicLookupHelper(names.init, site, argtypes, typeargtypes) {
28842879
@Override
28852880
Symbol doLookup(Env<AttrContext> env, MethodResolutionPhase phase) {
2886-
return findDiamond(pos, env, site, argtypes, typeargtypes,
2881+
return findDiamond(env, site, argtypes, typeargtypes,
28872882
phase.isBoxingRequired(),
28882883
phase.isVarargsRequired());
28892884
}
@@ -2906,29 +2901,6 @@ Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Sym
29062901
}});
29072902
}
29082903

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-
29322904
/** This method scans all the constructor symbol in a given class scope -
29332905
* assuming that the original scope contains a constructor of the kind:
29342906
* {@code Foo(X x, Y y)}, where X,Y are class type-variables declared in Foo,

0 commit comments

Comments
 (0)