Skip to content
Browse files
8257037: No javac warning when calling deprecated constructor with di…

Reviewed-by: mcimadamore
  • Loading branch information
lgxbslgx authored and mcimadamore committed Dec 7, 2020
1 parent 46b35ac commit 2c04fc02c929a117ce620ac70e3b957c4afc3c40
@@ -2919,7 +2919,7 @@ Symbol resolveDiamond(DiagnosticPosition pos,
new BasicLookupHelper(names.init, site, argtypes, typeargtypes) {
Symbol doLookup(Env<AttrContext> env, MethodResolutionPhase phase) {
return findDiamond(env, site, argtypes, typeargtypes,
return findDiamond(pos, env, site, argtypes, typeargtypes,
@@ -2942,6 +2942,29 @@ Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Sym

/** 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,, 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,
@@ -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

public class T8257037 {
T8257037_GenericClass<Object> test = new T8257037_GenericClass<>(); // use diamond

class T8257037_GenericClass<T> {
public T8257037_GenericClass() {}
@@ -0,0 +1,2 @@ compiler.warn.has.been.deprecated: <T>T8257037_GenericClass(), T8257037_GenericClass
1 warning

1 comment on commit 2c04fc0


This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 2c04fc0 Dec 7, 2020

Please sign in to comment.