Files
kotlin-fork/compiler/testData/diagnostics/tests/generics/capturedParameters/uncheckedCast.kt
T
Mikhail Zarechenskiy ae3497c6ce Reduce highlighting range for UNCHECKED_CAST
#KT-18985 Fixed
2017-08-07 18:49:58 +03:00

38 lines
585 B
Kotlin
Vendored

fun <E> foo(x: Any, y: Any) : Any {
class C
// without E?
if(x is <!CANNOT_CHECK_FOR_ERASED!>C<!>) {
return x
}
if (1 == 2) {
x <!UNCHECKED_CAST!>as C<!>
}
if (2 == 3) {
x <!UNCHECKED_CAST!>as? C<!>
}
class Outer<F> {
inner class Inner
}
// bare type
if (y is <!NO_TYPE_ARGUMENTS_ON_RHS!>Outer.Inner<!>) {
return y
}
y <!UNCHECKED_CAST!>as Outer<*>.Inner<!>
return C()
}
fun noTypeParameters(x: Any) : Any {
class C
if(x is C) {
return x
}
return C()
}