[FIR] KT-56723: Ensure safe access over non-expressions is always Unit
^KT-56723 Fixed
This commit is contained in:
committed by
Space Team
parent
a8370ea994
commit
be5850112a
+27
@@ -0,0 +1,27 @@
|
||||
fun foo(f: () -> Unit, returnIfOk: String): String {
|
||||
val string = f().toString()
|
||||
|
||||
return if (string == "kotlin.Unit") {
|
||||
returnIfOk
|
||||
} else {
|
||||
"FAIL: $string;"
|
||||
}
|
||||
}
|
||||
|
||||
class Wrapper(var s: String)
|
||||
|
||||
fun box(): String {
|
||||
val w: Wrapper? = Wrapper("Test")
|
||||
|
||||
val lambda = {
|
||||
w?.s = "X"
|
||||
}
|
||||
|
||||
val w2: Wrapper? = null
|
||||
|
||||
val lambda2 = {
|
||||
w2?.s = "X"
|
||||
}
|
||||
|
||||
return foo(lambda, "O") + foo(lambda2, "K")
|
||||
}
|
||||
Reference in New Issue
Block a user