Files
kotlin-fork/compiler/testData/diagnostics/tests/cast/AsNothing.kt
T
Mikhail Glukhikh b56e84d47f Cast never succeeds: special 'Nothing' / 'Nothing?' case
(cherry picked from commit 63435b4)
2016-07-27 10:52:13 +03:00

14 lines
306 B
Kotlin
Vendored

// Nothing can be cast to Nothing
fun foo(x: String) {
x <!CAST_NEVER_SUCCEEDS!>as<!> Nothing
}
fun gav(y: String?) {
y <!CAST_NEVER_SUCCEEDS!>as<!> Nothing
}
// Only nullable can be cast to Nothing?
fun bar(x: String, y: String?) {
x <!CAST_NEVER_SUCCEEDS!>as<!> Nothing?
y as Nothing?
}