FIR substitution: do not create fake overrides if types aren't changed
This commit is contained in:
+8
@@ -80,6 +80,10 @@ class FirClassSubstitutionScope(
|
||||
it.returnTypeRef.coneTypeUnsafe<ConeKotlinType>().substitute()
|
||||
}
|
||||
|
||||
if (newReceiverType == null && newReturnType == null && newParameterTypes.all { it == null }) {
|
||||
return original
|
||||
}
|
||||
|
||||
return createFakeOverrideFunction(session, member, original, newReceiverType, newReturnType, newParameterTypes)
|
||||
}
|
||||
|
||||
@@ -92,6 +96,10 @@ class FirClassSubstitutionScope(
|
||||
val returnType = typeCalculator.tryCalculateReturnType(member).type
|
||||
val newReturnType = returnType.substitute()
|
||||
|
||||
if (newReceiverType == null && newReturnType == null) {
|
||||
return original
|
||||
}
|
||||
|
||||
return createFakeOverrideProperty(session, member, original, newReceiverType, newReturnType)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ digraph loops_kt {
|
||||
color=blue
|
||||
46 [label="Enter loop condition"];
|
||||
47 [label="Access variable R|<local>/<iterator>|"];
|
||||
48 [label="Function call: R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()"];
|
||||
48 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()"];
|
||||
49 [label="Exit loop condition"];
|
||||
}
|
||||
subgraph cluster_16 {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ FILE: loops.kt
|
||||
public final fun testFor(x: R|kotlin/Any?|): R|kotlin/Unit| {
|
||||
lval <range>: R|kotlin/ranges/IntRange| = Int(0).R|kotlin/Int.rangeTo|(Int(5))
|
||||
lval <iterator>: R|kotlin/collections/IntIterator| = R|<local>/<range>|.R|kotlin/ranges/IntProgression.iterator|()
|
||||
while(R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()) {
|
||||
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
|
||||
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
|
||||
lval y: R|kotlin/Boolean| = (R|<local>/x| is R|kotlin/String|)
|
||||
}
|
||||
|
||||
@@ -30,6 +30,6 @@ FILE: importedReceiver.kt
|
||||
(this@R|/My|, String()).R|/My.bar|<R|kotlin/String|>()
|
||||
this@R|/My|.R|/My.baz|()
|
||||
(this@R|/My|, Boolean(true)).R|/My.gau|()
|
||||
this@R|/Your|.R|FakeOverride</Your.wat: R|kotlin/Unit|>|()
|
||||
Boolean(false).<Inapplicable(WRONG_RECEIVER): [/Your.watwat]>#()
|
||||
this@R|/Your|.R|/Your.wat|()
|
||||
(this@R|/Your|, Boolean(false)).R|/Your.watwat|<R|kotlin/Boolean|>()
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ FILE: fib.kt
|
||||
lvar prev: R|kotlin/Int| = Int(1)
|
||||
lval <range>: R|kotlin/ranges/IntRange| = Int(2).R|kotlin/Int.rangeTo|(R|<local>/n|)
|
||||
lval <iterator>: R|kotlin/collections/IntIterator| = R|<local>/<range>|.R|kotlin/ranges/IntProgression.iterator|()
|
||||
while(R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()) {
|
||||
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
|
||||
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
|
||||
lval temp: R|kotlin/Int| = R|<local>/current|
|
||||
R|<local>/current| += R|<local>/prev|
|
||||
|
||||
@@ -25,7 +25,7 @@ FILE: components.kt
|
||||
public final fun foo(list: R|kotlin/collections/List<D>|): R|kotlin/Unit| {
|
||||
lval <range>: R|kotlin/collections/List<D>| = R|<local>/list|
|
||||
lval <iterator>: R|kotlin/collections/Iterator<D>| = R|<local>/<range>|.R|FakeOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<D>|>|()
|
||||
while(R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()) {
|
||||
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
|
||||
lval <destruct>: R|D| = R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.next: R|D|>|()
|
||||
lval x: R|kotlin/Int| = R|<local>/<destruct>|.R|/D.component1|()
|
||||
lval y: R|kotlin/String| = R|<local>/<destruct>|.R|/D.component2|()
|
||||
|
||||
@@ -45,7 +45,7 @@ FILE fqName:<root> fileName:/callableRefToGenericMember.kt
|
||||
PROPERTY name:test2 visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Int visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
PROPERTY_REFERENCE 'public final bar: kotlin.Int [val]' field=null getter='public final fun <get-bar> (): kotlin.Int declared in <root>.A' setter=null type=kotlin.Int origin=null
|
||||
PROPERTY_REFERENCE 'public final bar: kotlin.Int [val]' field='FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.Int visibility:private [final]' getter='public final fun <get-bar> (): kotlin.Int declared in <root>.A' setter=null type=kotlin.Int origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test2> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
|
||||
@@ -68,7 +68,7 @@ FILE fqName:<root> fileName:/genericPropertyRef.kt
|
||||
FIELD DELEGATE name:additionalText$delegate type:<root>.DVal visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (kmember: kotlin.Any) [primary] declared in <root>.DVal' type=<root>.DVal origin=null
|
||||
kmember: PROPERTY_REFERENCE 'public final text: kotlin.String? [var]' field=null getter='public final fun <get-text> (): kotlin.String? declared in <root>.Value' setter='public final fun <set-text> (<set-?>: kotlin.String?): kotlin.Unit declared in <root>.Value' type=kotlin.String? origin=null
|
||||
kmember: PROPERTY_REFERENCE 'public final text: kotlin.String? [var]' field='FIELD PROPERTY_BACKING_FIELD name:text type:kotlin.String? visibility:private' getter='public final fun <get-text> (): kotlin.String? declared in <root>.Value' setter='public final fun <set-text> (<set-?>: kotlin.String?): kotlin.Unit declared in <root>.Value' type=kotlin.String? origin=null
|
||||
FUN DELEGATED_PROPERTY_ACCESSOR name:<get-additionalText> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:additionalText visibility:public modality:FINAL [delegated,val]
|
||||
BLOCK_BODY
|
||||
|
||||
@@ -232,7 +232,9 @@ FILE fqName:<root> fileName:/useImportedMember.kt
|
||||
BRANCH
|
||||
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: ERROR_CALL 'Unresolved reference: <Inapplicable(WRONG_RECEIVER): [/I.fromInterface]>#' type=IrErrorType
|
||||
arg0: CALL 'public open fun fromInterface <T> (): T of <root>.I.fromInterface declared in <root>.I' type=kotlin.Int origin=null
|
||||
<T>: <none>
|
||||
$this: GET_VAR '<this>: <root>.I declared in <root>.I' type=<root>.I<*> origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=9
|
||||
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="9"
|
||||
|
||||
Reference in New Issue
Block a user