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
This commit is contained in:
Denis Zharkov
2016-07-13 18:32:47 +03:00
parent 06a659e6e7
commit 4725dd3028
14 changed files with 623 additions and 30 deletions
@@ -12,18 +12,18 @@ fun test() {
val x1 =
if (1 == 1)
// TODO: Diagnostic content could be better
<!EXPECTED_TYPE_MISMATCH(\(\) -> Int)!>fun named4(): Int {return 1}<!>
else
<!EXPECTED_TYPE_MISMATCH!>fun named5() = 1<!>
<!SYNTAX!><!>fun named4(): Int {return 1}
<!SYNTAX!>else<!>
fun named5() = 1
val x2 =
if (1 == 1) {
<!EXPECTED_TYPE_MISMATCH!>fun named6(): Int {
fun named6(): Int {
return 1
}<!>
}
}
else
<!EXPECTED_TYPE_MISMATCH!>fun named7() = 1<!>
<!SYNTAX!><!>fun named7() = 1
val x3 = when (1) {
0 -> <!EXPECTED_TYPE_MISMATCH!>fun named8(): Int {return 1}<!>