JVM IR: prevent behavior change with operator dot calls on literals
#KT-42321 Fixed
This commit is contained in:
+67
@@ -0,0 +1,67 @@
|
||||
// This test exists only to check that we don't accidentally break the buggy behavior of the old JVM backend in JVM IR (KT-42321).
|
||||
// Feel free to remove it as soon as there's no language version where such code is allowed (KT-38895).
|
||||
|
||||
abstract class C<L> {
|
||||
abstract fun takeT(x: L)
|
||||
}
|
||||
|
||||
fun testLongDotCall(c1: C<Long>) {
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.plus(2))
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.minus(2))
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.times(2))
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.div(2))
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.rem(2))
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.inc())
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.dec())
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.unaryPlus())
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.unaryMinus())
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.shl(2))
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.shr(2))
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.ushr(2))
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.and(2))
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.or(2))
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.xor(2))
|
||||
c1.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.inv())
|
||||
}
|
||||
|
||||
fun testShortDotCall(c2: C<Short>) {
|
||||
c2.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.plus(2))
|
||||
c2.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.inc())
|
||||
c2.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.dec())
|
||||
c2.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.shr(2))
|
||||
c2.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.inv())
|
||||
}
|
||||
|
||||
fun testByteDotCall(c3: C<Byte>) {
|
||||
c3.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.plus(2))
|
||||
c3.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.inc())
|
||||
c3.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.dec())
|
||||
c3.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.shr(2))
|
||||
c3.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1.inv())
|
||||
}
|
||||
|
||||
fun testLongOperatorInfixCall(c4: C<Long>) {
|
||||
c4.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 + 2)
|
||||
c4.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 - 2)
|
||||
c4.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 * 2)
|
||||
c4.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 / 2)
|
||||
c4.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 % 2)
|
||||
c4.takeT(+1)
|
||||
c4.takeT(-1)
|
||||
c4.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 shl 2)
|
||||
c4.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 shr 2)
|
||||
c4.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 ushr 2)
|
||||
c4.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 and 2)
|
||||
c4.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 or 2)
|
||||
c4.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 xor 2)
|
||||
}
|
||||
|
||||
fun testShortOperatorInfixCall(c5: C<Short>) {
|
||||
c5.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 + 2)
|
||||
c5.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 shr 2)
|
||||
}
|
||||
|
||||
fun testByteOperatorInfixCall(c6: C<Byte>) {
|
||||
c6.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 + 2)
|
||||
c6.<!INAPPLICABLE_CANDIDATE!>takeT<!>(1 shr 2)
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
// This test exists only to check that we don't accidentally break the buggy behavior of the old JVM backend in JVM IR (KT-42321).
|
||||
// Feel free to remove it as soon as there's no language version where such code is allowed (KT-38895).
|
||||
|
||||
abstract class C<L> {
|
||||
abstract fun takeT(x: L)
|
||||
}
|
||||
|
||||
fun testLongDotCall(c1: C<Long>) {
|
||||
c1.takeT(1.plus(2))
|
||||
c1.takeT(1.minus(2))
|
||||
c1.takeT(1.times(2))
|
||||
c1.takeT(1.div(2))
|
||||
c1.takeT(1.rem(2))
|
||||
c1.takeT(<!TYPE_MISMATCH!>1.inc()<!>)
|
||||
c1.takeT(<!TYPE_MISMATCH!>1.dec()<!>)
|
||||
c1.takeT(1.unaryPlus())
|
||||
c1.takeT(1.unaryMinus())
|
||||
c1.takeT(1.shl(2))
|
||||
c1.takeT(1.shr(2))
|
||||
c1.takeT(1.ushr(2))
|
||||
c1.takeT(1.and(2))
|
||||
c1.takeT(1.or(2))
|
||||
c1.takeT(1.xor(2))
|
||||
c1.takeT(1.inv())
|
||||
}
|
||||
|
||||
fun testShortDotCall(c2: C<Short>) {
|
||||
c2.takeT(1.plus(2))
|
||||
c2.takeT(<!TYPE_MISMATCH!>1.inc()<!>)
|
||||
c2.takeT(<!TYPE_MISMATCH!>1.dec()<!>)
|
||||
c2.takeT(1.shr(2))
|
||||
c2.takeT(1.inv())
|
||||
}
|
||||
|
||||
fun testByteDotCall(c3: C<Byte>) {
|
||||
c3.takeT(1.plus(2))
|
||||
c3.takeT(<!TYPE_MISMATCH!>1.inc()<!>)
|
||||
c3.takeT(<!TYPE_MISMATCH!>1.dec()<!>)
|
||||
c3.takeT(1.shr(2))
|
||||
c3.takeT(1.inv())
|
||||
}
|
||||
|
||||
fun testLongOperatorInfixCall(c4: C<Long>) {
|
||||
c4.takeT(1 + 2)
|
||||
c4.takeT(1 - 2)
|
||||
c4.takeT(1 * 2)
|
||||
c4.takeT(1 / 2)
|
||||
c4.takeT(1 % 2)
|
||||
c4.takeT(+1)
|
||||
c4.takeT(-1)
|
||||
c4.takeT(1 shl 2)
|
||||
c4.takeT(1 shr 2)
|
||||
c4.takeT(1 ushr 2)
|
||||
c4.takeT(1 and 2)
|
||||
c4.takeT(1 or 2)
|
||||
c4.takeT(1 xor 2)
|
||||
}
|
||||
|
||||
fun testShortOperatorInfixCall(c5: C<Short>) {
|
||||
c5.takeT(1 + 2)
|
||||
c5.takeT(1 shr 2)
|
||||
}
|
||||
|
||||
fun testByteOperatorInfixCall(c6: C<Byte>) {
|
||||
c6.takeT(1 + 2)
|
||||
c6.takeT(1 shr 2)
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package
|
||||
|
||||
public fun testByteDotCall(/*0*/ c3: C<kotlin.Byte>): kotlin.Unit
|
||||
public fun testByteOperatorInfixCall(/*0*/ c6: C<kotlin.Byte>): kotlin.Unit
|
||||
public fun testLongDotCall(/*0*/ c1: C<kotlin.Long>): kotlin.Unit
|
||||
public fun testLongOperatorInfixCall(/*0*/ c4: C<kotlin.Long>): kotlin.Unit
|
||||
public fun testShortDotCall(/*0*/ c2: C<kotlin.Short>): kotlin.Unit
|
||||
public fun testShortOperatorInfixCall(/*0*/ c5: C<kotlin.Short>): kotlin.Unit
|
||||
|
||||
public abstract class C</*0*/ L> {
|
||||
public constructor C</*0*/ L>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun takeT(/*0*/ x: L): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user