[PL] Fix: Don't raise an error when external interface inherits from external class
^KT-57378
This commit is contained in:
committed by
Space Team
parent
3bc744af35
commit
9d4db72d72
+13
-4
@@ -203,10 +203,19 @@ internal class ClassifierExplorer(
|
||||
|
||||
private fun IrClass.exploreSuperClasses(superTypeSymbols: Set<IrClassSymbol>): Unusable? {
|
||||
if (isInterface) {
|
||||
// Can inherit only from other interfaces.
|
||||
val realSuperClassSymbols = superTypeSymbols.filter { it != builtIns.anyClass && !it.owner.isInterface }
|
||||
if (realSuperClassSymbols.isNotEmpty())
|
||||
return InvalidInheritance(symbol, realSuperClassSymbols) // Interface inherits from a real class(es).
|
||||
// Regular interface can inherit only from other regular interfaces.
|
||||
// External interface can inherit from external interfaces and external class, but not regular ones.
|
||||
val illegalSuperClassSymbols = if (isExternal)
|
||||
superTypeSymbols.filter { superTypeSymbol ->
|
||||
superTypeSymbol != builtIns.anyClass && superTypeSymbol.owner.let { superClass ->
|
||||
!superClass.isExternal || !(superClass.isInterface || superClass.isClass)
|
||||
}
|
||||
}
|
||||
else
|
||||
superTypeSymbols.filter { it != builtIns.anyClass && !it.owner.isInterface }
|
||||
|
||||
if (illegalSuperClassSymbols.isNotEmpty())
|
||||
return InvalidInheritance(symbol, illegalSuperClassSymbols)
|
||||
} else {
|
||||
// Check the number of non-interface supertypes.
|
||||
val superClassSymbols = superTypeSymbols.filter { !it.owner.isInterface }
|
||||
|
||||
Reference in New Issue
Block a user