8067792: Javac crashes in finder mode with nested implicit lambdas
Revert tree changes occurred in Attr before running the analyzer Reviewed-by: jlahoda
This commit is contained in:
parent
627ce960f5
commit
41070244c9
langtools
src/jdk.compiler/share/classes/com/sun/tools/javac/comp
test/tools/javac/lambda/8067792
@ -25,6 +25,7 @@
|
||||
|
||||
package com.sun.tools.javac.comp;
|
||||
|
||||
import com.sun.source.tree.LambdaExpressionTree;
|
||||
import com.sun.tools.javac.code.Source;
|
||||
import com.sun.tools.javac.code.Type;
|
||||
import com.sun.tools.javac.code.Types;
|
||||
@ -36,6 +37,7 @@ import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop;
|
||||
import com.sun.tools.javac.tree.JCTree.JCForLoop;
|
||||
import com.sun.tools.javac.tree.JCTree.JCIf;
|
||||
import com.sun.tools.javac.tree.JCTree.JCLambda;
|
||||
import com.sun.tools.javac.tree.JCTree.JCLambda.ParameterKind;
|
||||
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
|
||||
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
|
||||
import com.sun.tools.javac.tree.JCTree.JCNewClass;
|
||||
@ -50,6 +52,8 @@ import com.sun.tools.javac.tree.TreeInfo;
|
||||
import com.sun.tools.javac.tree.TreeMaker;
|
||||
import com.sun.tools.javac.tree.TreeScanner;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.DefinedBy;
|
||||
import com.sun.tools.javac.util.DefinedBy.Api;
|
||||
import com.sun.tools.javac.util.Filter;
|
||||
import com.sun.tools.javac.util.JCDiagnostic;
|
||||
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
|
||||
@ -489,5 +493,17 @@ public class Analyzer {
|
||||
}
|
||||
return newTree;
|
||||
}
|
||||
|
||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||
public JCTree visitLambdaExpression(LambdaExpressionTree node, Void _unused) {
|
||||
JCLambda oldLambda = (JCLambda)node;
|
||||
JCLambda newLambda = (JCLambda)super.visitLambdaExpression(node, _unused);
|
||||
if (oldLambda.paramKind == ParameterKind.IMPLICIT) {
|
||||
//reset implicit lambda parameters (whose type might have been set during attr)
|
||||
newLambda.paramKind = ParameterKind.IMPLICIT;
|
||||
newLambda.params.forEach(p -> p.vartype = null);
|
||||
}
|
||||
return newLambda;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
langtools/test/tools/javac/lambda/8067792/T8067792.java
Normal file
19
langtools/test/tools/javac/lambda/8067792/T8067792.java
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8067792
|
||||
* @summary Javac crashes in finder mode with nested implicit lambdas
|
||||
* @compile/fail/ref=T8067792.out -XDrawDiagnostics -Werror -XDfind=lambda T8067792.java
|
||||
*/
|
||||
|
||||
import java.util.stream.*;
|
||||
import java.util.*;
|
||||
|
||||
class T8067792 {
|
||||
void test(Stream<List<?>> sl) {
|
||||
Runnable r = new Runnable() {
|
||||
public void run() {
|
||||
Stream<List<?>> constructor = sl.filter(c -> true);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
4
langtools/test/tools/javac/lambda/8067792/T8067792.out
Normal file
4
langtools/test/tools/javac/lambda/8067792/T8067792.out
Normal file
@ -0,0 +1,4 @@
|
||||
T8067792.java:13:37: compiler.warn.potential.lambda.found
|
||||
- compiler.err.warnings.and.werror
|
||||
1 error
|
||||
1 warning
|
Loading…
x
Reference in New Issue
Block a user