8015648: Duplicate variable in lambda causes javac crash

Missing flag in synthetic lambda blog is causing duplicates symbol to go undetected

Reviewed-by: jjg, vromero
This commit is contained in:
Maurizio Cimadamore 2013-06-06 15:37:23 +01:00
parent abaf1a5c51
commit 459b2cba93
3 changed files with 39 additions and 1 deletions

View File

@ -2609,7 +2609,7 @@ public class Attr extends JCTree.Visitor {
//field initializer
lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dupUnshared()));
lambdaEnv.info.scope.owner =
new MethodSymbol(0, names.empty, null,
new MethodSymbol((owner.flags() & STATIC) | BLOCK, names.empty, null,
env.info.scope.owner);
} else {
lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dup()));

View File

@ -0,0 +1,31 @@
/*
* @test /nodynamiccopyright/
* @bug 8015648
* @summary Duplicate variable in lambda causes javac crash
* @compile/fail/ref=LambdaScope05.out -XDrawDiagnostics LambdaScope05.java
*/
class LambdaScope05 {
interface VoidFun1 {
void m(int i);
}
static Runnable r1 = () -> { VoidFun1 p = p -> { }; };
Runnable r2 = () -> { VoidFun1 p = p -> { }; };
static {
Runnable r = () -> { VoidFun1 p = p -> { }; };
}
{
Runnable r = () -> { VoidFun1 p = p -> { }; };
}
static void m_static() {
Runnable r = () -> { VoidFun1 p = p -> { }; };
}
void m() {
Runnable r = () -> { VoidFun1 p = p -> { }; };
}
}

View File

@ -0,0 +1,7 @@
LambdaScope05.java:13:47: compiler.err.already.defined.in.clinit: kindname.variable, p, kindname.static.init, kindname.class, LambdaScope05
LambdaScope05.java:14:40: compiler.err.already.defined.in.clinit: kindname.variable, p, kindname.instance.init, kindname.class, LambdaScope05
LambdaScope05.java:17:43: compiler.err.already.defined.in.clinit: kindname.variable, p, kindname.static.init, kindname.class, LambdaScope05
LambdaScope05.java:21:43: compiler.err.already.defined.in.clinit: kindname.variable, p, kindname.instance.init, kindname.class, LambdaScope05
LambdaScope05.java:25:43: compiler.err.already.defined: kindname.variable, p, kindname.method, m_static()
LambdaScope05.java:29:43: compiler.err.already.defined: kindname.variable, p, kindname.method, m()
6 errors