From 9d4db72d72f0bfe1dd41c89a6dc1bb214cec7e74 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Tue, 25 Apr 2023 00:16:38 +0200 Subject: [PATCH] [PL] Fix: Don't raise an error when external interface inherits from external class ^KT-57378 --- .../linkage/partial/ClassifierExplorer.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/ClassifierExplorer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/ClassifierExplorer.kt index 5185bcb98c5..4c61f750441 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/ClassifierExplorer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/ClassifierExplorer.kt @@ -203,10 +203,19 @@ internal class ClassifierExplorer( private fun IrClass.exploreSuperClasses(superTypeSymbols: Set): 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 }