Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/objectLiterals/captured.kt
T
Dmitry Savvinov 816d89e393 [NI] Improved testdata after changes in applicabilities
This commits introduces testdata changes, where NI behaviour strictly
improved, after several previous fixes.

For some tests, just WITH_NEW_INFERENCE directive was added. It
indicates, that some of previous commits first introduced error in that
test, and then some other commit fixed it (netting no overall testdata
change). It is preferrably to keep those annotations until we will
migrate to NI completely, to prevent unexpected regressions.
2017-12-07 12:49:56 +03:00

24 lines
529 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
abstract class Runnable {
abstract fun run()
}
fun foo(): Int {
val c: Int? = null
var a: Int?
if (c is Int) {
a = 2
val k = object: Runnable() {
init {
a = null
}
override fun run() = Unit
}
k.run()
val d: Int = <!DEBUG_INFO_SMARTCAST!>c<!>
// a is captured so smart cast is not possible
return d + <!NI;SMARTCAST_IMPOSSIBLE, SMARTCAST_IMPOSSIBLE!>a<!>
}
else return -1
}