[NI] Add extra ordering for ready-for-fixation variables
Helps fixing to more specific type in the following situations: Type1 <: Var1 Var2 <: Var1 Var2 <: Type2 Type1 and Type2 may also be nullable and non-nullable versions of the same type. Note that no additional constraints can be inferred from such constraints before fixation. Resulting types for variables will always Type1 and Type2 may also be nullable and non-nullable versions of the same type. Fixing Var1 first will make Var2's type more specific while fixing Var2 first will make Var1's type less specific. The first is preferrable in general.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
fun <T, VR : T> foo(x: T, fn: (VR?/*T?*/, T) -> Unit) {}
|
||||
|
||||
fun takeInt(x: Int) {}
|
||||
|
||||
fun main(x: Int) {
|
||||
foo(x) { prev: Int?, new -> takeInt(new) } // `new` is `Int` in OI, `Int?` in NI
|
||||
// It seems, `VR` has been fixed to `Int?` instead of `Int`
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T, /*1*/ VR : T> foo(/*0*/ x: T, /*1*/ fn: (VR?, T) -> kotlin.Unit): kotlin.Unit
|
||||
public fun main(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public fun takeInt(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
Reference in New Issue
Block a user