mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-07 15:53:18 +00:00
Do not box primitives for 'primitive == object'
NB user-defined 'equals' can violate contract for 'Object#equals', e.g., it can be asymmetric. Thus we can't avoid boxing for 'object == primitive'.
This commit is contained in:
26
compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqBoxed.kt
vendored
Normal file
26
compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqBoxed.kt
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
fun testBoolean1(a: Boolean, b: Boolean?) = a == b
|
||||
fun testBoolean2(a: Boolean, b: Boolean?) = a != b
|
||||
|
||||
fun testChar1(a: Char, b: Char?) = a == b
|
||||
fun testChar2(a: Char, b: Char?) = a != b
|
||||
|
||||
fun testByte1(a: Byte, b: Byte?) = a == b
|
||||
fun testByte2(a: Byte, b: Byte?) = a != b
|
||||
|
||||
fun testShort1(a: Short, b: Short?) = a == b
|
||||
fun testShort2(a: Short, b: Short?) = a != b
|
||||
|
||||
fun testInt1(a: Int, b: Int?) = a == b
|
||||
fun testInt2(a: Int, b: Int?) = a != b
|
||||
|
||||
fun testLong1(a: Long, b: Long?) = a == b
|
||||
fun testLong2(a: Long, b: Long?) = a != b
|
||||
|
||||
// 2 booleanValue
|
||||
// 2 charValue
|
||||
// 2 byteValue
|
||||
// 2 shortValue
|
||||
// 2 intValue
|
||||
// 2 longValue
|
||||
// 0 valueOf
|
||||
// 0 areEqual
|
||||
26
compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqObject.kt
vendored
Normal file
26
compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqObject.kt
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
fun testBoolean1(a: Boolean, b: Any?) = a == b
|
||||
fun testBoolean2(a: Boolean, b: Any?) = a != b
|
||||
|
||||
fun testChar1(a: Char, b: Any?) = a == b
|
||||
fun testChar2(a: Char, b: Any?) = a != b
|
||||
|
||||
fun testByte1(a: Byte, b: Any?) = a == b
|
||||
fun testByte2(a: Byte, b: Any?) = a != b
|
||||
|
||||
fun testShort1(a: Short, b: Any?) = a == b
|
||||
fun testShort2(a: Short, b: Any?) = a != b
|
||||
|
||||
fun testInt1(a: Int, b: Any?) = a == b
|
||||
fun testInt2(a: Int, b: Any?) = a != b
|
||||
|
||||
fun testLong1(a: Long, b: Any?) = a == b
|
||||
fun testLong2(a: Long, b: Any?) = a != b
|
||||
|
||||
// 2 booleanValue
|
||||
// 2 charValue
|
||||
// 2 byteValue
|
||||
// 2 shortValue
|
||||
// 2 intValue
|
||||
// 2 longValue
|
||||
// 0 valueOf
|
||||
// 0 areEqual
|
||||
Reference in New Issue
Block a user