[WASM] Add receiver capturing to callable references

This commit is contained in:
Igor Yakovlev
2021-09-17 11:57:38 +02:00
committed by teamcityserver
parent b8d11f7938
commit 41a69ad388
42 changed files with 204 additions and 110 deletions
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
import Host.foo
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
inline fun foo(x: () -> Unit): String {
x()
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType
class Outer(val o: String) {
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
var result = ""
class C(val token: String) {
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: WASM
fun use(fn: (Array<String>) -> Array<String>) =
fn(arrayOf("OK"))
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
class C {
fun ffff(i: Int, s: String = "OK") = s
}
@@ -1,6 +1,5 @@
// WITH_RUNTIME
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
class C(val x: String) {
fun foo(i: Int): Char = x[i]
}
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
fun box(): String {
return if ((arrayOf(1, 2, 3)::get)(1) == 2) "OK" else "Fail"
}
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// !LANGUAGE: +NewInference
interface JsonParser
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// KJS_WITH_FULL_RUNTIME
// !LANGUAGE: +NewInference
// WITH_RUNTIME
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
class A {
companion object {
fun ok() = "OK"
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
fun box(): String {
var state = 0
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// WASM_MUTE_REASON: PROPERTY_REFERENCES
var result = ""
class A {
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// WASM_MUTE_REASON: FUNCTION_REFERENCES
// IGNORE_BACKEND: JS, JS_IR
// IGNORE_BACKEND: JS_IR_ES6
enum class E {
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// WASM_MUTE_REASON: PROPERTY_REFERENCES
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// TODO: investigate should it be ran for JS or not
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// WASM_MUTE_REASON: FUNCTION_REFERENCES
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// TODO: investigate should it be ran for JS or not
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// WASM_MUTE_REASON: PROPERTY_REFERENCES
// KT-30629
abstract class BaseFragment<T : BaseViewModel> {
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// WASM_MUTE_REASON: PROPERTY_REFERENCES
class Generic<P : Any>(val p: P)
class Host {
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// WASM_MUTE_REASON: PROPERTY_REFERENCES
// SKIP_SOURCEMAP_REMAPPING
fun box(): String {
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
fun <T> get(t: T): () -> String {
return t::toString
}
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// KJS_WITH_FULL_RUNTIME
//WITH_RUNTIME
fun box(): String {
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// WASM_MUTE_REASON: PROPERTY_REFERENCES
// IGNORE_BACKEND: NATIVE
class A(var v: Int) {
fun f(x: Int) = x * v
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
object Singleton {
fun ok() = "OK"
}
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
fun Boolean.foo() = 1
fun Byte.foo() = 2
fun Short.foo() = 3
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
var x = 0
class A {
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
fun box(): String {
val f = "KOTLIN"::get
return "${f(1)}${f(0)}"
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
fun <T> id(x: T): T = x
fun <T> String.extId(x: T): T = x
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
abstract class A {
inner class InnerInA {
fun returnOk() = "OK"
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: WASM
fun box(): String {
val generateId = (1 .. Int.MAX_VALUE).iterator()::next
@@ -1,5 +1,5 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// WASM_MUTE_REASON: FUNCTION_REFERENCES
// WITH_RUNTIME
// IGNORE_BACKEND: JS
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// KT-42025
open class L<LL>(val ll: LL)
@@ -1,5 +1,4 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
// KT-42025
open class L<LL>(val ll: LL)
@@ -1,11 +1,23 @@
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: PROPERTY_REFERENCES
fun box(): String {
class Local {
var result = "Fail"
}
val l = Local()
(Local::result).set(l, "OK")
return (Local::result).get(l)
class X(val ok: String) {
fun y(): String = ok
}
fun box(): String {
val x = X("OK")
val y = x::y
return y()
}
//fun y(): String = "OK"
//
//fun box(): String {
// val y = ::y
// return y.invoke()
//}
//val x = "OK"
//
//fun box(): String {
// val x = ::x
// return x.get()
//}