[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:
+6
@@ -370,6 +370,12 @@ public class Fe10IdeNormalAnalysisSourceModuleResolveCallTestGenerated extends A
|
||||
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/enumAsAnnotationValue.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumSuperTypeInterface.kt")
|
||||
public void testEnumSuperTypeInterface() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/enumSuperTypeInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("eqEqCall_fromAny.kt")
|
||||
public void testEqEqCall_fromAny() throws Exception {
|
||||
|
||||
+6
@@ -370,6 +370,12 @@ public class FirIdeNormalAnalysisSourceModuleResolveCallTestGenerated extends Ab
|
||||
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/enumAsAnnotationValue.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumSuperTypeInterface.kt")
|
||||
public void testEnumSuperTypeInterface() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/enumSuperTypeInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("eqEqCall_fromAny.kt")
|
||||
public void testEqEqCall_fromAny() throws Exception {
|
||||
|
||||
+6
@@ -370,6 +370,12 @@ public class FirStandaloneNormalAnalysisSourceModuleResolveCallTestGenerated ext
|
||||
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/enumAsAnnotationValue.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumSuperTypeInterface.kt")
|
||||
public void testEnumSuperTypeInterface() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/enumSuperTypeInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("eqEqCall_fromAny.kt")
|
||||
public void testEqEqCall_fromAny() throws Exception {
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
KtErrorCallInfo:
|
||||
candidateCalls = []
|
||||
diagnostic = ERROR<NO_CONSTRUCTOR: This class does not have a constructor>
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
enum class E : <expr>I()</expr>, I1{}
|
||||
|
||||
interface I {}
|
||||
interface I1 {}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
KtErrorCallInfo:
|
||||
candidateCalls = []
|
||||
diagnostic = ERROR<UNRESOLVED_REFERENCE: Unresolved reference: <init>>
|
||||
+2
-2
@@ -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>| {
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
// FILE: test.kt
|
||||
enum class MyEnum(): <!CLASS_IN_SUPERTYPE_FOR_ENUM!>MyClass<!>() {}
|
||||
enum class MyEnum2(): MyTrait {}
|
||||
enum class MyEnum3(): <!CLASS_IN_SUPERTYPE_FOR_ENUM, FINAL_SUPERTYPE!>MyEnumBase<!>() {}
|
||||
enum class MyEnum2_1(): <!UNRESOLVED_REFERENCE!>MyTrait<!>() {}
|
||||
enum class MyEnum3(): <!CLASS_IN_SUPERTYPE_FOR_ENUM, FINAL_SUPERTYPE, INVISIBLE_REFERENCE!>MyEnumBase<!>() {}
|
||||
|
||||
open class MyClass() {}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// FILE: test.kt
|
||||
enum class MyEnum(): <!CLASS_IN_SUPERTYPE_FOR_ENUM!>MyClass<!>() {}
|
||||
enum class MyEnum2(): MyTrait {}
|
||||
enum class MyEnum2_1(): MyTrait<!NO_CONSTRUCTOR!>()<!> {}
|
||||
enum class MyEnum3(): <!CLASS_IN_SUPERTYPE_FOR_ENUM, FINAL_SUPERTYPE, INVISIBLE_MEMBER!>MyEnumBase<!>() {}
|
||||
|
||||
open class MyClass() {}
|
||||
|
||||
@@ -35,6 +35,23 @@ public final enum class MyEnum2 : kotlin.Enum<MyEnum2>, MyTrait {
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<MyEnum2>
|
||||
}
|
||||
|
||||
public final enum class MyEnum2_1 : kotlin.Enum<MyEnum2_1>, MyTrait {
|
||||
private constructor MyEnum2_1()
|
||||
@kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum2_1): kotlin.Int
|
||||
public final override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<MyEnum2_1!>!
|
||||
public final override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): MyEnum2_1
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<MyEnum2_1>
|
||||
}
|
||||
|
||||
public final enum class MyEnum3 : MyEnumBase {
|
||||
private constructor MyEnum3()
|
||||
@kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
|
||||
Reference in New Issue
Block a user