Don't use methods from super interface if call was on inline class type
Some methods (like `size` from kotlin.collections.Collection) have special rules for mapping and overriding. For example, when we call `size`, normally there will be `INVOKEVIRTUAL size()` in the bytecode, but for inline classes it should be `INVOKESTATIC ...$Erased.getSize()`
This commit is contained in:
@@ -881,7 +881,7 @@ public class KotlinTypeMapper {
|
||||
|
||||
FunctionDescriptor overriddenSpecialBuiltinFunction =
|
||||
SpecialBuiltinMembers.getOverriddenBuiltinReflectingJvmDescriptor(functionDescriptor.getOriginal());
|
||||
FunctionDescriptor functionToCall = overriddenSpecialBuiltinFunction != null && !superCall
|
||||
FunctionDescriptor functionToCall = overriddenSpecialBuiltinFunction != null && !superCall && !toInlinedErasedClass
|
||||
? overriddenSpecialBuiltinFunction.getOriginal()
|
||||
: functionDescriptor.getOriginal();
|
||||
|
||||
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class UInt(val x: Int)
|
||||
|
||||
inline class UIntArray(private val storage: IntArray) : Collection<UInt> {
|
||||
public override val size: Int get() = storage.size
|
||||
|
||||
override operator fun iterator() = TODO()
|
||||
override fun contains(element: UInt): Boolean = TODO()
|
||||
override fun containsAll(elements: Collection<UInt>): Boolean = TODO()
|
||||
override fun isEmpty(): Boolean = TODO()
|
||||
}
|
||||
|
||||
fun calculate(u: UIntArray): Int {
|
||||
return u.size
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (calculate(UIntArray(intArrayOf(1, 2, 3, 4))) != 4) return "Fail"
|
||||
return "OK"
|
||||
}
|
||||
Generated
+5
@@ -11174,6 +11174,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callComputablePropertyInsideInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callSpeciallyOverriddenPropertyOfInlineClass.kt")
|
||||
public void testCallSpeciallyOverriddenPropertyOfInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callSpeciallyOverriddenPropertyOfInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableReferencesWithInlineClasses.kt")
|
||||
public void testCallableReferencesWithInlineClasses() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClasses.kt");
|
||||
|
||||
+5
@@ -11174,6 +11174,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callComputablePropertyInsideInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callSpeciallyOverriddenPropertyOfInlineClass.kt")
|
||||
public void testCallSpeciallyOverriddenPropertyOfInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callSpeciallyOverriddenPropertyOfInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableReferencesWithInlineClasses.kt")
|
||||
public void testCallableReferencesWithInlineClasses() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClasses.kt");
|
||||
|
||||
+5
@@ -11174,6 +11174,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callComputablePropertyInsideInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callSpeciallyOverriddenPropertyOfInlineClass.kt")
|
||||
public void testCallSpeciallyOverriddenPropertyOfInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callSpeciallyOverriddenPropertyOfInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableReferencesWithInlineClasses.kt")
|
||||
public void testCallableReferencesWithInlineClasses() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClasses.kt");
|
||||
|
||||
+5
@@ -10839,6 +10839,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callComputablePropertyInsideInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callSpeciallyOverriddenPropertyOfInlineClass.kt")
|
||||
public void testCallSpeciallyOverriddenPropertyOfInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callSpeciallyOverriddenPropertyOfInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableReferencesWithInlineClasses.kt")
|
||||
public void testCallableReferencesWithInlineClasses() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClasses.kt");
|
||||
|
||||
+5
@@ -9717,6 +9717,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callComputablePropertyInsideInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callSpeciallyOverriddenPropertyOfInlineClass.kt")
|
||||
public void testCallSpeciallyOverriddenPropertyOfInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callSpeciallyOverriddenPropertyOfInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableReferencesWithInlineClasses.kt")
|
||||
public void testCallableReferencesWithInlineClasses() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClasses.kt");
|
||||
|
||||
Reference in New Issue
Block a user