[FE] Implement discussed rules to report empty intersection errors

This commit is contained in:
Victor Petukhov
2022-03-28 16:11:18 +03:00
committed by teamcity
parent b96708c3e2
commit 5bfe6cd20a
29 changed files with 241 additions and 62 deletions
@@ -1,14 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
abstract class Bar<T>
class Foo<T> : Bar<T>(), Comparable<Foo<*>> {
override fun compareTo(other: Foo<*>): Int = TODO()
}
infix fun <T : Comparable<T>, S : T?> Bar<in S>.test(t: T) { }
infix fun <T : Comparable<T>, S : T?> Bar<in S>.test(other: Bar<in S>) {}
fun checkFunctions(exp1: Foo<Int?>, exp2: Foo<Int>) {
exp1.<!OVERLOAD_RESOLUTION_AMBIGUITY!>test<!>(exp2)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
abstract class Bar<T>
@@ -13,7 +13,7 @@ fun testElvis(a: Int?, b: Int?) {
if (a != null) {
doInt(b ?: a)
}
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION!>doList<!>(getList() ?: emptyListOfA()) //should be an error
doList(getList() ?: emptyListOfA()) //should be an error
doList(getList() ?: strangeList { doInt(it) }) //lambda was not analyzed
}
@@ -13,7 +13,7 @@ fun testElvis(a: Int?, b: Int?) {
if (a != null) {
doInt(b ?: <!DEBUG_INFO_SMARTCAST!>a<!>)
}
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>doList<!>(getList() ?: emptyListOfA()) //should be an error
doList(getList() ?: emptyListOfA()) //should be an error
doList(getList() ?: strangeList { doInt(it) }) //lambda was not analyzed
}
@@ -12,7 +12,7 @@ fun <T: A> emptyNullableListOfA(): List<T>? = null
//-------------------------------
fun testExclExcl() {
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION!>doList<!>(emptyNullableListOfA()!!) //should be an error here
doList(emptyNullableListOfA()!!) //should be an error here
val l: List<Int> = <!INITIALIZER_TYPE_MISMATCH, NEW_INFERENCE_ERROR!>id(emptyNullableListOfA()!!)<!>
doList(strangeNullableList { doInt(it) }!!) //lambda should be analyzed (at completion phase)
@@ -12,7 +12,7 @@ fun <T: A> emptyNullableListOfA(): List<T>? = null
//-------------------------------
fun testExclExcl() {
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>doList<!>(emptyNullableListOfA()!!) //should be an error here
doList(emptyNullableListOfA()!!) //should be an error here
val l: List<Int> = <!TYPE_MISMATCH!><!TYPE_MISMATCH!>id<!>(<!TYPE_MISMATCH!>emptyNullableListOfA<!>()<!TYPE_MISMATCH!>!!<!>)<!>
doList(strangeNullableList { doInt(it) }!!) //lambda should be analyzed (at completion phase)