091b935c2d
'Subject.Error' is redundant. 'Subject.None' can be an object. 'Subject#dataFlowValue' can be a lateinit property. TODO: fix - parsing local extension properties in 'when' subject - parsing destructuring declarations in 'when' subject - non-completed calls in nested 'when' with subject variable - non-completed calls for subject variable in 'in' pattern
30 lines
751 B
Kotlin
Vendored
30 lines
751 B
Kotlin
Vendored
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
|
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
|
// WITH_RUNTIME
|
|
|
|
fun foo(): Any = 42
|
|
fun String.bar(): Any = 42
|
|
|
|
|
|
fun testSimpleValInWhenSubject() {
|
|
when (val y = foo()) {
|
|
}
|
|
}
|
|
|
|
fun testValWithoutInitializerWhenSubject() {
|
|
when (<!ILLEGAL_DECLARATION_IN_WHEN_SUBJECT!>val y: Any<!>) {
|
|
is String -> <!UNINITIALIZED_VARIABLE, DEBUG_INFO_SMARTCAST!>y<!>.length
|
|
}
|
|
}
|
|
|
|
fun testVarInWhenSubject() {
|
|
when (<!ILLEGAL_DECLARATION_IN_WHEN_SUBJECT!>var y = foo()<!>) {
|
|
is String -> <!DEBUG_INFO_SMARTCAST!>y<!>.length
|
|
}
|
|
}
|
|
|
|
fun testDelegatedValInWhenSubject() {
|
|
when (<!ILLEGAL_DECLARATION_IN_WHEN_SUBJECT!>val y by <!UNRESOLVED_REFERENCE!>lazy<!> { 42 }<!>) {
|
|
}
|
|
}
|