[IR] Implement IR actualizer and use it for K2 test and CLI scenario
Implement calculateExpectActualMap for Fir2IrComponents ^KT-51753 Fixed
This commit is contained in:
committed by
Space Team
parent
15ad9d134c
commit
8936220876
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: common.kt
|
||||
|
||||
val LocalClass = object {
|
||||
override fun toString() = "OK"
|
||||
}
|
||||
|
||||
fun ok() = LocalClass.toString()
|
||||
|
||||
// MODULE: jvm()()(common)
|
||||
// TARGET_PLATFORM: JVM
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = ok()
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package foo
|
||||
|
||||
fun transform(x: String, f: (String) -> String): String {
|
||||
return f(x) + "K"
|
||||
}
|
||||
|
||||
// MODULE: lib2()()(lib)
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// FILE: main.kt
|
||||
|
||||
package bar
|
||||
|
||||
import foo.*
|
||||
|
||||
fun box() = transform("") { "O" }
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: commonMain.kt
|
||||
|
||||
expect class R
|
||||
|
||||
expect fun ret(): R
|
||||
|
||||
fun foo() = ::ret
|
||||
|
||||
// MODULE: main()()(common)
|
||||
// TARGET_PLATFORM: JVM
|
||||
// FILE: main.kt
|
||||
|
||||
actual fun ret(): R = "OK"
|
||||
|
||||
actual typealias R = String
|
||||
|
||||
fun box() = foo().invoke()
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
|
||||
// FILE: p1.kt
|
||||
|
||||
package p1
|
||||
|
||||
expect fun f(): String
|
||||
|
||||
expect class A() {
|
||||
fun g(): Boolean
|
||||
}
|
||||
|
||||
fun test() = A().g()
|
||||
|
||||
// FILE: p2.kt
|
||||
|
||||
package p2
|
||||
|
||||
expect fun f(): String
|
||||
|
||||
expect class A() {
|
||||
fun g(): Int
|
||||
}
|
||||
|
||||
// MODULE: main()()(common)
|
||||
// TARGET_PLATFORM: JVM
|
||||
|
||||
// FILE: p11.kt
|
||||
|
||||
package p1
|
||||
|
||||
actual fun f() = "O"
|
||||
|
||||
actual class A {
|
||||
actual fun g() = true
|
||||
}
|
||||
|
||||
// FILE: p22.kt
|
||||
|
||||
package p2
|
||||
|
||||
actual fun f() = "K"
|
||||
|
||||
actual class A {
|
||||
actual fun g() = 42
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = if (p1.A().g()) p1.f() + p2.f() else "fail"
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: commonMain.kt
|
||||
|
||||
expect class A() {
|
||||
fun foo(s: String): String
|
||||
|
||||
val bar: String
|
||||
}
|
||||
|
||||
fun test(s: String): String {
|
||||
val a = A()
|
||||
return a.foo(s) + a.bar
|
||||
}
|
||||
|
||||
// MODULE: main()()(common)
|
||||
// TARGET_PLATFORM: JVM
|
||||
// FILE: main.kt
|
||||
|
||||
open class B {
|
||||
fun foo(s: String) = s
|
||||
|
||||
val bar: String = "K"
|
||||
}
|
||||
|
||||
actual class A : B()
|
||||
|
||||
fun box() = test("O")
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
// MODULE: common0
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: common0.kt
|
||||
|
||||
expect fun f0(): Boolean
|
||||
|
||||
fun g0() = f0()
|
||||
|
||||
// MODULE: common1()()(common0)
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: common1.kt
|
||||
|
||||
expect fun f1(): String
|
||||
|
||||
fun g1() = f1()
|
||||
|
||||
// MODULE: common2()()(common0)
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: common2.kt
|
||||
|
||||
expect fun f2(): String
|
||||
|
||||
fun g2() = f2()
|
||||
|
||||
// MODULE: jvm()()(common1, common2)
|
||||
// TARGET_PLATFORM: JVM
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual fun f0(): Boolean = true
|
||||
actual fun f1(): String = "O"
|
||||
actual fun f2(): String = "K"
|
||||
|
||||
fun box() = if (g0()) g1() + g2() else "fail"
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: commonMain.kt
|
||||
|
||||
expect class S
|
||||
|
||||
expect fun foo(s: S): S
|
||||
|
||||
expect fun foo(i: Int): Int
|
||||
|
||||
fun test(s: S) = foo(s)
|
||||
|
||||
// MODULE: main()()(common)
|
||||
// TARGET_PLATFORM: JVM
|
||||
// FILE: main.kt
|
||||
|
||||
actual fun foo(i: Int) = i
|
||||
|
||||
actual fun foo(s: String) = s
|
||||
|
||||
actual typealias S = String
|
||||
|
||||
fun box() = test("OK")
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: common.kt
|
||||
|
||||
expect fun func(): String
|
||||
|
||||
expect var prop: String
|
||||
|
||||
fun test(): String {
|
||||
prop = "K"
|
||||
return func() + prop
|
||||
}
|
||||
|
||||
// MODULE: jvm()()(common)
|
||||
// TARGET_PLATFORM: JVM
|
||||
// FILE: main.kt
|
||||
|
||||
actual fun func(): String = "O"
|
||||
|
||||
actual var prop: String = "!"
|
||||
|
||||
fun box() = test()
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: common.kt
|
||||
|
||||
expect class S {
|
||||
val length: Int
|
||||
}
|
||||
|
||||
expect fun foo(): S
|
||||
|
||||
fun test(): S = foo()
|
||||
|
||||
// MODULE: jvm()()(common)
|
||||
// TARGET_PLATFORM: JVM
|
||||
// FILE: main.kt
|
||||
|
||||
actual typealias S = String
|
||||
|
||||
actual fun foo(): S = "OK"
|
||||
|
||||
fun box() = test()
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: common.kt
|
||||
|
||||
expect interface S1
|
||||
expect interface S2
|
||||
|
||||
expect class S
|
||||
|
||||
open class A : S1, S2
|
||||
|
||||
class B : A()
|
||||
|
||||
// MODULE: jvm()()(common)
|
||||
// TARGET_PLATFORM: JVM
|
||||
// FILE: main.kt
|
||||
|
||||
actual interface S1 {
|
||||
fun o(): S = "O"
|
||||
val p: Boolean
|
||||
get() = true
|
||||
}
|
||||
|
||||
actual interface S2 {
|
||||
fun k() = "K"
|
||||
}
|
||||
|
||||
actual typealias S = String
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
return if (b.p) {
|
||||
b.o() + b.k()
|
||||
} else {
|
||||
"FAIL"
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: common.kt
|
||||
|
||||
interface Foo {
|
||||
fun ok(): String = "OK"
|
||||
}
|
||||
|
||||
fun test(e: Foo) = e.ok()
|
||||
|
||||
// MODULE: jvm()()(common)
|
||||
// TARGET_PLATFORM: JVM
|
||||
// FILE: main.kt
|
||||
|
||||
interface Bar : Foo
|
||||
|
||||
class A : Bar
|
||||
|
||||
fun box() = A().ok()
|
||||
compiler/testData/codegen/box/multiplatform/multiModule/getRidOfDoubleBindingInFir2IrLazyProperty.kt
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// WITH_REFLECT
|
||||
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: common.kt
|
||||
|
||||
interface I {
|
||||
companion object {
|
||||
const val OK: String = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun ok() = I.OK
|
||||
|
||||
// MODULE: jvm()()(common)
|
||||
// TARGET_PLATFORM: JVM
|
||||
// FILE: main.kt
|
||||
|
||||
import kotlin.reflect.KType
|
||||
|
||||
fun getAnnotations(kType: KType) = kType.annotations
|
||||
|
||||
fun box() = ok()
|
||||
@@ -0,0 +1,56 @@
|
||||
// ISSUE: KT-51753
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WITH_STDLIB
|
||||
// WITH_REFLECT
|
||||
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: common/AtomicBoolean.kt
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
expect class AtomicBoolean {
|
||||
var value: Boolean
|
||||
|
||||
inline operator fun getValue(thisRef: Any?, property: KProperty<*>): Boolean
|
||||
|
||||
inline operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean)
|
||||
}
|
||||
|
||||
expect fun atomic(initial: Boolean): AtomicBoolean
|
||||
|
||||
// FILE: common/test.kt
|
||||
|
||||
private val _topLevelBoolean = atomic(false)
|
||||
var topLevelDelegatedPropertyBoolean: Boolean by _topLevelBoolean
|
||||
|
||||
// MODULE: main()()(common)
|
||||
// TARGET_PLATFORM: JVM
|
||||
// FILE: jvm/AtomicBoolean.kt
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
actual class AtomicBoolean internal constructor(v: Boolean) {
|
||||
|
||||
@Volatile
|
||||
private var _value: Int = if (v) 1 else 0
|
||||
|
||||
actual inline operator fun getValue(thisRef: Any?, property: KProperty<*>): Boolean = value
|
||||
|
||||
actual inline operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) {
|
||||
this.value = value
|
||||
}
|
||||
|
||||
actual var value: Boolean
|
||||
get() = _value != 0
|
||||
set(value) {
|
||||
_value = if (value) 1 else 0
|
||||
}
|
||||
}
|
||||
|
||||
actual fun atomic(initial: Boolean): AtomicBoolean = AtomicBoolean(initial)
|
||||
|
||||
// FILE: jvm/box.kt
|
||||
|
||||
fun box(): String = if (!topLevelDelegatedPropertyBoolean) "OK" else "FAIL (true)"
|
||||
@@ -0,0 +1,52 @@
|
||||
// ISSUE: KT-51753
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WITH_STDLIB
|
||||
// WITH_REFLECT
|
||||
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: common/AtomicBoolean.kt
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
expect class AtomicRef<T> {
|
||||
var value: T
|
||||
|
||||
inline operator fun getValue(thisRef: Any?, property: KProperty<*>): T
|
||||
|
||||
inline operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T)
|
||||
}
|
||||
|
||||
expect fun <T> atomic(initial: T): AtomicRef<T>
|
||||
|
||||
// FILE: common/test.kt
|
||||
|
||||
private val _topLevelRef = atomic("A")
|
||||
var topLevelDelegatedPropertyRef: String by _topLevelRef
|
||||
|
||||
// MODULE: main()()(common)
|
||||
// TARGET_PLATFORM: JVM
|
||||
// FILE: jvm/AtomicBoolean.kt
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
actual class AtomicRef<T> internal constructor(v: T) {
|
||||
|
||||
actual inline operator fun getValue(thisRef: Any?, property: KProperty<*>): T = value
|
||||
|
||||
actual inline operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
|
||||
this.value = value
|
||||
}
|
||||
|
||||
actual var value: T = v
|
||||
}
|
||||
|
||||
actual fun <T> atomic(initial: T): AtomicRef<T> = AtomicRef(initial)
|
||||
|
||||
// FILE: jvm/box.kt
|
||||
|
||||
fun box(): String {
|
||||
val s = topLevelDelegatedPropertyRef
|
||||
return if (s == "A") "OK" else "FAIL($s)"
|
||||
}
|
||||
-3
@@ -3,9 +3,6 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// IGNORE_BACKEND_K2: JVM_IR
|
||||
// K2 status: caused by: java.lang.IllegalStateException: Should not be here!
|
||||
// It will be fixed after merging of MPP branch
|
||||
|
||||
// MODULE: lib-common
|
||||
// FILE: common.kt
|
||||
|
||||
Reference in New Issue
Block a user