Files
kotlin-fork/compiler/testData/codegen/box/valueClasses/javaInterop/methodWithValueClassInheritedInJavaOverriddenInKotlin.kt
T
vladislav.grechko 457837a255 Fix function invocation mangling rule
Mangle invocations of functions with value classes in signature which
override (directly or indirectly) a method declared in Kotlin code.
Otherwise, NoSuchMethodError is being thrown.

^KT-55945: Fixed
2023-06-15 09:34:21 +00:00

34 lines
634 B
Kotlin
Vendored

// WITH_STDLIB
// TARGET_BACKEND: JVM_IR
// LANGUAGE: +ValueClasses
// FILE: Point.kt
@JvmInline
value class Point(val x: Int, val y: Int)
// FILE: KotlinBase.kt
open class KotlinBase {
open fun foo(x : Point) = 42
}
// FILE: JavaChild.java
public class JavaChild extends KotlinBase {}
// FILE: KotlinChild.kt
class KotlinChild : JavaChild() {
override fun foo(x : Point) = 24
}
// FILE: box.kt
fun box(): String {
if (KotlinBase().foo(Point(0, 0)) != 42) return "Fail 1"
if (JavaChild().foo(Point(0, 0)) != 42) return "Fail 2"
if (KotlinChild().foo(Point(0, 0)) != 24) return "Fail 3"
return "OK"
}