diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirTypeResolverImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirTypeResolverImpl.kt index 5906056e97d..fd7a9535c20 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirTypeResolverImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirTypeResolverImpl.kt @@ -117,7 +117,10 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver { is FirImplicitBuiltinTypeRef -> { resolveToSymbol(typeRef, scope, position)!!.constructType(emptyList(), isNullable = false) } - is FirDynamicTypeRef, is FirDelegatedTypeRef -> { + is FirDelegatedTypeRef -> { + resolveType(typeRef.typeRef, scope, position) + } + is FirDynamicTypeRef -> { ConeKotlinErrorType("Not supported: ${typeRef::class.simpleName}") } else -> error("!") diff --git a/compiler/fir/resolve/testData/resolve/delegatedSuperType.kt b/compiler/fir/resolve/testData/resolve/delegatedSuperType.kt new file mode 100644 index 00000000000..35b8e7b5702 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/delegatedSuperType.kt @@ -0,0 +1,9 @@ +interface A { + fun foo() +} + +class B : A { + override fun foo() {} +} + +class C(val b: B) : A by b \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/delegatedSuperType.txt b/compiler/fir/resolve/testData/resolve/delegatedSuperType.txt new file mode 100644 index 00000000000..80a6354a6ae --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/delegatedSuperType.txt @@ -0,0 +1,23 @@ +FILE: delegatedSuperType.kt + public abstract interface A : R|kotlin/Any| { + public abstract fun foo(): R|kotlin/Unit| + + } + public final class B : R|A| { + public constructor(): R|B| { + super() + } + + public final override fun foo(): R|kotlin/Unit| { + } + + } + public final class C : R|A| { + public constructor(b: R|B|): R|C| { + super() + } + + public final val b: R|B| = R|/b| + public get(): R|B| + + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java index 5efc03531f4..4bbc21e6036 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java @@ -44,6 +44,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase { runTest("compiler/fir/resolve/testData/resolve/copy.kt"); } + @TestMetadata("delegatedSuperType.kt") + public void testDelegatedSuperType() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/delegatedSuperType.kt"); + } + @TestMetadata("derivedClass.kt") public void testDerivedClass() throws Exception { runTest("compiler/fir/resolve/testData/resolve/derivedClass.kt"); diff --git a/compiler/testData/ir/irText/classes/delegatedImplementation.fir.txt b/compiler/testData/ir/irText/classes/delegatedImplementation.fir.txt index a01dfe9d2fa..047199e9e72 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementation.fir.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementation.fir.txt @@ -157,15 +157,71 @@ FILE fqName: fileName:/delegatedImplementation.kt VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY CONSTRUCTOR_CALL 'private constructor () [primary] declared in .otherImpl.' type=.otherImpl. origin=null - CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[] + CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[.IBase] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test1 CONSTRUCTOR visibility:public <> () returnType:.Test1 [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[]' - CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[] + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[.IBase]' + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IBase, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit + overridden: + public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in .IBase + $this: VALUE_PARAMETER name: type:.IBase + VALUE_PARAMETER name:x index:0 type:kotlin.Int + VALUE_PARAMETER name:s index:1 type:kotlin.String + FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:.IBase) returnType:kotlin.Int + overridden: + public abstract fun bar (): kotlin.Int declared in .IBase + $this: VALUE_PARAMETER name: type:.IBase + FUN FAKE_OVERRIDE name:qux visibility:public modality:ABSTRACT <> ($this:.IBase, $receiver:kotlin.String) returnType:kotlin.Unit + overridden: + public abstract fun qux (): kotlin.Unit declared in .IBase + $this: VALUE_PARAMETER name: type:.IBase + $receiver: VALUE_PARAMETER name: type:kotlin.String + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.IBase; .IOther] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test2 CONSTRUCTOR visibility:public <> () returnType:.Test2 [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[]' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.IBase; .IOther]' + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IBase, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit + overridden: + public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in .IBase + $this: VALUE_PARAMETER name: type:.IBase + VALUE_PARAMETER name:x index:0 type:kotlin.Int + VALUE_PARAMETER name:s index:1 type:kotlin.String + FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:.IBase) returnType:kotlin.Int + overridden: + public abstract fun bar (): kotlin.Int declared in .IBase + $this: VALUE_PARAMETER name: type:.IBase + FUN FAKE_OVERRIDE name:qux visibility:public modality:ABSTRACT <> ($this:.IBase, $receiver:kotlin.String) returnType:kotlin.Unit + overridden: + public abstract fun qux (): kotlin.Unit declared in .IBase + $this: VALUE_PARAMETER name: type:.IBase + $receiver: VALUE_PARAMETER name: type:kotlin.String + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.txt b/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.txt index 863ba4cf395..aa68c390f33 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.txt @@ -43,12 +43,29 @@ FILE fqName: fileName:/delegatedImplementationWithExplicitOverride.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:C modality:FINAL visibility:public superTypes:[] + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.IFooBar] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C CONSTRUCTOR visibility:public <> () returnType:.C [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[]' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.IFooBar]' FUN name:bar visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.C BLOCK_BODY + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFooBar) returnType:kotlin.Unit + overridden: + public abstract fun foo (): kotlin.Unit declared in .IFooBar + $this: VALUE_PARAMETER name: type:.IFooBar + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.txt b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.txt index 4c29fc71ed3..85e3224c614 100644 --- a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.txt +++ b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.txt @@ -27,11 +27,35 @@ FILE fqName: fileName:/delegatedMembers.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[] + CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.IBase.Test>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test TYPE_PARAMETER name:TT index:0 variance: superTypes:[] CONSTRUCTOR visibility:public <> (impl:.IBase>) returnType:.Test> [primary] VALUE_PARAMETER name:impl index:0 type:.IBase> BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[]' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.IBase.Test>]' + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IBase, x:kotlin.Int) returnType:kotlin.Unit + overridden: + public abstract fun foo (x: kotlin.Int): kotlin.Unit declared in .IBase + $this: VALUE_PARAMETER name: type:.IBase + VALUE_PARAMETER name:x index:0 type:kotlin.Int + FUN FAKE_OVERRIDE name:qux visibility:public modality:ABSTRACT <> ($this:.IBase, t:TT of .Test, x:X of .IBase.qux) returnType:kotlin.Unit + overridden: + public abstract fun qux (t: T of .IBase, x: X of .IBase.qux): kotlin.Unit declared in .IBase + $this: VALUE_PARAMETER name: type:.IBase + VALUE_PARAMETER name:t index:0 type:TT of .Test + VALUE_PARAMETER name:x index:1 type:X of .IBase.qux + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any