Tue, 21 May 2013 13:50:56 +0100
8005207: test has 2 @bug tags
Reviewed-by: mcimadamore
duke@1 | 1 | /* |
duke@1 | 2 | * @test /nodynamiccopyright/ |
duke@1 | 3 | * @bug 4037746 4277279 4350658 4785453 |
duke@1 | 4 | * @summary Verify that an inner class cannot have the same simple name as an enclosing one. |
duke@1 | 5 | * @author William Maddox (maddox) |
duke@1 | 6 | * |
jjg@611 | 7 | * @compile/fail/ref=NestedInnerClassNames.out -XDrawDiagnostics NestedInnerClassNames.java |
duke@1 | 8 | */ |
duke@1 | 9 | |
duke@1 | 10 | /* |
duke@1 | 11 | * This program should compile with errors as marked. |
duke@1 | 12 | */ |
duke@1 | 13 | |
duke@1 | 14 | public class NestedInnerClassNames { |
duke@1 | 15 | |
duke@1 | 16 | class NestedInnerClassNames {} // ERROR |
duke@1 | 17 | |
duke@1 | 18 | void m1() { |
duke@1 | 19 | class NestedInnerClassNames {} // ERROR |
duke@1 | 20 | } |
duke@1 | 21 | |
duke@1 | 22 | class foo { |
duke@1 | 23 | class foo { } // ERROR |
duke@1 | 24 | } |
duke@1 | 25 | |
duke@1 | 26 | void m2 () { |
duke@1 | 27 | class foo { |
duke@1 | 28 | class foo { } // ERROR |
duke@1 | 29 | } |
duke@1 | 30 | } |
duke@1 | 31 | |
duke@1 | 32 | class bar { |
duke@1 | 33 | class foo { } |
duke@1 | 34 | class NestedInnerClassNames {} // ERROR |
duke@1 | 35 | } |
duke@1 | 36 | |
duke@1 | 37 | void m3() { |
duke@1 | 38 | class bar { |
duke@1 | 39 | class foo { } |
duke@1 | 40 | class NestedInnerClassNames {} // ERROR |
duke@1 | 41 | } |
duke@1 | 42 | } |
duke@1 | 43 | |
duke@1 | 44 | class baz { |
duke@1 | 45 | class baz { // ERROR |
duke@1 | 46 | class baz { } // ERROR |
duke@1 | 47 | } |
duke@1 | 48 | } |
duke@1 | 49 | |
duke@1 | 50 | void m4() { |
duke@1 | 51 | class baz { |
duke@1 | 52 | class baz { // ERROR |
duke@1 | 53 | class baz { } // ERROR |
duke@1 | 54 | } |
duke@1 | 55 | } |
duke@1 | 56 | } |
duke@1 | 57 | |
duke@1 | 58 | class foo$bar { |
duke@1 | 59 | class foo$bar { // ERROR |
duke@1 | 60 | class foo { } |
duke@1 | 61 | class bar { } |
duke@1 | 62 | } |
duke@1 | 63 | } |
duke@1 | 64 | |
duke@1 | 65 | void m5() { |
duke@1 | 66 | class foo$bar { |
duke@1 | 67 | class foo$bar { // ERROR |
duke@1 | 68 | class foo { } |
duke@1 | 69 | class bar { } |
duke@1 | 70 | } |
duke@1 | 71 | } |
duke@1 | 72 | } |
duke@1 | 73 | |
duke@1 | 74 | class $bar { |
duke@1 | 75 | class foo { |
duke@1 | 76 | class $bar { } // ERROR |
duke@1 | 77 | } |
duke@1 | 78 | } |
duke@1 | 79 | |
duke@1 | 80 | void m6() { |
duke@1 | 81 | class $bar { |
duke@1 | 82 | class foo { |
duke@1 | 83 | class $bar { } // ERROR |
duke@1 | 84 | } |
duke@1 | 85 | } |
duke@1 | 86 | } |
duke@1 | 87 | |
duke@1 | 88 | class bar$bar { |
duke@1 | 89 | class bar { |
duke@1 | 90 | class bar{ } // ERROR |
duke@1 | 91 | } |
duke@1 | 92 | } |
duke@1 | 93 | |
duke@1 | 94 | void m7() { |
duke@1 | 95 | class bar$bar { |
duke@1 | 96 | class bar { |
duke@1 | 97 | class bar{ } // ERROR |
duke@1 | 98 | } |
duke@1 | 99 | } |
duke@1 | 100 | } |
duke@1 | 101 | |
duke@1 | 102 | // The name of the class below clashes with the name of the |
duke@1 | 103 | // class created above for 'class foo { class foo {} }'. |
duke@1 | 104 | // The clash follows from the naming requirements of the inner |
duke@1 | 105 | // classes spec, but is most likely a specification bug. |
duke@1 | 106 | |
duke@1 | 107 | // Error may be reported here. See 4278961. |
duke@1 | 108 | // As of Merlin-beta b21, this now results in an error. |
duke@1 | 109 | class foo$foo { } // ERROR |
duke@1 | 110 | |
duke@1 | 111 | } |