Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/inference/kt4009.kt
T
Svetlana Isakova de85d3df72 KT-4009 Unnecessary attempt to do a smart cast causes an error
#KT-4009 Fixed
  do not add smart casted types for vars to constraint system
2013-10-16 19:51:52 +04:00

21 lines
500 B
Kotlin

trait PsiElement {
fun getText(): String
fun getParent(): PsiElement
}
trait JetExpression : PsiElement
fun foo1(e: PsiElement) {
var current: PsiElement? = e
var first = true
while (current != null) {
if (current is JetExpression && first) {
println(current!!.getText()) // error: smart cast not possible. But it's not needed in fact!
}
current = current?.getParent()
}
}
//from library
fun println(any: Any?) = throw Exception("$any")