Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2010 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.core.tests.compiler.regression; |
12 |
|
13 |
import java.util.Map; |
14 |
|
15 |
import junit.framework.Test; |
16 |
|
17 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
18 |
|
19 |
public class InnerClass15Test extends AbstractRegressionTest { |
20 |
public InnerClass15Test(String name) { |
21 |
super(name); |
22 |
} |
23 |
static { |
24 |
// TESTS_NUMBERS = new int[] { 2 }; |
25 |
} |
26 |
public static Test suite() { |
27 |
return buildMinimalComplianceTestSuite(testClass(), F_1_5); |
28 |
} |
29 |
protected Map getCompilerOptions() { |
30 |
Map options = super.getCompilerOptions(); |
31 |
options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); |
32 |
return options; |
33 |
} |
34 |
public void test001() { |
35 |
this.runNegativeTest(new String[] { |
36 |
"X.java", |
37 |
"class X {\n" + |
38 |
" <X> void foo() {\n" + |
39 |
" class X {}\n" + |
40 |
" }\n" + |
41 |
"}", |
42 |
}, |
43 |
"----------\n" + |
44 |
"1. WARNING in X.java (at line 2)\n" + |
45 |
" <X> void foo() {\n" + |
46 |
" ^\n" + |
47 |
"The type parameter X is hiding the type X\n" + |
48 |
"----------\n" + |
49 |
"2. WARNING in X.java (at line 3)\n" + |
50 |
" class X {}\n" + |
51 |
" ^\n" + |
52 |
"The nested type X is hiding the type parameter X of the generic method foo() of type X\n" + |
53 |
"----------\n" + |
54 |
"3. ERROR in X.java (at line 3)\n" + |
55 |
" class X {}\n" + |
56 |
" ^\n" + |
57 |
"The nested type X cannot hide an enclosing type\n" + |
58 |
"----------\n"); |
59 |
} |
60 |
public void test002() { |
61 |
this.runNegativeTest(new String[] { |
62 |
"X.java", |
63 |
"class X<X> {\n" + |
64 |
" void foo() {\n" + |
65 |
" class X {}\n" + |
66 |
" }\n" + |
67 |
"}", |
68 |
}, |
69 |
"----------\n" + |
70 |
"1. WARNING in X.java (at line 1)\n" + |
71 |
" class X<X> {\n" + |
72 |
" ^\n" + |
73 |
"The type parameter X is hiding the type X<X>\n" + |
74 |
"----------\n" + |
75 |
"2. WARNING in X.java (at line 3)\n" + |
76 |
" class X {}\n" + |
77 |
" ^\n" + |
78 |
"The nested type X is hiding the type parameter X of type X<X>\n" + |
79 |
"----------\n" + |
80 |
"3. ERROR in X.java (at line 3)\n" + |
81 |
" class X {}\n" + |
82 |
" ^\n" + |
83 |
"The nested type X cannot hide an enclosing type\n" + |
84 |
"----------\n"); |
85 |
} |
86 |
public void test003() { |
87 |
this.runNegativeTest(new String[] { |
88 |
"Y.java", |
89 |
"class Y {\n" + |
90 |
"class X {}\n" + |
91 |
" <X> void foo() {\n" + |
92 |
" class X {}\n" + |
93 |
" }\n" + |
94 |
"}", |
95 |
}, |
96 |
"----------\n" + |
97 |
"1. WARNING in Y.java (at line 3)\n" + |
98 |
" <X> void foo() {\n" + |
99 |
" ^\n" + |
100 |
"The type parameter X is hiding the type Y.X\n" + |
101 |
"----------\n" + |
102 |
"2. WARNING in Y.java (at line 4)\n" + |
103 |
" class X {}\n" + |
104 |
" ^\n" + |
105 |
"The nested type X is hiding the type parameter X of the generic method foo() of type Y\n" + |
106 |
"----------\n" + |
107 |
"3. ERROR in Y.java (at line 4)\n" + |
108 |
" class X {}\n" + |
109 |
" ^\n" + |
110 |
"The nested type X cannot hide an enclosing type\n" + |
111 |
"----------\n"); |
112 |
} |
113 |
public static Class testClass() { |
114 |
return InnerClass15Test.class; |
115 |
} |
116 |
} |