Skip to content

Commit bf6d32b

Browse files
committed
GROOVY-10125
1 parent 81aa7e3 commit bf6d32b

4 files changed

Lines changed: 43 additions & 11 deletions

File tree

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

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,13 +1120,32 @@ public void testCyclicReference5() {
11201120
"----------\n" +
11211121
"1. ERROR in C.groovy (at line 1)\n" +
11221122
"\tclass C<T extends T> {\n" +
1123-
"\t ^\n" +
1123+
"\t ^\n" +
11241124
"Groovy:Cycle detected: the type T cannot extend/implement itself or one of its own member types\n" +
11251125
"----------\n");
11261126
}
11271127

11281128
@Test
11291129
public void testCyclicReference6() {
1130+
//@formatter:off
1131+
String[] sources = {
1132+
"C.groovy",
1133+
"class C<T extends U, U extends T> {\n" +
1134+
"}\n",
1135+
};
1136+
//@formatter:on
1137+
1138+
runNegativeTest(sources,
1139+
"----------\n" +
1140+
"1. ERROR in C.groovy (at line 1)\n" +
1141+
"\tclass C<T extends U, U extends T> {\n" +
1142+
"\t ^\n" +
1143+
"Groovy:Cycle detected: the type T cannot extend/implement itself or one of its own member types\n" +
1144+
"----------\n");
1145+
}
1146+
1147+
@Test
1148+
public void testCyclicReference7() {
11301149
//@formatter:off
11311150
String[] sources = {
11321151
"C.groovy",
@@ -1145,7 +1164,7 @@ public void testCyclicReference6() {
11451164
}
11461165

11471166
@Test
1148-
public void testCyclicReference7() {
1167+
public void testCyclicReference8() {
11491168
//@formatter:off
11501169
String[] sources = {
11511170
"C.groovy",
@@ -1174,7 +1193,7 @@ public void testCyclicReference7() {
11741193
}
11751194

11761195
@Test
1177-
public void testCyclicReference8() {
1196+
public void testCyclicReference9() {
11781197
//@formatter:off
11791198
String[] sources = {
11801199
"I.groovy",
@@ -1203,7 +1222,7 @@ public void testCyclicReference8() {
12031222
}
12041223

12051224
@Test
1206-
public void testCyclicReference9() {
1225+
public void testCyclicReference10() {
12071226
//@formatter:off
12081227
String[] sources = {
12091228
"C.groovy",
@@ -1234,7 +1253,7 @@ public void testCyclicReference9() {
12341253
}
12351254

12361255
@Test // typo that caused overflow
1237-
public void testCyclicReference10() {
1256+
public void testCyclicReference11() {
12381257
//@formatter:off
12391258
String[] sources = {
12401259
"A.groovy",
@@ -1292,6 +1311,19 @@ public void testNonCyclicReference2() {
12921311
runNegativeTest(sources, "");
12931312
}
12941313

1314+
@Test // GROOVY-10125
1315+
public void testNonCyclicReference3() {
1316+
//@formatter:off
1317+
String[] sources = {
1318+
"C.groovy",
1319+
"class C<T, U extends T> {\n" +
1320+
"}\n",
1321+
};
1322+
//@formatter:on
1323+
1324+
runNegativeTest(sources, "");
1325+
}
1326+
12951327
@Test
12961328
public void testUnreachable_1047() {
12971329
//@formatter:off

base/org.codehaus.groovy25/src/org/codehaus/groovy/control/ResolveVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ public void visitClass(ClassNode node) {
15901590
for (ClassNode anInterface : node.getInterfaces()) {
15911591
resolveOrFail(anInterface, node, true);
15921592
}
1593-
/* GRECLIPSE edit -- GRECLIPSE-531, GROOVY-10113, et al.
1593+
/* GRECLIPSE edit -- GRECLIPSE-531, GROOVY-10113, GROOVY-10125, et al.
15941594
checkCyclicInheritance(node, node.getUnresolvedSuperClass(), node.getInterfaces());
15951595
*/
15961596
if (sn != null) checkCyclicInheritance(node, sn);
@@ -1601,7 +1601,7 @@ public void visitClass(ClassNode node) {
16011601
for (GenericsType gt : node.getGenericsTypes()) {
16021602
if (gt != null && gt.getUpperBounds() != null) {
16031603
for (ClassNode variant : gt.getUpperBounds()) {
1604-
if (variant.isGenericsPlaceHolder()) checkCyclicInheritance(gt.getType().redirect(), variant);
1604+
if (variant.isGenericsPlaceHolder()) checkCyclicInheritance(variant, gt.getType());
16051605
}
16061606
}
16071607
}

base/org.codehaus.groovy30/src/org/codehaus/groovy/control/ResolveVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ public void visitClass(final ClassNode node) {
14801480
for (ClassNode anInterface : node.getInterfaces()) {
14811481
resolveOrFail(anInterface, "", node, true);
14821482
}
1483-
/* GRECLIPSE edit -- GROOVY-10113
1483+
/* GRECLIPSE edit -- GRECLIPSE-531, GROOVY-10113, GROOVY-10125, et al.
14841484
checkCyclicInheritance(node, node.getUnresolvedSuperClass(), node.getInterfaces());
14851485
*/
14861486
if (sn != null) checkCyclicInheritance(node, sn);
@@ -1491,7 +1491,7 @@ public void visitClass(final ClassNode node) {
14911491
for (GenericsType gt : node.getGenericsTypes()) {
14921492
if (gt != null && gt.getUpperBounds() != null) {
14931493
for (ClassNode variant : gt.getUpperBounds()) {
1494-
if (variant.isGenericsPlaceHolder()) checkCyclicInheritance(gt.getType().redirect(), variant);
1494+
if (variant.isGenericsPlaceHolder()) checkCyclicInheritance(variant, gt.getType());
14951495
}
14961496
}
14971497
}

base/org.codehaus.groovy40/src/org/codehaus/groovy/control/ResolveVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ public void visitClass(final ClassNode node) {
14751475
for (ClassNode anInterface : node.getInterfaces()) {
14761476
resolveOrFail(anInterface, "", node, true);
14771477
}
1478-
/* GRECLIPSE edit -- GROOVY-10113
1478+
/* GRECLIPSE edit -- GRECLIPSE-531, GROOVY-10113, GROOVY-10125, et al.
14791479
checkCyclicInheritance(node, node.getUnresolvedSuperClass(), node.getInterfaces());
14801480
*/
14811481
if (sn != null) checkCyclicInheritance(node, sn);
@@ -1486,7 +1486,7 @@ public void visitClass(final ClassNode node) {
14861486
for (GenericsType gt : node.getGenericsTypes()) {
14871487
if (gt != null && gt.getUpperBounds() != null) {
14881488
for (ClassNode variant : gt.getUpperBounds()) {
1489-
if (variant.isGenericsPlaceHolder()) checkCyclicInheritance(gt.getType().redirect(), variant);
1489+
if (variant.isGenericsPlaceHolder()) checkCyclicInheritance(variant, gt.getType());
14901490
}
14911491
}
14921492
}

0 commit comments

Comments
 (0)