JS: extension lambdas translated same as local lambdas (KT-13312 fixed)

This commit is contained in:
Anton Bannykh
2017-01-16 16:24:06 +03:00
parent 5021be351d
commit 07bb7ef4d3
32 changed files with 123 additions and 183 deletions
@@ -0,0 +1,23 @@
fun test1(f: (Int) -> Int) = f(1)
fun test2(f: Int.() -> Int) = 2.f()
class A(val foo: Int.() -> Int)
fun box(): String {
val a: (Int) -> Int = { it }
val b: Int.() -> Int = { this }
if (test1(a) != 1) return "fail 1a"
if (test1(b) != 1) return "fail 1b"
if (test2(a) != 2) return "fail 2a"
if (test2(b) != 2) return "fail 2b"
val x = A({ this })
if (x.foo(3) != 3) return "fail 3"
if (with(x) { foo(4) } != 4) return "fail 4"
if (with(x) { 5.foo() } != 5) return "fail 5"
return "OK"
}
@@ -1,6 +1,3 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
fun test(cl: Int.() -> Int):Int = 11.cl()
class Foo {
@@ -1,6 +1,3 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
fun box(): String {
val f = fun (s: String): String = s
val g = f as String.() -> String
@@ -1,6 +1,3 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
class It(val id: String)
fun box(): String {
@@ -1,6 +1,3 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
fun box(): String {
operator fun Int?.inc() = (this ?: 0) + 1
var counter: Int? = null
@@ -1,6 +1,3 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
// WITH_REFLECT
fun doStuff(fn: String.() -> String) = "ok".fn()