[NI] Discriminate integer literal types as they are less specific
Plus simplify code in `ResultTypeResolver` a bit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun test(numbers: List<Number>) {
|
||||
|
||||
// Short <: R, ILT <: R => CST(Short, ILT) = Short
|
||||
// => we should pick Short in such situation as it more specific
|
||||
shortExpected { getShort() ?: 1 }
|
||||
|
||||
// Short <: R, ILT <: R, R <: Comparable<R> =>
|
||||
// Short <: Comparable<R>, ILT <: Comparable<R> =>
|
||||
// Comparable<Short> <: Comparable<R>, Comparable<ILT> <: Comparable<R> =>
|
||||
// R <: Short, R <: ILT =>
|
||||
// R := Short, R := ILT
|
||||
// => we should pick Short as it more specific
|
||||
shortComparable { getShort() ?: 1 }
|
||||
}
|
||||
|
||||
fun <R> shortExpected(f: () -> R) {}
|
||||
fun <R : Comparable<R>> shortComparable(f: () -> R) {}
|
||||
|
||||
fun getShort(): Short? = 1
|
||||
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public fun getShort(): kotlin.Short?
|
||||
public fun </*0*/ R : kotlin.Comparable<R>> shortComparable(/*0*/ f: () -> R): kotlin.Unit
|
||||
public fun </*0*/ R> shortExpected(/*0*/ f: () -> R): kotlin.Unit
|
||||
public fun test(/*0*/ numbers: kotlin.collections.List<kotlin.Number>): kotlin.Unit
|
||||
Reference in New Issue
Block a user