Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/objectLiterals/base.kt
T
2015-05-21 13:03:39 +03:00

20 lines
512 B
Kotlin
Vendored

// See KT-6293: Smart cast doesn't work after object literal
abstract class Runnable {
abstract fun run()
}
fun foo(): Int {
val c: Int? = null
if (c is Int) {
val d: Int = <!DEBUG_INFO_SMARTCAST!>c<!>
// This object breaks data flow info propagation
val k = object: Runnable() {
override fun run() = Unit
}
k.run()
// Smart cast should work but error is reported
return <!DEBUG_INFO_SMARTCAST!>c<!> + d
}
else return -1
}