diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt index 8f393317aa8..e5c1ca73679 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt @@ -80,6 +80,10 @@ class FirClassSubstitutionScope( it.returnTypeRef.coneTypeUnsafe().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) } diff --git a/compiler/fir/resolve/testData/resolve/cfg/loops.dot b/compiler/fir/resolve/testData/resolve/cfg/loops.dot index c71ec874429..8edeb76de3c 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/loops.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/loops.dot @@ -133,7 +133,7 @@ digraph loops_kt { color=blue 46 [label="Enter loop condition"]; 47 [label="Access variable R|/|"]; - 48 [label="Function call: R|/|.R|FakeOverride|()"]; + 48 [label="Function call: R|/|.R|kotlin/collections/Iterator.hasNext|()"]; 49 [label="Exit loop condition"]; } subgraph cluster_16 { diff --git a/compiler/fir/resolve/testData/resolve/cfg/loops.txt b/compiler/fir/resolve/testData/resolve/cfg/loops.txt index f60a2790fef..728fbfcbe8f 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/loops.txt +++ b/compiler/fir/resolve/testData/resolve/cfg/loops.txt @@ -16,7 +16,7 @@ FILE: loops.kt public final fun testFor(x: R|kotlin/Any?|): R|kotlin/Unit| { lval : R|kotlin/ranges/IntRange| = Int(0).R|kotlin/Int.rangeTo|(Int(5)) lval : R|kotlin/collections/IntIterator| = R|/|.R|kotlin/ranges/IntProgression.iterator|() - while(R|/|.R|FakeOverride|()) { + while(R|/|.R|kotlin/collections/Iterator.hasNext|()) { lval i: R|kotlin/Int| = R|/|.R|kotlin/collections/IntIterator.next|() lval y: R|kotlin/Boolean| = (R|/x| is R|kotlin/String|) } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/importedReceiver.txt b/compiler/fir/resolve/testData/resolve/expresssions/importedReceiver.txt index 474de0c8a06..aeaad1fbb50 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/importedReceiver.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/importedReceiver.txt @@ -30,6 +30,6 @@ FILE: importedReceiver.kt (this@R|/My|, String()).R|/My.bar|() this@R|/My|.R|/My.baz|() (this@R|/My|, Boolean(true)).R|/My.gau|() - this@R|/Your|.R|FakeOverride|() - Boolean(false).#() + this@R|/Your|.R|/Your.wat|() + (this@R|/Your|, Boolean(false)).R|/Your.watwat|() } diff --git a/compiler/fir/resolve/testData/resolve/fib.txt b/compiler/fir/resolve/testData/resolve/fib.txt index be7cde8c29f..91a5581c3ef 100644 --- a/compiler/fir/resolve/testData/resolve/fib.txt +++ b/compiler/fir/resolve/testData/resolve/fib.txt @@ -12,7 +12,7 @@ FILE: fib.kt lvar prev: R|kotlin/Int| = Int(1) lval : R|kotlin/ranges/IntRange| = Int(2).R|kotlin/Int.rangeTo|(R|/n|) lval : R|kotlin/collections/IntIterator| = R|/|.R|kotlin/ranges/IntProgression.iterator|() - while(R|/|.R|FakeOverride|()) { + while(R|/|.R|kotlin/collections/Iterator.hasNext|()) { lval i: R|kotlin/Int| = R|/|.R|kotlin/collections/IntIterator.next|() lval temp: R|kotlin/Int| = R|/current| R|/current| += R|/prev| diff --git a/compiler/fir/resolve/testData/resolve/stdlib/components.txt b/compiler/fir/resolve/testData/resolve/stdlib/components.txt index e2d0effd69a..1229c329e24 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/components.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/components.txt @@ -25,7 +25,7 @@ FILE: components.kt public final fun foo(list: R|kotlin/collections/List|): R|kotlin/Unit| { lval : R|kotlin/collections/List| = R|/list| lval : R|kotlin/collections/Iterator| = R|/|.R|FakeOverride|>|() - while(R|/|.R|FakeOverride|()) { + while(R|/|.R|kotlin/collections/Iterator.hasNext|()) { lval : R|D| = R|/|.R|FakeOverride|() lval x: R|kotlin/Int| = R|/|.R|/D.component1|() lval y: R|kotlin/String| = R|/|.R|/D.component2|() diff --git a/compiler/testData/ir/irText/expressions/callableRefToGenericMember.fir.txt b/compiler/testData/ir/irText/expressions/callableRefToGenericMember.fir.txt index 8cc621ade56..7782fe24b3f 100644 --- a/compiler/testData/ir/irText/expressions/callableRefToGenericMember.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableRefToGenericMember.fir.txt @@ -45,7 +45,7 @@ FILE fqName: 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 (): kotlin.Int declared in .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 (): kotlin.Int declared in .A' setter=null type=kotlin.Int origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/genericPropertyRef.fir.txt b/compiler/testData/ir/irText/expressions/genericPropertyRef.fir.txt index 15513f5c8d0..5cd8547ed63 100644 --- a/compiler/testData/ir/irText/expressions/genericPropertyRef.fir.txt +++ b/compiler/testData/ir/irText/expressions/genericPropertyRef.fir.txt @@ -68,7 +68,7 @@ FILE fqName: fileName:/genericPropertyRef.kt FIELD DELEGATE name:additionalText$delegate type:.DVal visibility:private [final,static] EXPRESSION_BODY CONSTRUCTOR_CALL 'public constructor (kmember: kotlin.Any) [primary] declared in .DVal' type=.DVal origin=null - kmember: PROPERTY_REFERENCE 'public final text: kotlin.String? [var]' field=null getter='public final fun (): kotlin.String? declared in .Value' setter='public final fun (: kotlin.String?): kotlin.Unit declared in .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 (): kotlin.String? declared in .Value' setter='public final fun (: kotlin.String?): kotlin.Unit declared in .Value' type=kotlin.String? origin=null FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:additionalText visibility:public modality:FINAL [delegated,val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt b/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt index 3bf5638a1de..40d196c57f4 100644 --- a/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt +++ b/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt @@ -232,7 +232,9 @@ FILE fqName: 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: #' type=IrErrorType + arg0: CALL 'public open fun fromInterface (): T of .I.fromInterface declared in .I' type=kotlin.Int origin=null + : + $this: GET_VAR ': .I declared in .I' type=.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 ' CONST String type=kotlin.String value="9"