Files
kotlin-fork/compiler/testData/codegen/box/callableReference/property/kt12044.kt
T
Alexander Udalov f8a88bdffb Fix "Rewrite at slice LEXICAL_SCOPE" for callable references
For special calls (when-expressions, if-expressions, etc.), do not attempt to
get type of the argument expression, which is the block with the callable
reference, instead get type of the callable reference itself. The difference
matters because for block expressions, a new lexical scope is created for each
getTypeInfo (see ExpressionTypingServices.getBlockReturnedType), and we do not
support rewrites of this value in the binding trace

 #KT-12044 Fixed
2016-12-27 10:45:46 +03:00

13 lines
392 B
Kotlin
Vendored

// KT-12044 Assertion "Rewrite at slice LEXICAL_SCOPE" for 'if' with property references
fun box(): String {
data class Pair<F, S>(val first: F, val second: S)
val (x, y) =
Pair(1,
if (1 == 1)
Pair<String, String>::first
else
Pair<String, String>::second)
return y.get(Pair("OK", "Fail"))
}