Skip to content

Commit d2555b6

Browse files
committed
GROOVY-5961,GROOVY-6777,GROOVY-6809,GROOVY-7609,GROOVY-9168,GROOVY-9189
1 parent 096e7c5 commit d2555b6

File tree

20 files changed

+4035
-294
lines changed

20 files changed

+4035
-294
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/basic/InnerClassTests.java

+75-42
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
package org.eclipse.jdt.groovy.core.tests.basic;
1717

1818
import static org.eclipse.jdt.groovy.core.tests.GroovyBundle.isAtLeastGroovy;
19-
import static org.junit.Assume.assumeTrue;
2019

21-
import org.junit.Ignore;
2220
import org.junit.Test;
2321

2422
public final class InnerClassTests extends GroovyCompilerTestSuite {
@@ -608,7 +606,7 @@ public void testAnonymousInnerClass11() {
608606
String[] sources = {
609607
"A.groovy",
610608
"class A {" +
611-
// field with anon. inner initializer argument:
609+
// field initializer with anon. inner argument:
612610
" C cee = new C(1, '2', new Runnable() {\n" +
613611
" void run() {\n" +
614612
" println 'hi!'\n" +
@@ -652,7 +650,7 @@ public void testAnonymousInnerClass11a() {
652650
String[] sources = {
653651
"A.groovy",
654652
"class A {" +
655-
// field with anon. inner initializer argument:
653+
// field initializer with anon. inner argument:
656654
" C cee = newC(1, '2', new Runnable() {\n" +
657655
" void run() {\n" +
658656
" }\n" +
@@ -697,7 +695,7 @@ public void testAnonymousInnerClass11b() {
697695
String[] sources = {
698696
"A.groovy",
699697
"class A {" +
700-
// field with anon. inner initializer argument:
698+
// field initializer with anon. inner argument:
701699
" C cee = newC().one(1).two('2').three(new Runnable() {\n" +
702700
" void run() {\n" +
703701
" }\n" +
@@ -752,7 +750,7 @@ public void testAnonymousInnerClass12() {
752750
"A.groovy",
753751
"class A {" +
754752
" static main(args) {\n" +
755-
// local with anon. inner initializer argument:
753+
// local initializer with anon. inner argument:
756754
" C cee = new C(1, '2', new Runnable() {\n" +
757755
" void run() {\n" +
758756
" println 'hi!'\n" +
@@ -843,6 +841,30 @@ public void testAnonymousInnerClass14() {
843841
runNegativeTest(sources, "");
844842
}
845843

844+
@Test
845+
public void testAnonymousInnerClass14a() {
846+
//@formatter:off
847+
String[] sources = {
848+
"C.groovy",
849+
"class C {\n" +
850+
" static int count\n" +
851+
" @SuppressWarnings('rawtypes')\n" +
852+
" static def m() {\n" +
853+
" new LinkedList() {\n" +
854+
" @Override\n" +
855+
" def get(int i) {\n" +
856+
" setCount(getCount() + 1)\n" +
857+
" super.get(i)\n" +
858+
" }\n" +
859+
" }\n" +
860+
" }\n" +
861+
"}\n",
862+
};
863+
//@formatter:on
864+
865+
runNegativeTest(sources, "");
866+
}
867+
846868
@Test
847869
public void testAnonymousInnerClass15() {
848870
//@formatter:off
@@ -892,8 +914,6 @@ public void testAnonymousInnerClass16() {
892914

893915
@Test // https://issues.apache.org/jira/browse/GROOVY-5961
894916
public void testAnonymousInnerClass17() {
895-
assumeTrue(isAtLeastGroovy(25));
896-
897917
//@formatter:off
898918
String[] sources = {
899919
"Script.groovy",
@@ -916,8 +936,6 @@ public void testAnonymousInnerClass17() {
916936

917937
@Test // https://issues.apache.org/jira/browse/GROOVY-5961
918938
public void testAnonymousInnerClass18() {
919-
assumeTrue(isAtLeastGroovy(25));
920-
921939
//@formatter:off
922940
String[] sources = {
923941
"Abstract.groovy",
@@ -999,7 +1017,7 @@ public void testAnonymousInnerClass20() {
9991017
runConformTest(sources, "foo");
10001018
}
10011019

1002-
@Test @Ignore // https://issues.apache.org/jira/browse/GROOVY-6809
1020+
@Test // https://issues.apache.org/jira/browse/GROOVY-6809
10031021
public void testAnonymousInnerClass21() {
10041022
//@formatter:off
10051023
String[] sources = {
@@ -1025,7 +1043,7 @@ public void testAnonymousInnerClass21() {
10251043
runConformTest(sources, "works");
10261044
}
10271045

1028-
@Test @Ignore // https://issues.apache.org/jira/browse/GROOVY-9168
1046+
@Test // https://issues.apache.org/jira/browse/GROOVY-9168
10291047
public void testAnonymousInnerClass22() {
10301048
//@formatter:off
10311049
String[] sources = {
@@ -1050,7 +1068,7 @@ public void testAnonymousInnerClass22() {
10501068
runConformTest(sources, "works");
10511069
}
10521070

1053-
@Test @Ignore // https://issues.apache.org/jira/browse/GROOVY-6809
1071+
@Test // https://issues.apache.org/jira/browse/GROOVY-6809
10541072
public void testAnonymousInnerClass23() {
10551073
//@formatter:off
10561074
String[] sources = {
@@ -1079,7 +1097,7 @@ public void testAnonymousInnerClass23() {
10791097
runConformTest(sources, "works");
10801098
}
10811099

1082-
@Test @Ignore // https://issues.apache.org/jira/browse/GROOVY-6809
1100+
@Test // https://issues.apache.org/jira/browse/GROOVY-6809
10831101
public void testAnonymousInnerClass23a() {
10841102
//@formatter:off
10851103
String[] sources = {
@@ -1128,8 +1146,32 @@ public void testAnonymousInnerClass24() {
11281146
runConformTest(sources, "works");
11291147
}
11301148

1131-
@Test @Ignore
1149+
@Test // https://issues.apache.org/jira/browse/GROOVY-9168
11321150
public void testAnonymousInnerClass24a() {
1151+
//@formatter:off
1152+
String[] sources = {
1153+
"Main.groovy",
1154+
"class Main {\n" +
1155+
" static main(args) {\n" +
1156+
" this.meth()\n" +
1157+
" }\n" +
1158+
// default argument with anon. inner initializer:
1159+
" static void meth(Runnable action = new Runnable() {\n" +
1160+
" @Override void run() {\n" +
1161+
" print 'works'\n" +
1162+
" }\n" +
1163+
" }) {\n" +
1164+
" action.run()\n" +
1165+
" }\n" +
1166+
"}\n",
1167+
};
1168+
//@formatter:on
1169+
1170+
runConformTest(sources, "works");
1171+
}
1172+
1173+
@Test // https://issues.apache.org/jira/browse/GROOVY-9168
1174+
public void testAnonymousInnerClass24b() {
11331175
//@formatter:off
11341176
String[] sources = {
11351177
"Script.groovy",
@@ -1267,7 +1309,13 @@ public void testReferenceToUninitializedThis1() {
12671309
};
12681310
//@formatter:on
12691311

1270-
runConformTest(sources, "", "java.lang.VerifyError: Bad type on operand stack\n");
1312+
runNegativeTest(sources,
1313+
"----------\n" +
1314+
"1. ERROR in Outer.groovy (at line 6)\n" +
1315+
"\tOuter() {\n" +
1316+
"\t^\n" +
1317+
"Groovy:Cannot reference 'this' before supertype constructor has been called.\n" +
1318+
"----------\n");
12711319
}
12721320

12731321
@Test
@@ -1286,10 +1334,10 @@ public void testReferenceToUninitializedThis1a() {
12861334

12871335
runNegativeTest(sources,
12881336
"----------\n" +
1289-
"1. ERROR in Outer.groovy (at line 1)\n" +
1290-
"\tclass Outer {\n" +
1337+
"1. ERROR in Outer.groovy (at line 4)\n" +
1338+
"\tOuter(Inner inner = new Inner()) {\n" +
12911339
"\t^\n" +
1292-
"Groovy:Apparent variable 'this' was found in a static scope but doesn't refer to a local variable, static field or class.\n" +
1340+
"Groovy:Cannot reference 'this' before supertype constructor has been called.\n" +
12931341
"----------\n");
12941342
}
12951343

@@ -1310,8 +1358,8 @@ public void testReferenceToUninitializedThis2() {
13101358
"----------\n" +
13111359
"1. ERROR in C.groovy (at line 2)\n" +
13121360
"\tC(foo = bar()) {\n" +
1313-
"\t ^^^^\n" +
1314-
"Groovy:Can't access instance method 'bar' for a constructor parameter default value\n" +
1361+
"\t ^^^\n" +
1362+
"Groovy:Cannot reference 'bar' before supertype constructor has been called.\n" +
13151363
"----------\n");
13161364
}
13171365

@@ -1332,8 +1380,8 @@ public void testReferenceToUninitializedThis2a() {
13321380
"----------\n" +
13331381
"1. ERROR in C.groovy (at line 2)\n" +
13341382
"\tC(foo = this.bar()) {\n" +
1335-
"\t ^^^^\n" +
1336-
"Groovy:Can't access instance method 'bar' for a constructor parameter default value\n" +
1383+
"\t ^^^^\n" +
1384+
"Groovy:Cannot reference 'this' before supertype constructor has been called.\n" +
13371385
"----------\n");
13381386
}
13391387

@@ -1355,12 +1403,7 @@ public void testReferenceToUninitializedThis2b() {
13551403
"1. ERROR in C.groovy (at line 2)\n" +
13561404
"\tC(foo = this.&bar) {\n" +
13571405
"\t ^^^^\n" +
1358-
"Groovy:Apparent variable 'this' was found in a static scope but doesn't refer to a local variable, static field or class.\n" +
1359-
"----------\n" +
1360-
"2. ERROR in C.groovy (at line 2)\n" +
1361-
"\tC(foo = this.&bar) {\n" +
1362-
"\t ^^^^\n" +
1363-
"Groovy:cannot reference this inside of this ((java.lang.Object) this.&bar)(....) before supertype constructor has been called\n" +
1406+
"Groovy:Cannot reference 'this' before supertype constructor has been called.\n" +
13641407
"----------\n");
13651408
}
13661409

@@ -1382,7 +1425,7 @@ public void testReferenceToUninitializedThis3() {
13821425
"1. ERROR in C.groovy (at line 2)\n" +
13831426
"\tC(foo = bar) {\n" +
13841427
"\t ^^^\n" +
1385-
"Groovy:Apparent variable 'bar' was found in a static scope but doesn't refer to a local variable, static field or class.\n" +
1428+
"Groovy:Cannot reference 'bar' before supertype constructor has been called.\n" +
13861429
"----------\n");
13871430
}
13881431

@@ -1404,12 +1447,7 @@ public void testReferenceToUninitializedThis3a() {
14041447
"1. ERROR in C.groovy (at line 2)\n" +
14051448
"\tC(foo = this.bar) {\n" +
14061449
"\t ^^^^\n" +
1407-
"Groovy:Apparent variable 'this' was found in a static scope but doesn't refer to a local variable, static field or class.\n" +
1408-
"----------\n" +
1409-
"2. ERROR in C.groovy (at line 2)\n" +
1410-
"\tC(foo = this.bar) {\n" +
1411-
"\t ^^^^\n" +
1412-
"Groovy:cannot reference this inside of this ((java.lang.Object) this.bar)(....) before supertype constructor has been called\n" +
1450+
"Groovy:Cannot reference 'this' before supertype constructor has been called.\n" +
14131451
"----------\n");
14141452
}
14151453

@@ -1431,12 +1469,7 @@ public void testReferenceToUninitializedThis3b() {
14311469
"1. ERROR in C.groovy (at line 2)\n" +
14321470
"\tC(foo = this.@bar) {\n" +
14331471
"\t ^^^^\n" +
1434-
"Groovy:Apparent variable 'this' was found in a static scope but doesn't refer to a local variable, static field or class.\n" +
1435-
"----------\n" +
1436-
"2. ERROR in C.groovy (at line 2)\n" +
1437-
"\tC(foo = this.@bar) {\n" +
1438-
"\t ^^^^\n" +
1439-
"Groovy:cannot reference this inside of this ((java.lang.Object) this.bar)(....) before supertype constructor has been called\n" +
1472+
"Groovy:Cannot reference 'this' before supertype constructor has been called.\n" +
14401473
"----------\n");
14411474
}
14421475

base/org.codehaus.groovy24/.checkstyle

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
<file-match-pattern match-pattern="groovy/classgen/ClassCompletionVerifier.java" include-pattern="false" />
4343
<file-match-pattern match-pattern="groovy/classgen/EnumVisitor.java" include-pattern="false" />
4444
<file-match-pattern match-pattern="groovy/classgen/ExtendedVerifier.java" include-pattern="false" />
45+
<file-match-pattern match-pattern="groovy/classgen/InnerClassCompletionVisitor.java" include-pattern="false" />
46+
<file-match-pattern match-pattern="groovy/classgen/InnerClassVisitor.java" include-pattern="false" />
47+
<file-match-pattern match-pattern="groovy/classgen/InnerClassVisitorHelper.java" include-pattern="false" />
4548
<file-match-pattern match-pattern="groovy/classgen/VariableScopeVisitor.java" include-pattern="false" />
4649
<file-match-pattern match-pattern="groovy/classgen/Verifier.java" include-pattern="false" />
4750
<file-match-pattern match-pattern="groovy/classgen/asm/BytecodeHelper.java" include-pattern="false" />

0 commit comments

Comments
 (0)