7002837: Diamond: javac generates diamond inference errors when in 'finder' mode
Javac should disable error messages when analyzing instance creation expression in 'diamond finder' mode Reviewed-by: jjg
This commit is contained in:
parent
7613f7a72c
commit
8644a0bc46
@ -1587,13 +1587,26 @@ public class Attr extends JCTree.Visitor {
|
||||
} else if (allowDiamondFinder &&
|
||||
clazztype.getTypeArguments().nonEmpty() &&
|
||||
findDiamonds) {
|
||||
Type inferred = attribDiamond(localEnv,
|
||||
tree,
|
||||
clazztype,
|
||||
mapping,
|
||||
argtypes,
|
||||
typeargtypes);
|
||||
if (!inferred.isErroneous() &&
|
||||
boolean prevDeferDiags = log.deferDiagnostics;
|
||||
Queue<JCDiagnostic> prevDeferredDiags = log.deferredDiagnostics;
|
||||
Type inferred = null;
|
||||
try {
|
||||
//disable diamond-related diagnostics
|
||||
log.deferDiagnostics = true;
|
||||
log.deferredDiagnostics = ListBuffer.lb();
|
||||
inferred = attribDiamond(localEnv,
|
||||
tree,
|
||||
clazztype,
|
||||
mapping,
|
||||
argtypes,
|
||||
typeargtypes);
|
||||
}
|
||||
finally {
|
||||
log.deferDiagnostics = prevDeferDiags;
|
||||
log.deferredDiagnostics = prevDeferredDiags;
|
||||
}
|
||||
if (inferred != null &&
|
||||
!inferred.isErroneous() &&
|
||||
inferred.tag == CLASS &&
|
||||
types.isAssignable(inferred, pt.tag == NONE ? clazztype : pt, Warner.noWarnings) &&
|
||||
chk.checkDiamond((ClassType)inferred).isEmpty()) {
|
||||
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 7002837
|
||||
*
|
||||
* @summary Diamond: javac generates diamond inference errors when in 'finder' mode
|
||||
* @author mcimadamore
|
||||
* @compile -Werror -XDfindDiamond T7002837.java
|
||||
*
|
||||
*/
|
||||
|
||||
class T7002837<X extends java.io.Serializable & Comparable<?>> {
|
||||
T7002837() {}
|
||||
{ new T7002837<Integer>(); }
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user