[NI] Add Nothing constraint if it was inferred from a call
This commit is contained in:
-1
@@ -106,7 +106,6 @@ class ConstraintInjector(val constraintIncorporator: ConstraintIncorporator, val
|
|||||||
|
|
||||||
if (constraintType is SimpleType) {
|
if (constraintType is SimpleType) {
|
||||||
if (constraint.kind == UPPER && constraintType.isNullableAny()) return true // T <: Any?
|
if (constraint.kind == UPPER && constraintType.isNullableAny()) return true // T <: Any?
|
||||||
if (constraint.kind == LOWER && constraintType.isNothing()) return true // T >: Nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|||||||
Vendored
+2
-2
@@ -9,8 +9,8 @@ inline fun <reified T> foo2(f: (T) -> Unit): Foo<T> = Foo()
|
|||||||
|
|
||||||
fun test1() {
|
fun test1() {
|
||||||
val f1: Foo<out Int> = foo1 { it checkType { _<Int>() } }
|
val f1: Foo<out Int> = foo1 { it checkType { _<Int>() } }
|
||||||
val f2: Foo<in Nothing> = <!NI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER, 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 f2: Foo<in Nothing> = <!NI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER, OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>foo1<!> { it <!UNREACHABLE_CODE!><!IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { _<Nothing>() }<!> }
|
||||||
|
|
||||||
val f3: Foo<out Int> = foo2 { it checkType { _<Int>() } }
|
val f3: Foo<out Int> = foo2 { it checkType { _<Int>() } }
|
||||||
val f4: Foo<in Nothing> = <!NI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER, 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>() }<!> }
|
val f4: Foo<in Nothing> = <!NI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER, OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER, REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>foo2<!> { it <!UNREACHABLE_CODE!><!IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { _<Nothing>() }<!> }
|
||||||
}
|
}
|
||||||
Vendored
+1
-1
@@ -23,7 +23,7 @@ fun test(s: SelectorFor<State>): Double {
|
|||||||
d checkType { _<AbstractSelector<State, Unit>>() }
|
d checkType { _<AbstractSelector<State, Unit>>() }
|
||||||
|
|
||||||
val e = s { return p1 }
|
val e = s { return p1 }
|
||||||
e checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><AbstractSelector<State, Nothing>>() }
|
e checkType { _<AbstractSelector<State, Nothing>>() }
|
||||||
|
|
||||||
<!OI;UNREACHABLE_CODE!>return<!> null!!
|
<!OI;UNREACHABLE_CODE!>return<!> null!!
|
||||||
}
|
}
|
||||||
+1
-1
@@ -13,5 +13,5 @@ fun test(s: String): String {
|
|||||||
a checkType { _<String>() }
|
a checkType { _<String>() }
|
||||||
|
|
||||||
<!UNREACHABLE_CODE!>val b =<!> TestClass { return s }
|
<!UNREACHABLE_CODE!>val b =<!> TestClass { return s }
|
||||||
<!UNREACHABLE_CODE!>b <!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!>
|
<!UNREACHABLE_CODE!>b <!IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { _<Nothing>() }<!>
|
||||||
}
|
}
|
||||||
Vendored
+1
-1
@@ -11,5 +11,5 @@ fun test(s: String): String {
|
|||||||
a checkType { _<TestClass>() }
|
a checkType { _<TestClass>() }
|
||||||
|
|
||||||
<!UNREACHABLE_CODE!>val b =<!> TestClass { return s }
|
<!UNREACHABLE_CODE!>val b =<!> TestClass { return s }
|
||||||
<!UNREACHABLE_CODE!>b <!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!>
|
<!UNREACHABLE_CODE!>b <!IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { _<Nothing>() }<!>
|
||||||
}
|
}
|
||||||
+1
-1
@@ -8,7 +8,7 @@ class TestClass {
|
|||||||
|
|
||||||
fun <T> test(value: T, test: TestClass): T {
|
fun <T> test(value: T, test: TestClass): T {
|
||||||
<!UNREACHABLE_CODE!>val x =<!> test { return value }
|
<!UNREACHABLE_CODE!>val x =<!> test { return value }
|
||||||
<!UNREACHABLE_CODE!>x <!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!>
|
<!UNREACHABLE_CODE!>x <!IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { _<Nothing>() }<!>
|
||||||
|
|
||||||
<!UNREACHABLE_CODE!>return value<!>
|
<!UNREACHABLE_CODE!>return value<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -5,5 +5,5 @@ val <!IMPLICIT_NOTHING_PROPERTY_TYPE!>y<!> get() = null!!
|
|||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
<!DEBUG_INFO_CONSTANT!>x<!> checkType { _<Nothing?>() }
|
<!DEBUG_INFO_CONSTANT!>x<!> checkType { _<Nothing?>() }
|
||||||
y <!UNREACHABLE_CODE!><!OI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Nothing>() }<!>
|
y <!UNREACHABLE_CODE!><!IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>checkType<!> { _<Nothing>() }<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -8,15 +8,15 @@ fun test(a: Int?, b: Int?) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun test(a: Int?, b: Int?, c: Int?) {
|
fun test(a: Int?, b: Int?, c: Int?) {
|
||||||
bar(<!NI;TYPE_MISMATCH!>if (a == null) return else if (b == null) return else <!OI;TYPE_MISMATCH!>c<!><!>)
|
bar(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>if (a == null) return else if (b == null) return else <!OI;TYPE_MISMATCH!>c<!><!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test(a: Any?, b: Any?, c: Int?) {
|
fun test(a: Any?, b: Any?, c: Int?) {
|
||||||
bar(<!NI;TYPE_MISMATCH!>if (a == null) if (b == null) <!OI;TYPE_MISMATCH!>c<!> else return else return<!>)
|
bar(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>if (a == null) if (b == null) <!OI;TYPE_MISMATCH!>c<!> else return else return<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test(a: Int?, b: Any?, c: Int?) {
|
fun test(a: Int?, b: Any?, c: Int?) {
|
||||||
bar(<!NI;TYPE_MISMATCH!>if (a == null) {
|
bar(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>if (a == null) {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
if (b == null) {
|
if (b == null) {
|
||||||
|
|||||||
+4
-4
@@ -12,13 +12,13 @@ fun case_1() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun case_2() {
|
fun case_2() {
|
||||||
<!NI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>test_1<!> { null!! }
|
test_1 { null!! }
|
||||||
<!NI;UNREACHABLE_CODE!>test_2 { null!! }<!>
|
test_2 { null!! }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun case_3() {
|
fun case_3() {
|
||||||
<!NI;IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>test_1<!> { throw Exception() }
|
test_1 { throw Exception() }
|
||||||
<!NI;UNREACHABLE_CODE!>test_2 { throw Exception() }<!>
|
test_2 { throw Exception() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun case_6() {
|
fun case_6() {
|
||||||
|
|||||||
Reference in New Issue
Block a user