[NI] discriminate Nothing for reified parameters

Related issues: KT-32836, KT-35728
This commit is contained in:
Pavel Kirpichenkov
2020-01-14 12:40:19 +03:00
parent a16b21a7cc
commit 4a29de3716
14 changed files with 222 additions and 7 deletions
@@ -1,5 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !WITH_NEW_INFERENCE
inline fun <reified T> parse(json: String): T? = TODO()
+1 -2
View File
@@ -1,5 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !WITH_NEW_INFERENCE
inline fun <reified T> parse(json: String): T? = TODO()
@@ -7,7 +6,7 @@ class MyType
fun parseMyData(json: String): MyType =
try {
<!NI;REIFIED_TYPE_FORBIDDEN_SUBSTITUTION, NI;REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>parse<!>(json) // error with new inf only: Cannot use 'Nothing?' as reified type parameter
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")