[FIR] Fix inferring arguments of bare types in different situations
- argument type is flexible - supertype has flexible type argument - type of expression is more specific than bare type
This commit is contained in:
committed by
TeamCityServer
parent
b99f1a1512
commit
14108011ee
@@ -0,0 +1,32 @@
|
||||
FILE: bareTypes2.kt
|
||||
public abstract interface A<D : R|A<D>|> : R|kotlin/Any| {
|
||||
public abstract fun foo(): R|kotlin/Any|
|
||||
|
||||
public abstract val cond: R|kotlin/Boolean|
|
||||
public get(): R|kotlin/Boolean|
|
||||
|
||||
public abstract val field: R|kotlin/Any|
|
||||
public get(): R|kotlin/Any|
|
||||
|
||||
}
|
||||
public abstract interface B<F : R|B<F>|> : R|A<F>| {
|
||||
public abstract override fun foo(): R|kotlin/CharSequence|
|
||||
|
||||
}
|
||||
public abstract interface C : R|B<C>| {
|
||||
public abstract override fun foo(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public final fun test(x: R|A<*>|): R|kotlin/Unit| {
|
||||
when ((R|<local>/x| as? R|C|)?.{ $subj$.R|/A.field| }) {
|
||||
($subj$ is R|kotlin/String|) -> {
|
||||
when () {
|
||||
==((R|<local>/x| as? R|B<C>|)?.{ $subj$.R|/A.cond| }, Boolean(true)) -> {
|
||||
R|<local>/x|.R|/C.foo|()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
interface A<D : A<D>> {
|
||||
fun foo(): Any
|
||||
|
||||
val cond: Boolean
|
||||
val field: Any
|
||||
}
|
||||
|
||||
interface B<F : B<F>> : A<F> {
|
||||
override fun foo(): CharSequence
|
||||
}
|
||||
|
||||
interface C : B<C> {
|
||||
override fun foo(): String
|
||||
}
|
||||
|
||||
fun test(x: A<*>) {
|
||||
when ((x as? C)?.field) {
|
||||
is String -> {
|
||||
if ((x as? B)?.cond == true) {
|
||||
x.foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
FILE: bareTypesWithFlexibleArguments.kt
|
||||
public final fun <T> R|kotlin/collections/Collection<T>?|.concat(collection: R|kotlin/collections/Collection<T>|): R|kotlin/collections/Collection<T>?| {
|
||||
when () {
|
||||
(this@R|/concat| is R|kotlin/collections/LinkedHashSet<T>|) -> {
|
||||
this@R|/concat|.R|SubstitutionOverride<java/util/LinkedHashSet.addAll: R|kotlin/Boolean|>|(R|<local>/collection|)
|
||||
^concat this@R|/concat|
|
||||
}
|
||||
}
|
||||
|
||||
^concat this@R|/concat|
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_STDLIB
|
||||
// FULL_JDK
|
||||
|
||||
fun <T> Collection<T>?.concat(collection: Collection<T>): Collection<T>? {
|
||||
if (this is LinkedHashSet) {
|
||||
addAll(collection)
|
||||
return this
|
||||
}
|
||||
return this
|
||||
}
|
||||
Reference in New Issue
Block a user