[NI] Fix exception, recorded type for function statement can be null

See `checkStatementType`, we return `null` to reduce count of errors.

 Also, note that named function which is used as last statement in lambda
 doesn't coerce to Unit, this is a separate bug and will be addressed later,
 see #KT-25383

 #EA-121026 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2018-07-10 13:13:03 +03:00
parent eb745133c9
commit 2be08f4d60
6 changed files with 35 additions and 6 deletions
@@ -27,15 +27,15 @@ fun test() {
<!SYNTAX!><!>fun named7() = 1
val x3 = when (1) {
0 -> <!OI;EXPECTED_TYPE_MISMATCH!>fun <!NI;ANONYMOUS_FUNCTION_WITH_NAME!>named8<!>(): Int {return 1}<!>
else -> <!OI;EXPECTED_TYPE_MISMATCH!>fun <!NI;ANONYMOUS_FUNCTION_WITH_NAME!>named9<!>() = 1<!>
0 -> <!EXPECTED_TYPE_MISMATCH!>fun named8(): Int {return 1}<!>
else -> <!EXPECTED_TYPE_MISMATCH!>fun named9() = 1<!>
}
val x31 = when (1) {
0 -> {
<!OI;EXPECTED_TYPE_MISMATCH!>fun <!NI;ANONYMOUS_FUNCTION_WITH_NAME!>named10<!>(): Int {return 1}<!>
<!EXPECTED_TYPE_MISMATCH!>fun named10(): Int {return 1}<!>
}
else -> <!OI;EXPECTED_TYPE_MISMATCH!>fun <!NI;ANONYMOUS_FUNCTION_WITH_NAME!>named11<!>() = 1<!>
else -> <!EXPECTED_TYPE_MISMATCH!>fun named11() = 1<!>
}
val x4 = {
@@ -55,5 +55,5 @@ fun success() {
run2 { fun named2() = 1 }
val x = run { fun named3() = 1 }
x checkType { _<Unit>() }
x checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Unit>() }
}