KT-5699 VerifyError in inlines
#KT-5699 Fixed
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import test.*
|
||||
|
||||
fun testExtensionInClass() : String {
|
||||
|
||||
var res = with(Z(1)) { "1".run("OK") }
|
||||
if (res != "1OK") return "failed in class 1: $res"
|
||||
|
||||
res = with(Z(1)) { "1".run() }
|
||||
if (res != "1null") return "failed in class 2: $res"
|
||||
|
||||
res = with(Z(2)) { "3".run("OK", {(a, b) -> a + b + value }, 1) }
|
||||
if (res != "OK123") return "failed in class 3: $res"
|
||||
|
||||
res = with(Z(3)) { "4".run(lambda = {(a, b) -> a + b + value }) }
|
||||
if (res != "034") return "failed in class 4: $res"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
var res = "1".run("OK")
|
||||
if (res != "1OK") return "failed 1: $res"
|
||||
|
||||
res = "1".run()
|
||||
if (res != "1null") return "failed 2: $res"
|
||||
|
||||
res = "3".run("OK", {(a, b) -> a + b}, 1)
|
||||
if (res != "OK13") return "failed 3: $res"
|
||||
|
||||
res = "4".run(lambda = {(a, b) -> a + b})
|
||||
if (res != "04") return "failed 4: $res"
|
||||
|
||||
return testExtensionInClass()
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package test
|
||||
|
||||
inline public fun String.run(p1: String? = null): String {
|
||||
return this + p1
|
||||
}
|
||||
|
||||
inline public fun String.run(p1: String = "", lambda: (a: String, b: Int) -> String, p2: Int = 0): String {
|
||||
return lambda(p1, p2) + this
|
||||
}
|
||||
|
||||
public class Z(val value: Int = 0) {
|
||||
|
||||
inline public fun String.run(p1: String? = null): String? {
|
||||
return this + p1
|
||||
}
|
||||
|
||||
inline public fun String.run(p1: String = "", lambda: (a: String, b: Int) -> String, p2: Int = 0): String {
|
||||
return lambda(p1, p2) + this
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
if (Z().run() != "null0") return "fail 1: ${Z().run()}"
|
||||
|
||||
if (Z().run("OK") != "OK0") return "fail 2"
|
||||
|
||||
if (Z().run("OK", {(a, b) -> a + b }, 1) != "OK1") return "fail 3"
|
||||
|
||||
if (Z().run(lambda = {(a: String, b: Int) -> a + b }) != "0") return "fail 4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package test
|
||||
|
||||
public class Z(public val value: Int = 0) {
|
||||
|
||||
inline public fun run(p1: String? = null): String? {
|
||||
return p1 + value
|
||||
}
|
||||
|
||||
|
||||
inline public fun run(p1: String = "", lambda: (a: String, b: Int) -> String, p2: Int = 0): String {
|
||||
return lambda(p1, p2)
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,8 @@ fun box(): String {
|
||||
result = simple()
|
||||
if (result != "OK") return "fail2: ${result}"
|
||||
|
||||
var result2 = simpleDoubleFun(2.0)
|
||||
if (result2 != 2.0 + 1.0) return "fail3: ${result2}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -9,3 +9,9 @@ inline fun simpleFun(arg: String = "O"): String {
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
inline fun simpleDoubleFun(arg: Double = 1.0): Double {
|
||||
val r = arg + 1;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user