@@ -2374,7 +2374,12 @@ void checkClass(DiagnosticPosition pos, Symbol c, List<JCTree> supertypes) {
2374
2374
return ;
2375
2375
if (seenClasses .contains (c )) {
2376
2376
errorFound = true ;
2377
- noteCyclic (pos , (ClassSymbol )c );
2377
+ log .error (pos , Errors .CyclicInheritance (c ));
2378
+ seenClasses .stream ()
2379
+ .filter (s -> !s .type .isErroneous ())
2380
+ .filter (ClassSymbol .class ::isInstance )
2381
+ .map (ClassSymbol .class ::cast )
2382
+ .forEach (Check .this ::handleCyclic );
2378
2383
} else if (!c .type .isErroneous ()) {
2379
2384
try {
2380
2385
seenClasses .add (c );
@@ -2451,7 +2456,8 @@ private boolean checkNonCyclicInternal(DiagnosticPosition pos, Type t) {
2451
2456
if ((c .flags_field & ACYCLIC ) != 0 ) return true ;
2452
2457
2453
2458
if ((c .flags_field & LOCKED ) != 0 ) {
2454
- noteCyclic (pos , (ClassSymbol )c );
2459
+ log .error (pos , Errors .CyclicInheritance (c ));
2460
+ handleCyclic ((ClassSymbol )c );
2455
2461
} else if (!c .type .isErroneous ()) {
2456
2462
try {
2457
2463
c .flags_field |= LOCKED ;
@@ -2478,9 +2484,10 @@ private boolean checkNonCyclicInternal(DiagnosticPosition pos, Type t) {
2478
2484
return complete ;
2479
2485
}
2480
2486
2481
- /** Note that we found an inheritance cycle. */
2482
- private void noteCyclic (DiagnosticPosition pos , ClassSymbol c ) {
2483
- log .error (pos , Errors .CyclicInheritance (c ));
2487
+ /** Handle finding an inheritance cycle on a class by setting
2488
+ * the class' and its supertypes' types to the error type.
2489
+ **/
2490
+ private void handleCyclic (ClassSymbol c ) {
2484
2491
for (List <Type > l =types .interfaces (c .type ); l .nonEmpty (); l =l .tail )
2485
2492
l .head = types .createErrorType ((ClassSymbol )l .head .tsym , Type .noType );
2486
2493
Type st = types .supertype (c .type );
0 commit comments