[FIR] Don't create redundant substitution scopes

This commit is contained in:
Mikhail Glukhikh
2020-02-20 12:09:12 +03:00
parent 01053c938a
commit a6d11b0207
9 changed files with 12 additions and 10 deletions
@@ -120,7 +120,11 @@ abstract class AbstractConeSubstitutor : ConeSubstitutor() {
}
fun substitutorByMap(substitution: Map<FirTypeParameterSymbol, ConeKotlinType>): ConeSubstitutor {
if (substitution.isEmpty()) return ConeSubstitutor.Empty
// If all arguments match parameters, then substitutor isn't needed
if (substitution.all { (parameterSymbol, argumentType) ->
(argumentType as? ConeTypeParameterType)?.lookupTag?.typeParameterSymbol == parameterSymbol
}
) return ConeSubstitutor.Empty
return ConeSubstitutorByMap(substitution)
}
@@ -8,7 +8,7 @@ FILE: genericUsedInFunction.kt
public get(): R|T|
public final fun foo(): R|T| {
^foo this@R|/Generic|.R|FakeOverride</Generic.value: R|T|>|
^foo this@R|/Generic|.R|/Generic.value|
}
}
@@ -91,7 +91,7 @@ FILE: protectedVisibility.kt
public get(): R|T|
protected open fun foo(): R|T| {
^foo this@R|/Generic|.R|FakeOverride</Generic.x: R|T|>|
^foo this@R|/Generic|.R|/Generic.x|
}
}
@@ -13,7 +13,7 @@ FILE: genericConstructors.kt
super<R|kotlin/Any|>()
}
public final val myE: R|E| = this@R|/B|.R|FakeOverride</B.id: R|E|>|(R|<local>/e|)
public final val myE: R|E| = this@R|/B|.R|/B.id|(R|<local>/e|)
public get(): R|E|
public final val a: R|A<E>| = R|/A.A|<R|E|>(R|<local>/e|)
+1 -1
View File
@@ -9,7 +9,7 @@ FILE: problems2.kt
}
public final fun intern(obj: R|T|): R|kotlin/Int?| {
^intern this@R|/Interner|.R|FakeOverride</Interner.find: R|kotlin/Int?|>|(R|<local>/obj|)
^intern this@R|/Interner|.R|/Interner.find|(R|<local>/obj|)
}
}
@@ -14,7 +14,7 @@ FILE: hashTableWithForEach.kt
when () {
R|/DEBUG| -> {
^ Q|java/util/Collections|.R|java/util/Collections.unmodifiableSet|<R|ft<kotlin/collections/MutableMap.MutableEntry<K, V>, kotlin/collections/MutableMap.MutableEntry<K, V>?>!|>(R|kotlin/collections/mutableSetOf|<R|kotlin/collections/MutableMap.MutableEntry<K, V>|>().R|kotlin/apply|<R|kotlin/collections/MutableSet<kotlin/collections/MutableMap.MutableEntry<K, V>>|>(<L> = apply@fun R|kotlin/collections/MutableSet<kotlin/collections/MutableMap.MutableEntry<K, V>>|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
this@R|/SomeHashTable|.R|FakeOverride</SomeHashTable.forEach: R|kotlin/Unit|>|(<L> = forEach@fun <anonymous>(key: R|K|, value: R|V|): R|kotlin/Unit| {
this@R|/SomeHashTable|.R|/SomeHashTable.forEach|(<L> = forEach@fun <anonymous>(key: R|K|, value: R|V|): R|kotlin/Unit| {
^ this@R|special/anonymous|.R|FakeOverride<kotlin/collections/MutableSet.add: R|kotlin/Boolean|>|(R|/SomeHashTable.Entry.Entry|<R|K|, R|V|>(R|<local>/key|, R|<local>/value|))
}
)
@@ -6,14 +6,14 @@ FILE: User.kt
super<R|kotlin/Any|>()
}
private final var settings: R|T| = this@R|/User|.R|FakeOverride</User.createSettings: R|T|>|()
private final var settings: R|T| = this@R|/User|.R|/User.createSettings|()
private get(): R|T|
private set(value: R|T|): R|kotlin/Unit|
protected abstract fun createSettings(): R|T|
public final fun foo(): R|kotlin/Unit| {
this@R|/User|.R|FakeOverride</User.settings: R|T|>| = Q|StaticOwner|.R|/StaticOwner.newInstance|<R|ft<T, T?>!|>(this@R|/User|.R|FakeOverride</User.settings: R|T|>|.R|kotlin/jvm/javaClass|)
this@R|/User|.R|/User.settings| = Q|StaticOwner|.R|/StaticOwner.newInstance|<R|ft<T, T?>!|>(this@R|/User|.R|/User.settings|.R|kotlin/jvm/javaClass|)
}
}
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun t1 () {
val a1 = arrayOfNulls<String>(1)
a1[0] = "0" //ok
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class A<in I>(init_o: I, private val init_k: I) {
private val o: I = init_o
private fun k(): I = init_k