From 85c1505689f67b16089e70b152c45dfd2e2cb8c6 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 19 Aug 2020 13:26:01 +0300 Subject: [PATCH] [FIR2IR] Copy type parameters for trivial fake overrides --- .../kotlin/fir/Fir2IrTextTestGenerated.java | 5 + .../scopes/impl/FirClassSubstitutionScope.kt | 152 ++++++++++-------- .../nonNullableTypeParameter.kt | 1 - .../typeParameterBoundedBySubclass.fir.txt | 5 +- .../irText/firProblems/BaseFirBuilder.fir.txt | 29 ++++ .../ir/irText/firProblems/BaseFirBuilder.txt | 29 ++++ .../ir/irText/firProblems/FirBuilder.fir.txt | 52 ++++++ .../ir/irText/firProblems/FirBuilder.kt | 15 ++ .../ir/irText/firProblems/FirBuilder.txt | 52 ++++++ .../kotlin/ir/IrTextTestCaseGenerated.java | 5 + 10 files changed, 274 insertions(+), 71 deletions(-) create mode 100644 compiler/testData/ir/irText/firProblems/BaseFirBuilder.fir.txt create mode 100644 compiler/testData/ir/irText/firProblems/BaseFirBuilder.txt create mode 100644 compiler/testData/ir/irText/firProblems/FirBuilder.fir.txt create mode 100644 compiler/testData/ir/irText/firProblems/FirBuilder.kt create mode 100644 compiler/testData/ir/irText/firProblems/FirBuilder.txt diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index 7b7b1a0e1a8..fe62f134a11 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1711,6 +1711,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { public void testDeprecated() throws Exception { runTest("compiler/testData/ir/irText/firProblems/deprecated.kt"); } + + @TestMetadata("FirBuilder.kt") + public void testFirBuilder() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/FirBuilder.kt"); + } } @TestMetadata("compiler/testData/ir/irText/lambdas") 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 3709ac530d9..0ead7b8db28 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 @@ -217,7 +217,7 @@ class FirClassSubstitutionScope( private fun createSubstitutedData(member: FirCallableMemberDeclaration<*>): SubstitutedData { val (newTypeParameters, substitutor) = createNewTypeParametersAndSubstitutor( - member as FirTypeParameterRefsOwner + member as FirTypeParameterRefsOwner, substitutor ) val receiverType = member.receiverTypeRef?.coneType @@ -228,58 +228,6 @@ class FirClassSubstitutionScope( return SubstitutedData(newTypeParameters, newReceiverType, newReturnType, substitutor) } - // Returns a list of type parameters, and a substitutor that should be used for all other types - private fun createNewTypeParametersAndSubstitutor( - member: FirTypeParameterRefsOwner - ): Pair, ConeSubstitutor> { - if (member.typeParameters.isEmpty()) return Pair(member.typeParameters, substitutor) - val newTypeParameters = member.typeParameters.map { typeParameter -> - if (typeParameter !is FirTypeParameter) return@map null - FirTypeParameterBuilder().apply { - source = typeParameter.source - session = typeParameter.session - origin = FirDeclarationOrigin.FakeOverride - name = typeParameter.name - symbol = FirTypeParameterSymbol() - variance = typeParameter.variance - isReified = typeParameter.isReified - annotations += typeParameter.annotations - } - } - - val substitutionMapForNewParameters = member.typeParameters.zip(newTypeParameters).mapNotNull { (original, new) -> - if (new != null) - Pair(original.symbol, ConeTypeParameterTypeImpl(new.symbol.toLookupTag(), isNullable = false)) - else null - }.toMap() - - val additionalSubstitutor = substitutorByMap(substitutionMapForNewParameters) - - for ((newTypeParameter, oldTypeParameter) in newTypeParameters.zip(member.typeParameters)) { - if (newTypeParameter == null) continue - val original = oldTypeParameter as FirTypeParameter - for (boundTypeRef in original.bounds) { - val typeForBound = boundTypeRef.coneType - val substitutedBound = typeForBound.substitute() - newTypeParameter.bounds += - buildResolvedTypeRef { - source = boundTypeRef.source - type = additionalSubstitutor.substituteOrSelf(substitutedBound ?: typeForBound) - } - } - } - - // TODO: Uncomment when problem from org.jetbrains.kotlin.fir.Fir2IrTextTestGenerated.Declarations.Parameters.testDelegatedMembers is gone - // The problem is that Fir2Ir thinks that type parameters in fake override are the same as for original - // While common Ir contracts expect them to be different - // if (!wereChangesInTypeParameters) return Pair(member.typeParameters, substitutor) - - return Pair( - newTypeParameters.mapIndexed { index, builder -> builder?.build() ?: member.typeParameters[index] }, - ChainedSubstitutor(substitutor, additionalSubstitutor) - ) - } - private fun createFakeOverrideField(original: FirFieldSymbol): FirFieldSymbol { if (substitutor == ConeSubstitutor.Empty) return original val member = original.fir @@ -336,6 +284,34 @@ class FirClassSubstitutionScope( } } + private fun FirFunctionBuilder.configureAnnotationsAndAllParameters( + session: FirSession, + baseFunction: FirFunction<*>, + newParameterTypes: List?, + newTypeParameters: List? + ): List { + return when { + baseFunction.typeParameters.isEmpty() -> { + configureAnnotationsAndParameters(session, baseFunction, newParameterTypes) + emptyList() + } + newTypeParameters == null -> { + val (copiedTypeParameters, substitutor) = createNewTypeParametersAndSubstitutor( + baseFunction, ConeSubstitutor.Empty + ) + val copiedParameterTypes = baseFunction.valueParameters.map { + substitutor.substituteOrNull(it.returnTypeRef.coneType) + } + configureAnnotationsAndParameters(session, baseFunction, copiedParameterTypes) + copiedTypeParameters + } + else -> { + configureAnnotationsAndParameters(session, baseFunction, newParameterTypes) + newTypeParameters + } + } + } + private fun FirDeclarationStatus.withExpect(isExpect: Boolean): FirDeclarationStatus { return if (this.isExpect == isExpect) { this @@ -368,15 +344,10 @@ class FirClassSubstitutionScope( status = baseFunction.status.withExpect(isExpect) symbol = fakeOverrideSymbol resolvePhase = baseFunction.resolvePhase - configureAnnotationsAndParameters(session, baseFunction, newParameterTypes) - // TODO: Fix the hack for org.jetbrains.kotlin.fir.backend.Fir2IrVisitor.addFakeOverrides - // We might have added baseFunction.typeParameters in case new ones are null - // But it fails at org.jetbrains.kotlin.ir.AbstractIrTextTestCase.IrVerifier.elementsAreUniqueChecker - // because it shares the same declarations of type parameters between two different two functions - if (newTypeParameters != null) { - typeParameters += newTypeParameters - } + typeParameters += configureAnnotationsAndAllParameters( + session, baseFunction, newParameterTypes, newTypeParameters + ).filterIsInstance() } } @@ -500,16 +471,61 @@ class FirClassSubstitutionScope( status = baseConstructor.status.withExpect(isExpect) symbol = fakeOverrideSymbol resolvePhase = baseConstructor.resolvePhase - configureAnnotationsAndParameters(session, baseConstructor, newParameterTypes) - // TODO: Fix the hack for org.jetbrains.kotlin.fir.backend.Fir2IrVisitor.addFakeOverrides - // We might have added baseFunction.typeParameters in case new ones are null - // But it fails at org.jetbrains.kotlin.ir.AbstractIrTextTestCase.IrVerifier.elementsAreUniqueChecker - // because it shares the same declarations of type parameters between two different two functions - if (newTypeParameters != null) { - typeParameters += newTypeParameters + typeParameters += configureAnnotationsAndAllParameters(session, baseConstructor, newParameterTypes, newTypeParameters) + } + } + + // Returns a list of type parameters, and a substitutor that should be used for all other types + private fun createNewTypeParametersAndSubstitutor( + member: FirTypeParameterRefsOwner, substitutor: ConeSubstitutor + ): Pair, ConeSubstitutor> { + if (member.typeParameters.isEmpty()) return Pair(member.typeParameters, substitutor) + val newTypeParameters = member.typeParameters.map { typeParameter -> + if (typeParameter !is FirTypeParameter) return@map null + FirTypeParameterBuilder().apply { + source = typeParameter.source + session = typeParameter.session + origin = FirDeclarationOrigin.FakeOverride + name = typeParameter.name + symbol = FirTypeParameterSymbol() + variance = typeParameter.variance + isReified = typeParameter.isReified + annotations += typeParameter.annotations } } + + val substitutionMapForNewParameters = member.typeParameters.zip(newTypeParameters).mapNotNull { (original, new) -> + if (new != null) + Pair(original.symbol, ConeTypeParameterTypeImpl(new.symbol.toLookupTag(), isNullable = false)) + else null + }.toMap() + + val additionalSubstitutor = substitutorByMap(substitutionMapForNewParameters) + + for ((newTypeParameter, oldTypeParameter) in newTypeParameters.zip(member.typeParameters)) { + if (newTypeParameter == null) continue + val original = oldTypeParameter as FirTypeParameter + for (boundTypeRef in original.bounds) { + val typeForBound = boundTypeRef.coneType + val substitutedBound = substitutor.substituteOrNull(typeForBound) + newTypeParameter.bounds += + buildResolvedTypeRef { + source = boundTypeRef.source + type = additionalSubstitutor.substituteOrSelf(substitutedBound ?: typeForBound) + } + } + } + + // TODO: Uncomment when problem from org.jetbrains.kotlin.fir.Fir2IrTextTestGenerated.Declarations.Parameters.testDelegatedMembers is gone + // The problem is that Fir2Ir thinks that type parameters in fake override are the same as for original + // While common Ir contracts expect them to be different + // if (!wereChangesInTypeParameters) return Pair(member.typeParameters, substitutor) + + return Pair( + newTypeParameters.mapIndexed { index, builder -> builder?.build() ?: member.typeParameters[index] }, + ChainedSubstitutor(substitutor, additionalSubstitutor) + ) } } diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/nonNullableTypeParameter.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nonNullableTypeParameter.kt index 147e938867b..becbae4233c 100644 --- a/compiler/testData/codegen/box/javaInterop/notNullAssertions/nonNullableTypeParameter.kt +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nonNullableTypeParameter.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // FILE: a.kt interface I { diff --git a/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.fir.txt b/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.fir.txt index cf72949e9cd..a64a5960d4f 100644 --- a/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.fir.txt +++ b/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.fir.txt @@ -69,11 +69,12 @@ FILE fqName: fileName:/typeParameterBoundedBySubclass.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base2' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived2 modality:FINAL visibility:public superTypes:[.Base2]' - FUN FAKE_OVERRIDE name:foo visibility:public modality:FINAL <> ($this:.Base2, x:T of .Base2.foo) returnType:kotlin.Unit [fake_override] + FUN FAKE_OVERRIDE name:foo visibility:public modality:FINAL ($this:.Base2, x:T of .Derived2.foo) returnType:kotlin.Unit [fake_override] overridden: public final fun foo (x: T of .Base2.foo): kotlin.Unit declared in .Base2 + TYPE_PARAMETER name:T index:0 variance: superTypes:[.Derived2] $this: VALUE_PARAMETER name: type:.Base2 - VALUE_PARAMETER name:x index:0 type:T of .Base2.foo + VALUE_PARAMETER name:x index:0 type:T of .Derived2.foo FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/BaseFirBuilder.fir.txt b/compiler/testData/ir/irText/firProblems/BaseFirBuilder.fir.txt new file mode 100644 index 00000000000..4e682908055 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/BaseFirBuilder.fir.txt @@ -0,0 +1,29 @@ +FILE fqName: fileName:/BaseFirBuilder.kt + CLASS CLASS name:BaseFirBuilder modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.BaseFirBuilder.BaseFirBuilder> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> () returnType:.BaseFirBuilder.BaseFirBuilder> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:BaseFirBuilder modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' + FUN name:withCapturedTypeParameters visibility:public modality:FINAL ($this:.BaseFirBuilder.BaseFirBuilder>, block:kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters>) returnType:T of .BaseFirBuilder.withCapturedTypeParameters [inline] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.BaseFirBuilder.BaseFirBuilder> + VALUE_PARAMETER name:block index:0 type:kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun withCapturedTypeParameters (block: kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters>): T of .BaseFirBuilder.withCapturedTypeParameters [inline] declared in .BaseFirBuilder' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .BaseFirBuilder.withCapturedTypeParameters origin=INVOKE + $this: GET_VAR 'block: kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters> declared in .BaseFirBuilder.withCapturedTypeParameters' type=kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters> origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] 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 [fake_override] + 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 [fake_override] + 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/firProblems/BaseFirBuilder.txt b/compiler/testData/ir/irText/firProblems/BaseFirBuilder.txt new file mode 100644 index 00000000000..9d8c529a33b --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/BaseFirBuilder.txt @@ -0,0 +1,29 @@ +FILE fqName: fileName:/BaseFirBuilder.kt + CLASS CLASS name:BaseFirBuilder modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.BaseFirBuilder.BaseFirBuilder> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> () returnType:.BaseFirBuilder.BaseFirBuilder> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:BaseFirBuilder modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' + FUN name:withCapturedTypeParameters visibility:public modality:FINAL ($this:.BaseFirBuilder.BaseFirBuilder>, block:kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters>) returnType:T of .BaseFirBuilder.withCapturedTypeParameters [inline] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.BaseFirBuilder.BaseFirBuilder> + VALUE_PARAMETER name:block index:0 type:kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun withCapturedTypeParameters (block: kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters>): T of .BaseFirBuilder.withCapturedTypeParameters [inline] declared in .BaseFirBuilder' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .BaseFirBuilder.withCapturedTypeParameters origin=INVOKE + $this: GET_VAR 'block: kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters> declared in .BaseFirBuilder.withCapturedTypeParameters' type=kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters> origin=VARIABLE_AS_FUNCTION + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] 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 [fake_override] + 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 [fake_override] + 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/firProblems/FirBuilder.fir.txt b/compiler/testData/ir/irText/firProblems/FirBuilder.fir.txt new file mode 100644 index 00000000000..599b48151ce --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/FirBuilder.fir.txt @@ -0,0 +1,52 @@ +FILE fqName: fileName:/FirBuilder.kt + CLASS CLASS name:BaseConverter modality:OPEN visibility:public superTypes:[.BaseFirBuilder] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.BaseConverter + CONSTRUCTOR visibility:public <> () returnType:.BaseConverter [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .BaseFirBuilder' + : kotlin.Any + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:BaseConverter modality:OPEN visibility:public superTypes:[.BaseFirBuilder]' + FUN FAKE_OVERRIDE name:withCapturedTypeParameters visibility:public modality:FINAL ($this:.BaseFirBuilder.BaseFirBuilder>, block:kotlin.Function0.BaseConverter.withCapturedTypeParameters>) returnType:T of .BaseConverter.withCapturedTypeParameters [inline,fake_override] + overridden: + public final fun withCapturedTypeParameters (block: kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters>): T of .BaseFirBuilder.withCapturedTypeParameters [inline] declared in .BaseFirBuilder + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.BaseFirBuilder.BaseFirBuilder> + VALUE_PARAMETER name:block index:0 type:kotlin.Function0.BaseConverter.withCapturedTypeParameters> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] 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 [fake_override] + 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 [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:DeclarationsConverter modality:FINAL visibility:public superTypes:[.BaseConverter] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DeclarationsConverter + CONSTRUCTOR visibility:public <> () returnType:.DeclarationsConverter [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .BaseConverter' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DeclarationsConverter modality:FINAL visibility:public superTypes:[.BaseConverter]' + FUN FAKE_OVERRIDE name:withCapturedTypeParameters visibility:public modality:FINAL ($this:.BaseConverter, block:kotlin.Function0.DeclarationsConverter.withCapturedTypeParameters>) returnType:T of .BaseConverter.withCapturedTypeParameters [inline,fake_override] + overridden: + public final fun withCapturedTypeParameters (block: kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters>): T of .BaseFirBuilder.withCapturedTypeParameters [inline] declared in .BaseFirBuilder + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.BaseConverter + VALUE_PARAMETER name:block index:0 type:kotlin.Function0.DeclarationsConverter.withCapturedTypeParameters> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] 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 [fake_override] + 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 [fake_override] + 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/firProblems/FirBuilder.kt b/compiler/testData/ir/irText/firProblems/FirBuilder.kt new file mode 100644 index 00000000000..64099956b25 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/FirBuilder.kt @@ -0,0 +1,15 @@ +// MODULE: m1 +// FILE: BaseFirBuilder.kt + +abstract class BaseFirBuilder { + inline fun withCapturedTypeParameters(block: () -> T): T { + return block() + } +} + +// MODULE: m2(m1) +// FILE: FirBuilder.kt + +open class BaseConverter : BaseFirBuilder() + +class DeclarationsConverter : BaseConverter() \ No newline at end of file diff --git a/compiler/testData/ir/irText/firProblems/FirBuilder.txt b/compiler/testData/ir/irText/firProblems/FirBuilder.txt new file mode 100644 index 00000000000..f71e2079911 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/FirBuilder.txt @@ -0,0 +1,52 @@ +FILE fqName: fileName:/FirBuilder.kt + CLASS CLASS name:BaseConverter modality:OPEN visibility:public superTypes:[.BaseFirBuilder] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.BaseConverter + CONSTRUCTOR visibility:public <> () returnType:.BaseConverter [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .BaseFirBuilder' + : kotlin.Any + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:BaseConverter modality:OPEN visibility:public superTypes:[.BaseFirBuilder]' + FUN FAKE_OVERRIDE name:withCapturedTypeParameters visibility:public modality:FINAL ($this:.BaseFirBuilder, block:kotlin.Function0.BaseConverter.withCapturedTypeParameters>) returnType:T of .BaseConverter.withCapturedTypeParameters [inline,fake_override] + overridden: + public final fun withCapturedTypeParameters (block: kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters>): T of .BaseFirBuilder.withCapturedTypeParameters [inline] declared in .BaseFirBuilder + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.BaseFirBuilder + VALUE_PARAMETER name:block index:0 type:kotlin.Function0.BaseConverter.withCapturedTypeParameters> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .BaseFirBuilder + $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 [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .BaseFirBuilder + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .BaseFirBuilder + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:DeclarationsConverter modality:FINAL visibility:public superTypes:[.BaseConverter] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DeclarationsConverter + CONSTRUCTOR visibility:public <> () returnType:.DeclarationsConverter [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .BaseConverter' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DeclarationsConverter modality:FINAL visibility:public superTypes:[.BaseConverter]' + FUN FAKE_OVERRIDE name:withCapturedTypeParameters visibility:public modality:FINAL ($this:.BaseFirBuilder, block:kotlin.Function0.DeclarationsConverter.withCapturedTypeParameters>) returnType:T of .DeclarationsConverter.withCapturedTypeParameters [inline,fake_override] + overridden: + public final fun withCapturedTypeParameters (block: kotlin.Function0.BaseConverter.withCapturedTypeParameters>): T of .BaseConverter.withCapturedTypeParameters [inline,fake_override] declared in .BaseConverter + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.BaseFirBuilder + VALUE_PARAMETER name:block index:0 type:kotlin.Function0.DeclarationsConverter.withCapturedTypeParameters> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .BaseConverter + $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 [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .BaseConverter + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .BaseConverter + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index bfc36cf569c..748bd2354b9 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -1710,6 +1710,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { public void testDeprecated() throws Exception { runTest("compiler/testData/ir/irText/firProblems/deprecated.kt"); } + + @TestMetadata("FirBuilder.kt") + public void testFirBuilder() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/FirBuilder.kt"); + } } @TestMetadata("compiler/testData/ir/irText/lambdas")