Fix condition of generating equals-impl0 call
This methods should not be called when instances of different inline classes are being compared ^KT-57242: Fixed
This commit is contained in:
committed by
teamcity
parent
948714e7e5
commit
8039e30bbd
+6
@@ -22613,6 +22613,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/kt54656.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/kt54656.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt57242.kt")
|
||||||
|
public void testKt57242() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/kt57242.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lateinitInlineClasses.kt")
|
@TestMetadata("lateinitInlineClasses.kt")
|
||||||
public void testLateinitInlineClasses() throws Exception {
|
public void testLateinitInlineClasses() throws Exception {
|
||||||
|
|||||||
+6
@@ -22613,6 +22613,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/kt54656.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/kt54656.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt57242.kt")
|
||||||
|
public void testKt57242() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/kt57242.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lateinitInlineClasses.kt")
|
@TestMetadata("lateinitInlineClasses.kt")
|
||||||
public void testLateinitInlineClasses() throws Exception {
|
public void testLateinitInlineClasses() throws Exception {
|
||||||
|
|||||||
+4
-4
@@ -283,11 +283,11 @@ internal class JvmInlineClassLowering(
|
|||||||
if (left.type.isUnsigned() && right.type.isUnsigned() && rightIsUnboxed)
|
if (left.type.isUnsigned() && right.type.isUnsigned() && rightIsUnboxed)
|
||||||
return irEquals(left.coerceToUnboxed(), right.coerceToUnboxed())
|
return irEquals(left.coerceToUnboxed(), right.coerceToUnboxed())
|
||||||
|
|
||||||
val klass = left.type.classOrNull!!.owner
|
val leftOperandClass = left.type.classOrNull!!.owner
|
||||||
val equalsMethod = if (rightIsUnboxed) {
|
val equalsMethod = if (rightIsUnboxed && leftOperandClass == right.type.classOrNull!!.owner) {
|
||||||
this@JvmInlineClassLowering.context.inlineClassReplacements.getSpecializedEqualsMethod(klass, context.irBuiltIns)
|
this@JvmInlineClassLowering.context.inlineClassReplacements.getSpecializedEqualsMethod(leftOperandClass, context.irBuiltIns)
|
||||||
} else {
|
} else {
|
||||||
val equals = klass.functions.single { it.name.asString() == "equals" && it.overriddenSymbols.isNotEmpty() }
|
val equals = leftOperandClass.functions.single { it.name.asString() == "equals" && it.overriddenSymbols.isNotEmpty() }
|
||||||
this@JvmInlineClassLowering.context.inlineClassReplacements.getReplacementFunction(equals)!!
|
this@JvmInlineClassLowering.context.inlineClassReplacements.getReplacementFunction(equals)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// WITH_STDLIB
|
||||||
|
// FULL_JDK
|
||||||
|
// WORKS_WHEN_VALUE_CLASS
|
||||||
|
// LANGUAGE: +ValueClasses
|
||||||
|
|
||||||
|
import java.util.UUID
|
||||||
|
import java.util.UUID.randomUUID
|
||||||
|
|
||||||
|
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||||
|
value class IdOne(val id: UUID)
|
||||||
|
|
||||||
|
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||||
|
value class IdTwo(val id: UUID)
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val sameUUID = randomUUID()
|
||||||
|
val one = IdOne(sameUUID)
|
||||||
|
val two = IdTwo(sameUUID)
|
||||||
|
|
||||||
|
if (one.equals(two)) return "Fail"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+6
@@ -22613,6 +22613,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/kt54656.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/kt54656.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt57242.kt")
|
||||||
|
public void testKt57242() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/kt57242.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lateinitInlineClasses.kt")
|
@TestMetadata("lateinitInlineClasses.kt")
|
||||||
public void testLateinitInlineClasses() throws Exception {
|
public void testLateinitInlineClasses() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user