[NI] Avoid constraints from expected type for effectively empty system
Expression will be checked against expected type later. Theoretically, this is not very good, but it aligns with the old inference, plus it helps avoiding multiple type mismatch diagnostics.
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ fun foo(): String? {
|
||||
run {
|
||||
if (true) return@run
|
||||
|
||||
if (true) return <!TYPE_MISMATCH, TYPE_MISMATCH!>Obj()<!> // correct error, type check against return type of function "foo"
|
||||
if (true) return <!TYPE_MISMATCH!>Obj()<!> // correct error, type check against return type of function "foo"
|
||||
}
|
||||
|
||||
run {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ package kt1293
|
||||
|
||||
fun main() {
|
||||
val intArray = arrayOfNulls<Int>(10)
|
||||
val <!UNUSED_VARIABLE!>i<!> : Int = <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>intArray[0]<!>
|
||||
val <!UNUSED_VARIABLE!>i<!> : Int = <!TYPE_MISMATCH!>intArray[0]<!>
|
||||
requiresInt(<!TYPE_MISMATCH!>intArray[0]<!>)
|
||||
}
|
||||
|
||||
|
||||
@@ -29,5 +29,5 @@ fun testWithoutInference(col: MutableCollection<Int>) {
|
||||
|
||||
doAction { col.add(2) }
|
||||
|
||||
val <!UNUSED_VARIABLE!>u<!>: Unit = <!TYPE_MISMATCH!>col.<!NI;TYPE_MISMATCH!>add(2)<!><!>
|
||||
val <!UNUSED_VARIABLE!>u<!>: Unit = <!TYPE_MISMATCH!>col.add(2)<!>
|
||||
}
|
||||
+1
-1
@@ -8,5 +8,5 @@ class Client<T, X: Base<T>>(<!UNUSED_PARAMETER!>x<!>: X)
|
||||
|
||||
fun test() {
|
||||
val c = Client(StringBase()) // Type inference fails here for T.
|
||||
val <!UNUSED_VARIABLE!>i<!> : Int = <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>c<!>
|
||||
val <!UNUSED_VARIABLE!>i<!> : Int = <!TYPE_MISMATCH!>c<!>
|
||||
}
|
||||
Reference in New Issue
Block a user