Introduce warning about implicitly inferred Nothing as a type parameter

^KT-20849 Fixed
This commit is contained in:
victor.petukhov
2019-03-13 16:28:51 +03:00
parent 1f98eaa27b
commit 70c35f4186
26 changed files with 188 additions and 24 deletions
@@ -7,6 +7,6 @@ fun foo1() {
<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>fooT22<!>()
}
val n : Nothing = null.sure()
val n : Nothing = null.<!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>sure<!>()
fun <T : Any> T?.sure() : T = this!!
@@ -9,8 +9,8 @@ inline fun <reified T> foo2(f: (T) -> Unit): Foo<T> = Foo()
fun test1() {
val f1: Foo<out Int> = foo1 { it checkType { _<Int>() } }
val f2: Foo<in Nothing> = foo1 { it <!UNREACHABLE_CODE!>checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!> }
val f2: Foo<in Nothing> = <!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>foo1<!> { it <!UNREACHABLE_CODE!><!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!> }
val f3: Foo<out Int> = foo2 { it checkType { _<Int>() } }
val f4: Foo<in Nothing> = <!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>foo2<!> { it <!UNREACHABLE_CODE!>checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!> }
val f4: Foo<in Nothing> = <!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER, REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>foo2<!> { it <!UNREACHABLE_CODE!><!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!> }
}
@@ -13,5 +13,5 @@ fun test(s: String): String {
a checkType { _<String>() }
<!UNREACHABLE_CODE!>val b =<!> TestClass { return s }
<!UNREACHABLE_CODE!>b checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!>
<!UNREACHABLE_CODE!>b <!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!>
}
@@ -11,5 +11,5 @@ fun test(s: String): String {
a checkType { _<TestClass>() }
<!UNREACHABLE_CODE!>val b =<!> TestClass { return s }
<!UNREACHABLE_CODE!>b checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!>
<!UNREACHABLE_CODE!>b <!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!>
}
@@ -8,7 +8,7 @@ class TestClass {
fun <T> test(value: T, test: TestClass): T {
<!UNREACHABLE_CODE!>val x =<!> test { return value }
<!UNREACHABLE_CODE!>x checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!>
<!UNREACHABLE_CODE!>x <!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!>
<!UNREACHABLE_CODE!>return value<!>
}