Files
kotlin/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/declarationAfterIncompleteElvis.kt
Denis Zharkov 4725dd3028 Implement recovery for incomplete expression before declaration
It's needed when declarations are parsed as a part of previous expression
(see tests)

Currently we apply this kind of recovery in a conservative way,
only when declaration starts at the next line, and while
the condition could be relaxed, there's no need to do this

 #KT-4948 Fixed
 #KT-7118 Fixed
2016-07-15 18:59:31 +03:00

23 lines
352 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_VARIABLE
fun foo(x: Any?) {
x ?:<!SYNTAX!><!>
val foo = 1
x ?:<!SYNTAX!><!>
fun bar() = 2
val res: String.() -> Int = null ?:
fun String.() = 3
}
class A {
val z = null ?:<!SYNTAX!><!>
val x = 4
val y = null ?:<!SYNTAX!><!>
fun baz() = 5
val q = null ?:
fun String.() = 6
}