K2: fix NSME on toChar for subclasses of Number
Code in `ReplaceNumberToCharCallSitesLowering` relies on `Number.toChar` being declared in IR as non-abstract. Otherwise the `resolveFakeOverride` call there doesn't work, and the lowering can't rewrite the call to `toInt().toChar()`, and we end up with a call to the missing method `Number.toChar` in the bytecode. #KT-57217 Fixed
This commit is contained in:
committed by
Space Team
parent
175cf5e833
commit
13baf43ae3
@@ -77,9 +77,10 @@ class IrBuiltInsOverFir(
|
||||
|
||||
private val number by createClass(kotlinIrPackage, IdSignatureValues.number, build = { modality = Modality.ABSTRACT }) {
|
||||
configureSuperTypes()
|
||||
for (targetPrimitive in primitiveIrTypesWithComparisons) {
|
||||
for (targetPrimitive in primitiveNumericIrTypes) {
|
||||
createMemberFunction("to${targetPrimitive.classFqName!!.shortName().asString()}", targetPrimitive, modality = Modality.ABSTRACT)
|
||||
}
|
||||
createMemberFunction("toChar", charType, modality = Modality.OPEN)
|
||||
finalizeClassDefinition()
|
||||
}
|
||||
override val numberClass: IrClassSymbol get() = number.klass
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
// ISSUE: KT-23447
|
||||
// WITH_STDLIB
|
||||
|
||||
// IGNORE_BACKEND_K2: JVM_IR
|
||||
// Ignore reason: KT-57217
|
||||
|
||||
// FILE: MyNumber.java
|
||||
|
||||
public class MyNumber extends Number {
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Int modality:FINAL visibility:publ
|
||||
annotations:
|
||||
IntrinsicConstEvaluation
|
||||
overridden:
|
||||
public abstract fun toChar (): kotlin.Char declared in kotlin.Number
|
||||
public open fun toChar (): kotlin.Char declared in kotlin.Number
|
||||
$this: VALUE_PARAMETER name:$this type:kotlin.Int
|
||||
FUN BUILTIN_CLASS_METHOD name:toByte visibility:public modality:OPEN <> ($this:kotlin.Int) returnType:kotlin.Byte
|
||||
annotations:
|
||||
|
||||
Reference in New Issue
Block a user