langtools/test/tools/javac/foreach/7139681/T7139681neg.java
author mcimadamore
Thu, 06 Jun 2013 15:32:41 +0100
changeset 18379 8dd20756448c
permissions -rw-r--r--
7139681: Enhanced for loop: local variable scope inconsistent with JLS Summary: For-each loop variable is incorrectly visible from the for-each expression Reviewed-by: jjg, vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18379
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
     1
/*
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
     3
 * @bug 7139681
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
     4
 * @summary Enhanced for loop: local variable scope inconsistent with JLS
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
     5
 *
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
     6
 * @compile/fail/ref=T7139681neg.out -XDrawDiagnostics T7139681neg.java
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
     7
 */
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
     8
class T7139681neg {
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
     9
    void testArray() {
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
    10
        for (int a : a) { }
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
    11
    }
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
    12
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
    13
    void testIterable() {
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
    14
        for (Integer b : b) { }
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
    15
    }
8dd20756448c 7139681: Enhanced for loop: local variable scope inconsistent with JLS
mcimadamore
parents:
diff changeset
    16
}