Files
kotlin/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameInBlock.kt
Denis Zharkov f1026935a0 Add recovery for properties without name
If property name is parsed on the next line and declaration is invalid
(no receiver/type/initializer), treat that name as it does not belong to property

 #KT-12987 In Progress
2016-07-08 16:06:47 +03:00

51 lines
838 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
fun println(x: String) {
}
fun run(block: () -> Unit) {}
val propertyNameOnTheNextLine = 1
fun foo() {
val<!SYNTAX!><!>
println("abc")
val<!SYNTAX!><!>
run {
println("abc")
}
val<!SYNTAX!><!>
if (1 == 1) {
}
val<!SYNTAX!><!>
(1 + 2)
// `propertyNameOnTheNextLine` parsed as simple name expression
val<!SYNTAX!><!>
propertyNameOnTheNextLine
val<!SYNTAX!><!>
// comment
propertyNameOnTheNextLine
val<!SYNTAX!><!> /* comment */
propertyNameOnTheNextLine
// Correct properties
val
property1 = 1
val
propertyWithBy by <!UNRESOLVED_REFERENCE!>lazy<!> { 1 }
val
propertyWithType: Int
val
(a, b) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>1<!>
}