[FIR2IR] Use cached IrEnumEntry when available in Fir2IrConverter

Calling createIrEnumEntry lead to "IllegalStateException:
Fir2IrEnumEntrySymbol for [declaration] is already bound" when the
IrEnumEntry was already created previously, e.g. by an annotation call
referencing it.

^KT-54079 Fixed
This commit is contained in:
Kirill Rakhman
2023-01-31 11:41:14 +01:00
committed by Space Team
parent feb6fd0e0d
commit f7f50ca842
3 changed files with 58 additions and 1 deletions
@@ -403,7 +403,7 @@ class Fir2IrConverter(
null
}
is FirEnumEntry -> {
classifierStorage.createIrEnumEntry(declaration, parent as IrClass)
classifierStorage.getIrEnumEntry(declaration, parent as IrClass)
}
is FirAnonymousInitializer -> {
declarationStorage.createIrAnonymousInitializer(declaration, parent as IrClass)
@@ -0,0 +1,41 @@
open class Arguments {
@GradleOption(
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
gradleInputType = GradleInputTypes.INPUT,
)
val useK2: Boolean by lazy { false }
}
class JvmArguments : Arguments() {
@GradleOption(
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
gradleInputType = GradleInputTypes.INPUT,
)
val specific: Boolean by lazy { true }
}
@Retention(AnnotationRetention.RUNTIME)
annotation class GradleOption(
val value: DefaultValue,
val gradleInputType: GradleInputTypes
)
enum class GradleInputTypes(
val typeAsString: String
) {
INPUT("org.gradle.api.tasks.Input"),
INTERNAL("org.gradle.api.tasks.Internal");
override fun toString(): String {
return typeAsString
}
}
enum class DefaultValue {
BOOLEAN_FALSE_DEFAULT,
BOOLEAN_TRUE_DEFAULT,
}
fun box(): String {
return "OK"
}
@@ -129,6 +129,22 @@ public class FirSpecificBlackBoxCodegenTestGenerated extends AbstractFirBlackBox
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/fir2ir/testData/codegen/boxWithStdLib"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Nested
@TestMetadata("compiler/fir/fir2ir/testData/codegen/boxWithStdLib/enum")
@TestDataPath("$PROJECT_ROOT")
public class Enum {
@Test
public void testAllFilesPresentInEnum() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/fir2ir/testData/codegen/boxWithStdLib/enum"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("k54079.kt")
public void testK54079() throws Exception {
runTest("compiler/fir/fir2ir/testData/codegen/boxWithStdLib/enum/k54079.kt");
}
}
@Nested
@TestMetadata("compiler/fir/fir2ir/testData/codegen/boxWithStdLib/properties")
@TestDataPath("$PROJECT_ROOT")