NI: In subtyping do not intersect arguments for non-covariant types

It partially reverts 7898922066
because it's not obvious that it's a safe operation
for invariant/contravariant types.

Also, there's a necessary fix in prepareReceiverRegardingCaptureTypes
to make types order stable
Otherwise test bareTypesWithStarProjections becomes flaky.

Also, the changes in bareTypesWithStarProjections.kt are also expected
because the type of the expression `coneSymbol` after the second "if" is
FirVariableSymbol<*> & FirPropertySymbol & AbstractFirBasedSymbol<*>
thus we fix D in the call `coneSymbol.phasedFir()` to FirVariableSymbol<*>
because it's the first type in the list
(see the next line after the last changed in AbstractTypeChecker)
This commit is contained in:
Denis Zharkov
2020-01-14 12:35:17 +03:00
parent 4202c9c1a4
commit d6b01f1007
9 changed files with 38 additions and 12 deletions
@@ -15,3 +15,13 @@ fun <E> main(a: A<E>) {
foo(a).b()
}
class AOut<out X>
fun <Y> foo(c: AOut<Y>): Y = TODO()
fun <E> mainOut(a: AOut<E>) {
a as AOut<B<*>>
foo(a).b()
}
@@ -15,3 +15,13 @@ fun <E> main(a: A<E>) {
foo(<!DEBUG_INFO_SMARTCAST!>a<!>).b()
}
class AOut<out X>
fun <Y> foo(c: AOut<Y>): Y = TODO()
fun <E> mainOut(a: AOut<E>) {
a <!UNCHECKED_CAST!>as AOut<B<*>><!>
foo(<!DEBUG_INFO_SMARTCAST!>a<!>).b()
}
@@ -20,7 +20,7 @@ fun <X> InvBase<X>.myLastInv(): X = TODO()
fun <T> fooInv(x: InvBase<T>) {
if (x is InvDerived<*>) {
val l: T = x.myLastInv() // required T, found Cap(*). Only in NI
val l: T = <!TYPE_MISMATCH!>x.<!TYPE_MISMATCH!>myLastInv()<!><!> // required T, found Cap(*). Only in NI
}
}
@@ -36,7 +36,7 @@ fun Number.num() {}
fun main(b: Base<out Number>) {
b.foo().num()
if (b is Derived<*>) {
b.foo().num()
b.foo().<!DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE_WRONG_RECEIVER!>num<!>()
b.baz().length
}
}