Fallback to Any type in case supertypes are empty
This can happen e.g. if all supertypes were on the cycle (A : B, B : A) -- then SupertypesLoopChecker will cut all supertypes that are on cycle, leaving set of supertypes empty. Some clients in the compiler are not ready to work with empty list of supertypes -- notably, CommonSupertypes. ^KT-23029 Fixed
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.types;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
@@ -160,4 +161,14 @@ public abstract class AbstractClassTypeConstructor extends AbstractTypeConstruct
|
||||
|
||||
return additionalNeighbours;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected KotlinType defaultSupertypeIfEmpty() {
|
||||
if (KotlinBuiltIns.isSpecialClassWithNoSupertypes(this.getDeclarationDescriptor())) {
|
||||
return null;
|
||||
} else {
|
||||
return getBuiltIns().getAnyType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user