dc42b20ae3
The new inference uses inferred intersection types normally, unlike the old inference.
However, intersection types in public declarations are approximated to supertype, which
potentially may give a less presice type, then it would be with the OI.
For non-related T1, T2 the NI approximates {T1 & T2} to Any in public declarations,
and if the OI was inferring T1 instead of the intersection type, it may lead to
less precise declaration type and related errors.
The solution is to remember an alternative for an intersection type when present.
Before approximation the alternative replaces the intersection type.
^KT-36249 Fixed
26 lines
577 B
Kotlin
Vendored
26 lines
577 B
Kotlin
Vendored
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
|
// !WITH_NEW_INFERENCE
|
|
// NI_EXPECTED_FILE
|
|
|
|
interface Base {
|
|
fun base() {}
|
|
}
|
|
interface Base2 : Base3
|
|
interface Base3
|
|
interface One : Base, Base2
|
|
interface Two : Base, Base2
|
|
interface Three : Base, Base3
|
|
|
|
object O1 : One
|
|
object O2 : Two
|
|
object O3 : Three
|
|
|
|
fun <S: Base> intersect(vararg elements: S): S = TODO()
|
|
fun <S> intersectNoBound(vararg elements: S): S = TODO()
|
|
|
|
fun some(a: One, b: Two, c: Three) = intersectNoBound(intersect(a, b), c)
|
|
|
|
fun test(arg: Base, arg2: Base) {
|
|
some(O1, O2, O3).<!NI;UNRESOLVED_REFERENCE!>base<!>()
|
|
}
|