Files
kotlin-fork/compiler/testData/codegen/box/ir/hashCodeOnGenericSubstitutedWithPrimitive.kt
T
Alexander Udalov 3a5d0ab427 JVM IR: fix HashCode intrinsic for generics substituted with primitives
The problem here was that although the IR type of the expression was
primitive, the type of the actual expression in the bytecode generated
after type erasure was `Ljava/lang/Object;`, and we were trying to call
a non-existing method `Object.hashCode(Object)`.

 #KT-41669 Fixed
2020-09-08 23:37:00 +02:00

12 lines
200 B
Kotlin
Vendored

// JVM_TARGET: 1.8
class A<T> {
fun id(x: T): T = x
}
fun foo(f: A<Boolean>): Int =
f.id(true).hashCode()
fun box(): String =
if (foo(A<Boolean>()) == true.hashCode()) "OK" else "Fail"