Cast never succeeds: special 'Nothing' / 'Nothing?' case

(cherry picked from commit 63435b4)
This commit is contained in:
Mikhail Glukhikh
2016-07-26 15:50:03 +03:00
committed by Mikhail Glukhikh
parent bf4231d65a
commit b56e84d47f
5 changed files with 29 additions and 2 deletions
+14
View File
@@ -0,0 +1,14 @@
// 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?
}
@@ -0,0 +1,5 @@
package
public fun bar(/*0*/ x: kotlin.String, /*1*/ y: kotlin.String?): kotlin.Unit
public fun foo(/*0*/ x: kotlin.String): kotlin.Unit
public fun gav(/*0*/ y: kotlin.String?): kotlin.Unit