FIR: improve inference of implicit type arguments in casts

Type parameters do not necessarily match one-to-one, or preserve order.
This commit is contained in:
pyos
2021-01-06 14:39:22 +01:00
committed by Dmitriy Novozhilov
parent acdc1f532b
commit 29f95c7df2
32 changed files with 134 additions and 149 deletions
@@ -2,13 +2,13 @@ package p
public fun foo(a: Any) {
a is Map<Int>
a is Map
a is <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Map<!>
a is Map<out Any?, Any?>
a is Map<*, *>
a is Map<<!SYNTAX!><!>>
a is List<Map>
a is List
a is <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>List<!>
a is Int
(a as Map) is Int
(a as <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Map<!>) is Int
}
@@ -1,12 +1,12 @@
public fun foo(a: Any, b: Map) {
when (a) {
is Map<Int> -> {}
is Map -> {}
is <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Map<!> -> {}
is Map<out Any?, Any?> -> {}
is Map<*, *> -> {}
is Map<<!SYNTAX!><!>> -> {}
is List<Map> -> {}
is List -> {}
is <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>List<!> -> {}
is Int -> {}
else -> {}
}
@@ -8,7 +8,7 @@ class DerivedOuter<G> : SuperOuter<G>() {
fun bare(x: SuperOuter<*>.SuperInner<*>, y: Any?) {
if (x is SuperOuter.SuperInner) return
if (y is SuperOuter.SuperInner) {
if (y is <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>SuperOuter.SuperInner<!>) {
return
}
}
@@ -12,7 +12,7 @@ class Outer<E> {
x.prop.checkType { _<E>() }
}
if (y is Inner) return
if (y is <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inner<!>) return
if (z is Inner) {
z.prop.checkType { _<Any?>() }
@@ -26,7 +26,7 @@ class Outer<E> {
fun bar(x: InnerBase<String>, y: Any?, z: Outer<*>.InnerBase<String>) {
x as Inner
y as Inner
y as <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inner<!>
z as Inner
}
}