[NI] Discriminate constraints with Nothing(?) lower bounds
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// Validation test.
|
||||
// Check that type variable is fixed to Data<Nothing> as it's used in input types for lambda
|
||||
|
||||
class Data<T>(val x: T) {
|
||||
fun dataMethod() {}
|
||||
}
|
||||
|
||||
fun <K> bar(x: K, y: (K) -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
bar(Data(null)) { it.dataMethod() }
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K> bar(/*0*/ x: K, /*1*/ y: (K) -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class Data</*0*/ T> {
|
||||
public constructor Data</*0*/ T>(/*0*/ x: T)
|
||||
public final val x: T
|
||||
public final fun dataMethod(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun <K> select2(x: K, y: K): K = TODO()
|
||||
fun <K> select3(x: K, y: K, z: K): K = TODO()
|
||||
|
||||
fun <K : S, S> dependantSelect2(x: K, y: S) {}
|
||||
fun <K : S, S> dependantSelect3(x: K, y: K, z: S) {}
|
||||
|
||||
fun foo() {}
|
||||
fun cloneFoo() {}
|
||||
fun bar(x: Int) {}
|
||||
|
||||
fun test(f1: (Int) -> Unit, f2: kotlin.Function1<Int, Unit>) {
|
||||
select2(null, ::foo)
|
||||
select3(null, f1, ::bar)
|
||||
select3(null, f2, ::bar)
|
||||
|
||||
select3(null, f1, <!TYPE_MISMATCH!>::foo<!>)
|
||||
select3(null, f2, <!TYPE_MISMATCH!>::foo<!>)
|
||||
|
||||
dependantSelect2(null, ::foo)
|
||||
dependantSelect3(null, ::foo, ::cloneFoo)
|
||||
dependantSelect3(null, f1, ::bar)
|
||||
// Here we have LOWER(Nothing?), UPPER(Function1) and therefore type variable is fixed to the former
|
||||
dependantSelect3(null, <!TYPE_MISMATCH!>::bar<!>, f1)
|
||||
|
||||
// These errors are actually can be fixed (and, probably, should) if we force resolution of callable reference
|
||||
dependantSelect3(null, ::foo, <!TYPE_MISMATCH!>::bar<!>)
|
||||
dependantSelect3(null, ::bar, <!TYPE_MISMATCH!>::foo<!>)
|
||||
dependantSelect3(null, f1, <!TYPE_MISMATCH!>::foo<!>)
|
||||
dependantSelect3(null, <!TYPE_MISMATCH!>::foo<!>, f1)
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public fun cloneFoo(): kotlin.Unit
|
||||
public fun </*0*/ K : S, /*1*/ S> dependantSelect2(/*0*/ x: K, /*1*/ y: S): kotlin.Unit
|
||||
public fun </*0*/ K : S, /*1*/ S> dependantSelect3(/*0*/ x: K, /*1*/ y: K, /*2*/ z: S): kotlin.Unit
|
||||
public fun foo(): kotlin.Unit
|
||||
public fun </*0*/ K> select2(/*0*/ x: K, /*1*/ y: K): K
|
||||
public fun </*0*/ K> select3(/*0*/ x: K, /*1*/ y: K, /*2*/ z: K): K
|
||||
public fun test(/*0*/ f1: (kotlin.Int) -> kotlin.Unit, /*1*/ f2: (kotlin.Int) -> kotlin.Unit): kotlin.Unit
|
||||
Reference in New Issue
Block a user