8257037: No javac warning when calling deprecated constructor with diamond
Reviewed-by: mcimadamore
This commit is contained in:
parent
46b35acfcb
commit
2c04fc02c9
@ -2919,7 +2919,7 @@ public class Resolve {
|
||||
new BasicLookupHelper(names.init, site, argtypes, typeargtypes) {
|
||||
@Override
|
||||
Symbol doLookup(Env<AttrContext> env, MethodResolutionPhase phase) {
|
||||
return findDiamond(env, site, argtypes, typeargtypes,
|
||||
return findDiamond(pos, env, site, argtypes, typeargtypes,
|
||||
phase.isBoxingRequired(),
|
||||
phase.isVarargsRequired());
|
||||
}
|
||||
@ -2942,6 +2942,29 @@ public class Resolve {
|
||||
}});
|
||||
}
|
||||
|
||||
/** Find the constructor using diamond inference and do some checks(deprecated and preview).
|
||||
* @param pos The position to use for error reporting.
|
||||
* @param env The environment current at the constructor invocation.
|
||||
* @param site The type of class for which a constructor is searched.
|
||||
* The scope of this class has been touched in attribution.
|
||||
* @param argtypes The types of the constructor invocation's value arguments.
|
||||
* @param typeargtypes The types of the constructor invocation's type arguments.
|
||||
* @param allowBoxing Allow boxing conversions of arguments.
|
||||
* @param useVarargs Box trailing arguments into an array for varargs.
|
||||
*/
|
||||
private Symbol findDiamond(DiagnosticPosition pos,
|
||||
Env<AttrContext> env,
|
||||
Type site,
|
||||
List<Type> argtypes,
|
||||
List<Type> typeargtypes,
|
||||
boolean allowBoxing,
|
||||
boolean useVarargs) {
|
||||
Symbol sym = findDiamond(env, site, argtypes, typeargtypes, allowBoxing, useVarargs);
|
||||
chk.checkDeprecated(pos, env.info.scope.owner, sym);
|
||||
chk.checkPreview(pos, sym);
|
||||
return sym;
|
||||
}
|
||||
|
||||
/** This method scans all the constructor symbol in a given class scope -
|
||||
* assuming that the original scope contains a constructor of the kind:
|
||||
* {@code Foo(X x, Y y)}, where X,Y are class type-variables declared in Foo,
|
||||
|
15
test/langtools/tools/javac/T8257037/T8257037.java
Normal file
15
test/langtools/tools/javac/T8257037/T8257037.java
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8257307
|
||||
* @summary No javac warning when calling deprecated constructor with diamond
|
||||
* @run compile/ref=T8257037.out -Xlint -XDrawDiagnostics T8257037.java
|
||||
*/
|
||||
|
||||
public class T8257037 {
|
||||
T8257037_GenericClass<Object> test = new T8257037_GenericClass<>(); // use diamond
|
||||
}
|
||||
|
||||
class T8257037_GenericClass<T> {
|
||||
@Deprecated
|
||||
public T8257037_GenericClass() {}
|
||||
}
|
2
test/langtools/tools/javac/T8257037/T8257037.out
Normal file
2
test/langtools/tools/javac/T8257037/T8257037.out
Normal file
@ -0,0 +1,2 @@
|
||||
T8257037.java:9:42: compiler.warn.has.been.deprecated: <T>T8257037_GenericClass(), T8257037_GenericClass
|
||||
1 warning
|
Loading…
x
Reference in New Issue
Block a user