Allow open callable members in expect interfaces

#KT-42094 fixed
This commit is contained in:
sebastian.sellmair
2020-11-06 17:03:30 +01:00
committed by Sebastian Sellmair
parent bf0156f7c6
commit 06cb64bb51
20 changed files with 289 additions and 10 deletions
@@ -23,9 +23,6 @@ interface CirFunctionOrProperty :
val returnType: CirType
val kind: CallableMemberDescriptor.Kind
fun isNonAbstractMemberInInterface(): Boolean =
modality != Modality.ABSTRACT && containingClassDetails?.kind == ClassKind.INTERFACE
fun isVirtual(): Boolean =
visibility != DescriptorVisibilities.PRIVATE
&& modality != Modality.FINAL
@@ -29,8 +29,7 @@ abstract class AbstractFunctionOrPropertyCommonizer<T : CirFunctionOrProperty>(
}
override fun doCommonizeWith(next: T): Boolean =
!next.isNonAbstractMemberInInterface() // non-abstract callable members declared in interface can't be commonized
&& next.kind != DELEGATION // delegated members should not be commonized
next.kind != DELEGATION // delegated members should not be commonized
&& (next.kind != SYNTHESIZED || next.containingClassDetails?.isData != true) // synthesized members of data classes should not be commonized
&& kind == next.kind
&& modality.commonizeWith(next.modality)
@@ -0,0 +1,3 @@
expect interface Interface {
open fun openFun()
}
@@ -0,0 +1,5 @@
actual interface Interface {
actual fun openFun() = Unit
fun openFunWithOtherParams(param: Int) = Unit
fun openInJs_abstractInJvm() = Unit
}
@@ -0,0 +1,5 @@
actual interface Interface {
actual fun openFun() = Unit
fun openFunWithOtherParams(param: Double) = Unit
fun openInJs_abstractInJvm()
}
@@ -0,0 +1,5 @@
interface Interface {
fun openFun() = Unit
fun openFunWithOtherParams(param: Int) = Unit
fun openInJs_abstractInJvm() = Unit
}
@@ -0,0 +1,5 @@
interface Interface {
fun openFun() = Unit
fun openFunWithOtherParams(param: Double) = Unit
fun openInJs_abstractInJvm()
}
@@ -15,4 +15,6 @@ class CallableMemberCommonizationFromSourcesTest : AbstractCommonizationFromSour
fun testReturnTypes() = doTestSuccessfulCommonization()
fun testExtensionReceivers() = doTestSuccessfulCommonization()
fun testOpenCallableMemberInInterface() = doTestSuccessfulCommonization()
}