FIR: Rework bare types support

^KT-48305 Fixed
This commit is contained in:
Denis.Zharkov
2021-08-26 18:13:55 +03:00
committed by TeamCityServer
parent 587146679d
commit 112af9b145
21 changed files with 253 additions and 93 deletions
@@ -3,6 +3,6 @@
class G<T>
fun foo(p: <!UNRESOLVED_REFERENCE!>P<!>) {
val v = p as G?
checkSubtype<G<*>>(<!ARGUMENT_TYPE_MISMATCH!>v!!<!>)
val v = p as <!NO_TYPE_ARGUMENTS_ON_RHS!>G?<!>
checkSubtype<G<*>>(v!!)
}
@@ -0,0 +1,17 @@
// FIR_IDENTICAL
// SKIP_TXT
abstract class Parent<K>
abstract class DefaultParent<K, X> : Parent<K>()
abstract class TableDerived<K : A> : DefaultParent<K, Int>() {
fun bar(): K = TODO()
}
interface A {}
interface B : A { fun b() }
fun foo(): Parent<out B> = TODO()
fun main() {
val w = foo() as? TableDerived ?: return
w.bar().b()
}
@@ -1,14 +0,0 @@
open class SuperOuter<E> {
inner open class SuperInner<F>
}
class DerivedOuter<G> : SuperOuter<G>() {
inner class DerivedInner<H> : SuperOuter<G>.SuperInner<H>()
}
fun bare(x: SuperOuter<*>.SuperInner<*>, y: Any?) {
if (x is SuperOuter.SuperInner) return
if (y is <!NO_TYPE_ARGUMENTS_ON_RHS!>SuperOuter.SuperInner<!>) {
return
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
open class SuperOuter<E> {
inner open class SuperInner<F>
}
@@ -1,4 +1,3 @@
// FIR_IDE_IGNORE
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
@@ -1,4 +1,3 @@
// FIR_IDE_IGNORE
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
@@ -1,4 +1,3 @@
// FIR_IDE_IGNORE
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
@@ -1,4 +1,3 @@
// FIR_IDE_IGNORE
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
@@ -14,16 +14,16 @@ fun testNL1(x: Collection<Int>?): Boolean = x is NL
fun testNL2(x: Collection<Int>?): List<Int>? = x as NL
fun testNL3(x: Collection<Int>?): List<Int>? = x as NL?
fun testLStar(x: Collection<Int>): List<Int> = x as <!NO_TYPE_ARGUMENTS_ON_RHS!>LStar<!>
fun testMyList(x: Collection<Int>): List<Int> = x as <!NO_TYPE_ARGUMENTS_ON_RHS!>MyList<!>
fun testLStar(x: Collection<Int>): List<Int> = x as LStar
fun testMyList(x: Collection<Int>): List<Int> = x as MyList
typealias MMTT<T> = MutableMap<T, T>
typealias Dictionary<T> = MutableMap<String, T>
typealias WriteableMap<K, V> = MutableMap<in K, V>
typealias ReadableList<T> = MutableList<out T>
fun testWrong1(x: Map<Any, Any>) = x is MMTT
fun testWrong2(x: Map<Any, Any>) = x is Dictionary
fun testWrong1(x: Map<Any, Any>) = x is <!NO_TYPE_ARGUMENTS_ON_RHS!>MMTT<!>
fun testWrong2(x: Map<Any, Any>) = x is <!NO_TYPE_ARGUMENTS_ON_RHS!>Dictionary<!>
fun testWrong3(x: Map<Any, Any>) = x is <!NO_TYPE_ARGUMENTS_ON_RHS!>WriteableMap<!>
fun testWrong4(x: List<Any>) = x is <!NO_TYPE_ARGUMENTS_ON_RHS!>ReadableList<!>