@@ -116,6 +116,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
116
116
private boolean checkingVariableTypeInDeclaration ;
117
117
private boolean inClosure , inPropertyExpression ;
118
118
private boolean isTopLevelProperty = true ;
119
+ /*package*/ int phase ; // sub-divide visit
119
120
120
121
/**
121
122
* A ConstructedNestedClass consists of an outer class and a name part, denoting a
@@ -478,7 +479,6 @@ protected boolean resolveNestedClass(final ClassNode type) {
478
479
// GROOVY-4043: for type "X", try "A$X" with each type in the class hierarchy (except for Object)
479
480
for (; cn != null && cycleCheck .add (cn ) && !isObjectType (cn ); cn = cn .getSuperClass ()) {
480
481
if (setRedirect (type , cn )) return true ;
481
- // GROOVY-9866: unresolvable interfaces
482
482
}
483
483
484
484
// Another case we want to check here is if we are in a
@@ -1390,7 +1390,7 @@ public void visitClass(final ClassNode node) {
1390
1390
ClassNode oldNode = currentClass ;
1391
1391
currentClass = node ;
1392
1392
// GRECLIPSE add
1393
- if (commencingResolution ()) try {
1393
+ if (phase == 2 || commencingResolution ()) try {
1394
1394
// GRECLIPSE end
1395
1395
ModuleNode module = node .getModule ();
1396
1396
if (!module .hasImportsResolved ()) {
@@ -1451,7 +1451,7 @@ public void visitClass(final ClassNode node) {
1451
1451
genericParameterNames = new HashMap <>();
1452
1452
}
1453
1453
resolveGenericsHeader (node .getGenericsTypes ());
1454
-
1454
+ switch ( phase ) { case 0 : case 1 : // GROOVY-9866, GROOVY-10466
1455
1455
ClassNode sn = node .getUnresolvedSuperClass ();
1456
1456
if (sn != null ) {
1457
1457
resolveOrFail (sn , "" , node , true );
@@ -1473,7 +1473,7 @@ public void visitClass(final ClassNode node) {
1473
1473
}
1474
1474
}
1475
1475
}
1476
-
1476
+ case 2 :
1477
1477
// VariableScopeVisitor visits anon. inner class body inline, so resolve now
1478
1478
for (Iterator <InnerClassNode > it = node .getInnerClasses (); it .hasNext (); ) {
1479
1479
InnerClassNode cn = it .next ();
@@ -1485,14 +1485,17 @@ public void visitClass(final ClassNode node) {
1485
1485
resolveOrFail (cn .getUnresolvedSuperClass (false ), cn ); // GROOVY-9642
1486
1486
}
1487
1487
}
1488
+ if (phase == 1 ) break ; // resolve other class headers before members, et al.
1488
1489
// initialize scopes/variables now that imports and super types are resolved
1489
1490
new VariableScopeVisitor (source ).visitClass (node );
1490
1491
1491
1492
visitTypeAnnotations (node );
1492
1493
super .visitClass (node );
1493
-
1494
1494
// GRECLIPSE add
1495
1495
finishedResolution ();
1496
+ // GRECLIPSE end
1497
+ }
1498
+ // GRECLIPSE add
1496
1499
} finally {
1497
1500
if (currentClass == node )
1498
1501
// GRECLIPSE end
@@ -1612,7 +1615,9 @@ private void resolveGenericsHeader(final GenericsType[] types, final GenericsTyp
1612
1615
boolean nameAdded = false ;
1613
1616
for (ClassNode upperBound : type .getUpperBounds ()) {
1614
1617
if (upperBound == null ) continue ;
1615
-
1618
+ // GRECLIPSE add
1619
+ if (upperBound .hasInconsistentHierarchy ()) continue ;
1620
+ // GRECLIPSE end
1616
1621
if (!isWildcardGT ) {
1617
1622
if (!nameAdded || !resolve (typeType )) {
1618
1623
if (dealWithGenerics ) {
0 commit comments