[NI] Remove hack for special functions
Treating special functions for `if`, `when`, `try`, `?:` as not accepting `Nothing` result type is incorrect. Making so leads to cases with uninferred `Nothing` result type for inner calls and lost data flow info.
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ val ww = if (true) {
|
||||
<!OI;TYPE_MISMATCH!>{ true }<!> <!USELESS_ELVIS!>?: null!!<!>
|
||||
}
|
||||
else if (true) {
|
||||
<!OI;TYPE_MISMATCH!>{ true }<!> <!USELESS_ELVIS!>?: null!!<!>
|
||||
<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>{ <!NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>true<!> }<!> <!USELESS_ELVIS!>?: null!!<!>
|
||||
}
|
||||
else {
|
||||
null!!
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
inline fun <reified T> parse(json: String): T? = TODO()
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
inline fun <reified T> parse(json: String): T? = TODO()
|
||||
|
||||
@@ -6,7 +7,7 @@ class MyType
|
||||
|
||||
fun parseMyData(json: String): MyType =
|
||||
try {
|
||||
parse(json) // error with new inf only: Cannot use 'Nothing?' as reified type parameter
|
||||
<!NI;REIFIED_TYPE_FORBIDDEN_SUBSTITUTION, NI;REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>parse<!>(json) // error with new inf only: Cannot use 'Nothing?' as reified type parameter
|
||||
?: throw IllegalArgumentException("Can't parse")
|
||||
} catch (e: Exception) {
|
||||
throw IllegalArgumentException("Can't parse")
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNREACHABLE_CODE
|
||||
|
||||
fun test() {
|
||||
val x: Int? = 20
|
||||
if (x != null) {
|
||||
} else {
|
||||
if (true) return else return
|
||||
}
|
||||
x.and(1) // unsafe call
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNREACHABLE_CODE
|
||||
|
||||
fun test() {
|
||||
val x: Int? = 20
|
||||
if (x != null) {
|
||||
} else {
|
||||
if (true) return else return
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.and(1) // unsafe call
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
Reference in New Issue
Block a user