[PL] Fix: Allow IrEnumConstructorCall with constructed class with kind=ENUM_ENTRY

This commit is contained in:
Dmitriy Dolovov
2023-03-22 22:05:20 +01:00
committed by Space Team
parent 66532d714e
commit 0f17191e0e
3 changed files with 27 additions and 1 deletions
@@ -519,7 +519,8 @@ internal class PartiallyLinkedIrTreePatcher(
checkReferencedDeclaration(symbol)
?: checkExpressionTypeArguments()
?: checkReferencedDeclarationType(expression.symbol.owner.parentAsClass, "enum class") { constructedClass ->
constructedClass.kind == ClassKind.ENUM_CLASS || constructedClass.symbol == builtIns.enumClass
constructedClass.kind == ClassKind.ENUM_CLASS || constructedClass.kind == ClassKind.ENUM_ENTRY
|| constructedClass.symbol == builtIns.enumClass
}
?: checkArgumentsAndValueParameters(symbol.owner)
}
@@ -220,3 +220,25 @@ fun instantiationOfAbstractClass() {
// abstract classes except for from their direct inheritors.
ClassToAbstractClass().getGreeting()
}
// This is required to check that enum entry classes are correctly handled in partial linkage.
enum class StableEnum {
FOO {
val x = "OK"
inner class Inner {
val y = x
}
val z = Inner()
override val test: String
get() = z.y
},
BAR {
override val test = "OK"
};
abstract val test: String
}
@@ -207,4 +207,7 @@ fun box() = abiTest {
expectSuccess { getFunctionalInterfaceToInterface(); "OK" }
expectFailure(linkage("Constructor 'ClassToAbstractClass.<init>' can not be called: Can not instantiate abstract class 'ClassToAbstractClass'")) { instantiationOfAbstractClass() }
expectSuccess { StableEnum.FOO.test }
expectSuccess { StableEnum.BAR.test }
}