Enum.valueOf throws inconsistent exception across multiple platforms #KT-35116

This commit is contained in:
Abduqodiri Qurbonzoda
2023-06-11 03:14:37 +03:00
committed by Space Team
parent d6867917c9
commit 295fdc36ce
10 changed files with 34 additions and 11 deletions
@@ -219,6 +219,9 @@ class JsIrBackendContext(
override val throwISE: IrSimpleFunctionSymbol =
symbolTable.referenceSimpleFunction(getFunctions(kotlinPackageFqn.child(Name.identifier("THROW_ISE"))).single())
override val throwIAE: IrSimpleFunctionSymbol =
symbolTable.referenceSimpleFunction(getFunctions(kotlinPackageFqn.child(Name.identifier("THROW_IAE"))).single())
override val stringBuilder
get() = TODO("not implemented")
override val coroutineImpl =
@@ -325,9 +328,6 @@ class JsIrBackendContext(
val setPropertiesToThrowableInstanceSymbol =
symbolTable.referenceSimpleFunction(getJsInternalFunction("setPropertiesToThrowableInstance"))
val throwISEsymbol = symbolTable.referenceSimpleFunction(getFunctions(kotlinPackageFqn.child(Name.identifier("THROW_ISE"))).single())
val throwIAEsymbol = symbolTable.referenceSimpleFunction(getFunctions(kotlinPackageFqn.child(Name.identifier("THROW_IAE"))).single())
override val suiteFun = getFunctions(FqName("kotlin.test.suite")).singleOrNull()?.let { symbolTable.referenceSimpleFunction(it) }
override val testFun = getFunctions(FqName("kotlin.test.test")).singleOrNull()?.let { symbolTable.referenceSimpleFunction(it) }
@@ -501,7 +501,7 @@ class EnumSyntheticFunctionsAndPropertiesLowering(
return null
}
private val throwISESymbol = context.ir.symbols.throwISE
private val throwIAESymbol = context.ir.symbols.throwIAE
private fun createEnumEntriesBody(entriesGetter: IrFunction, enumClass: IrClass): IrBlockBody {
val entriesField = enumClass.buildEntriesField()
@@ -548,7 +548,9 @@ class EnumSyntheticFunctionsAndPropertiesLowering(
)
} memoryOptimizedPlus irElseBranch(irBlock {
+irCall(irClass.initEntryInstancesFun!!)
+irCall(throwISESymbol)
+irCall(throwIAESymbol).apply {
putValueArgument(0, irString("No enum constant ${nameParameter.name.identifier}."))
}
})
)
}
@@ -32,7 +32,7 @@ class PropertyReferenceLowering(private val context: JsIrBackendContext) : BodyL
private val localDelegateBuilderSymbol = context.klocalDelegateBuilder
private val jsClassSymbol = context.intrinsics.jsClass
private val throwISE = context.throwISEsymbol
private val throwISE = context.ir.symbols.throwISE
override fun lower(irBody: IrBody, container: IrDeclaration) {
val currentParent = container as? IrDeclarationParent ?: container.parent