[FIR] skip implicit call to enum constructor if super type call exists

otherwise, reference to the super type would be resolved even when it's not
e.g. for interface constructor
^ KTIJ-24437
This commit is contained in:
Anna Kozlova
2023-01-25 23:01:30 +01:00
committed by teamcity
parent 07d369998c
commit e5b96561e0
12 changed files with 52 additions and 5 deletions
@@ -7,9 +7,9 @@ FILE: classInSupertypeForEnum.kt
}
public abstract interface C : R|kotlin/Any| {
}
public final enum class B : R|C|, R|A|, R|kotlin/Any|, R|kotlin/Enum<B>| {
public final enum class B : R|C|, R|A|, R|kotlin/Any| {
private constructor(): R|B| {
super<R|kotlin/Enum<B>|>()
super<R|kotlin/Any|>()
}
public final static fun values(): R|kotlin/Array<B>| {
@@ -538,7 +538,7 @@ class DeclarationsConverter(
delegationSpecifiers?.let { superTypeRefs += it.superTypesRef }
when {
modifiers.isEnum() && (classKind == ClassKind.ENUM_CLASS) -> {
modifiers.isEnum() && (classKind == ClassKind.ENUM_CLASS) && delegatedConstructorSource == null -> {
delegatedSuperTypeRef = buildResolvedTypeRef {
type = ConeClassLikeTypeImpl(
implicitEnumType.type.lookupTag,
@@ -881,7 +881,7 @@ open class RawFirBuilder(
}
when {
this is KtClass && classKind == ClassKind.ENUM_CLASS -> {
this is KtClass && classKind == ClassKind.ENUM_CLASS && superTypeCallEntry == null -> {
/*
* kotlin.Enum constructor has (name: String, ordinal: Int) signature,
* so we should generate non-trivial constructors for enum and it's entry