Cast never succeeds: special 'Nothing' / 'Nothing?' case
(cherry picked from commit 63435b4)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
bf4231d65a
commit
b56e84d47f
@@ -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
|
||||
Reference in New Issue
Block a user