From 08b91da6db26ca51bf477508457c6aa940184c66 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Mon, 13 Apr 2020 10:46:04 -0700 Subject: [PATCH] FIR: fix body generation for data class's copy method --- .../testData/resolve/constantValues.txt | 3 ++ .../analysis-tests/testData/resolve/copy.txt | 1 + .../diagnostics/incompatibleModifiers.txt | 4 ++ .../testData/resolve/problems2.txt | 1 + .../testData/resolveWithStdlib/components.txt | 1 + .../kotlin/fir/builder/BaseFirBuilder.kt | 47 +++++++++++++------ .../converter/DeclarationsConverter.kt | 7 ++- .../kotlin/fir/builder/RawFirBuilder.kt | 8 ++-- .../rawBuilder/expressions/annotated.txt | 1 + .../rawBuilder/expressions/destructuring.txt | 7 +-- .../testData/rawBuilder/expressions/for.txt | 5 +- .../rawBuilder/expressions/lambda.txt | 5 +- .../testData/codegen/box/classes/kt6136.kt | 1 - .../codegen/box/dataClasses/copy/kt3033.kt | 1 - .../box/localClasses/localDataClass.kt | 1 - .../classes/dataClassWithArrayMembers.fir.txt | 29 ++++++++++++ .../ir/irText/classes/dataClasses.fir.txt | 22 +++++++++ .../irText/classes/dataClassesGeneric.fir.txt | 19 ++++++++ .../ir/irText/classes/kt31649.fir.txt | 4 ++ .../lambdaInDataClassDefaultParameter.fir.txt | 8 ++++ .../parameters/dataClassMembers.fir.txt | 7 +++ .../lambdas/destructuringInLambda.fir.txt | 6 +++ .../enhancedNullabilityInForLoop.fir.txt | 6 +++ 23 files changed, 162 insertions(+), 32 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/constantValues.txt b/compiler/fir/analysis-tests/testData/resolve/constantValues.txt index b33115ddf0b..b733892d9e1 100644 --- a/compiler/fir/analysis-tests/testData/resolve/constantValues.txt +++ b/compiler/fir/analysis-tests/testData/resolve/constantValues.txt @@ -28,6 +28,7 @@ FILE: constantValues.kt } public final fun copy(classId: R|ClassId| = this@R|/ClassLiteralValue|.R|/ClassLiteralValue.classId|, arrayNestedness: R|kotlin/Int| = this@R|/ClassLiteralValue|.R|/ClassLiteralValue.arrayNestedness|): R|ClassLiteralValue| { + ^copy R|/ClassLiteralValue.ClassLiteralValue|(this@R|/ClassLiteralValue|.R|/ClassLiteralValue.classId|, this@R|/ClassLiteralValue|.R|/ClassLiteralValue.arrayNestedness|) } } @@ -72,6 +73,7 @@ FILE: constantValues.kt } public final fun copy(value: R|ClassLiteralValue| = this@R|/KClassValue.Value.NormalClass|.R|/KClassValue.Value.NormalClass.value|): R|KClassValue.Value.NormalClass| { + ^copy R|/KClassValue.Value.NormalClass.NormalClass|(this@R|/KClassValue.Value.NormalClass|.R|/KClassValue.Value.NormalClass.value|) } } @@ -89,6 +91,7 @@ FILE: constantValues.kt } public final fun copy(type: R|KotlinType| = this@R|/KClassValue.Value.LocalClass|.R|/KClassValue.Value.LocalClass.type|): R|KClassValue.Value.LocalClass| { + ^copy R|/KClassValue.Value.LocalClass.LocalClass|(this@R|/KClassValue.Value.LocalClass|.R|/KClassValue.Value.LocalClass.type|) } } diff --git a/compiler/fir/analysis-tests/testData/resolve/copy.txt b/compiler/fir/analysis-tests/testData/resolve/copy.txt index d306225a7f0..e4603034727 100644 --- a/compiler/fir/analysis-tests/testData/resolve/copy.txt +++ b/compiler/fir/analysis-tests/testData/resolve/copy.txt @@ -19,6 +19,7 @@ FILE: copy.kt } public final fun copy(x: R|kotlin/Int| = this@R|/Some|.R|/Some.x|, y: R|kotlin/String| = this@R|/Some|.R|/Some.y|): R|Some| { + ^copy R|/Some.Some|(this@R|/Some|.R|/Some.x|, this@R|/Some|.R|/Some.y|) } } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/incompatibleModifiers.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/incompatibleModifiers.txt index 1b5b65f4a30..4835a4ae72e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/incompatibleModifiers.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/incompatibleModifiers.txt @@ -56,6 +56,7 @@ FILE: incompatibleModifiers.kt } public final fun copy(i: R|kotlin/Int| = this@R|/H|.R|/H.i|): R|H| { + ^copy R|/H.H|(this@R|/H|.R|/H.i|) } } @@ -72,6 +73,7 @@ FILE: incompatibleModifiers.kt } public final fun copy(i: R|kotlin/Int| = this@R|/I|.R|/I.i|): R|I| { + ^copy R|/I.I|(this@R|/I|.R|/I.i|) } } @@ -88,6 +90,7 @@ FILE: incompatibleModifiers.kt } public final fun copy(i: R|kotlin/Int| = this@R|/J|.R|/J.i|): R|J| { + ^copy R|/J.J|(this@R|/J|.R|/J.i|) } } @@ -133,6 +136,7 @@ FILE: incompatibleModifiers.kt } public final fun copy(i: R|kotlin/Int| = this@R|/X.Y|.R|/X.Y.i|): R|X.Y| { + ^copy R|/X.Y.Y|(this@R|/X.Y|.R|/X.Y.i|) } } diff --git a/compiler/fir/analysis-tests/testData/resolve/problems2.txt b/compiler/fir/analysis-tests/testData/resolve/problems2.txt index 63a29a8a20a..ee40422fecd 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems2.txt +++ b/compiler/fir/analysis-tests/testData/resolve/problems2.txt @@ -55,6 +55,7 @@ FILE: problems2.kt } public final fun copy(x: R|kotlin/Int| = this@R|/Some.WithPrimary|.R|/Some.WithPrimary.x|, arr: R|kotlin/Array?| = this@R|/Some.WithPrimary|.R|/Some.WithPrimary.arr|, s: R|kotlin/String?| = this@R|/Some.WithPrimary|.R|/Some.WithPrimary.s|): R|Some.WithPrimary| { + ^copy R|/Some.WithPrimary.WithPrimary|(this@R|/Some.WithPrimary|.R|/Some.WithPrimary.x|, this@R|/Some.WithPrimary|.R|/Some.WithPrimary.arr|, this@R|/Some.WithPrimary|.R|/Some.WithPrimary.s|) } } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/components.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/components.txt index f33fdfeb76b..b3c21a03207 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/components.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/components.txt @@ -19,6 +19,7 @@ FILE: components.kt } public final fun copy(x: R|kotlin/Int| = this@R|/D|.R|/D.x|, y: R|kotlin/String| = this@R|/D|.R|/D.y|): R|D| { + ^copy R|/D.D|(this@R|/D|.R|/D.x|, this@R|/D|.R|/D.y|) } } diff --git a/compiler/fir/raw-fir/fir-common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt b/compiler/fir/raw-fir/fir-common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt index 5ff3edb052f..1bef3aa2ca7 100644 --- a/compiler/fir/raw-fir/fir-common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt +++ b/compiler/fir/raw-fir/fir-common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt @@ -642,23 +642,24 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte } } - inner class DataClassMemberGenerator( + inner class DataClassMembersGenerator( private val session: FirSession, private val source: T, private val classBuilder: AbstractFirRegularClassBuilder, - private val classTypeRef: FirTypeRef, + private val primaryConstructor: FirConstructor, private val zippedParameters: List>, private val packageFqName: FqName, private val classFqName: FqName, ) { + private val classTypeRef = primaryConstructor.returnTypeRef - fun generateMembers() { + fun generate() { generateComponentFunctions() generateCopyFunction() - // TODO: equals, hashCode, toString + // Refer to (IR utils or FIR backend) DataClassMembersGenerator for generating equals, hashCode, and toString } - private inline fun generateComponentAccess(parameterSource: FirSourceElement?, firProperty: FirProperty) = + private fun generateComponentAccess(parameterSource: FirSourceElement?, firProperty: FirProperty) = buildQualifiedAccessExpression { source = parameterSource dispatchReceiver = buildThisReceiverExpression { @@ -684,10 +685,8 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte val target = FirFunctionTarget(labelName = null, isLambda = false) val componentFunction = buildSimpleFunction { source = parameterSource - session = this@DataClassMemberGenerator.session - returnTypeRef = buildImplicitTypeRef { - source = parameterSource - } + session = this@DataClassMembersGenerator.session + returnTypeRef = firProperty.returnTypeRef receiverTypeRef = null this.name = name status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL) @@ -709,10 +708,11 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte private val copyName = Name.identifier("copy") private fun generateCopyFunction() { + val target = FirFunctionTarget(labelName = null, isLambda = false) classBuilder.addDeclaration( buildSimpleFunction { - source = this@DataClassMemberGenerator.source.toFirSourceElement() - session = this@DataClassMemberGenerator.session + source = this@DataClassMembersGenerator.source.toFirSourceElement() + session = this@DataClassMembersGenerator.session returnTypeRef = classTypeRef name = copyName status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL) @@ -722,7 +722,7 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte val parameterSource = ktParameter?.toFirSourceElement() valueParameters += buildValueParameter { source = parameterSource - session = this@DataClassMemberGenerator.session + session = this@DataClassMembersGenerator.session returnTypeRef = firProperty.returnTypeRef name = propertyName symbol = FirVariableSymbol(propertyName) @@ -733,8 +733,27 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte } } - body = buildEmptyExpressionBlock() - }, + // TODO: Handle generic types. + val initCallExpression = buildFunctionCall { + argumentList = buildArgumentList { + for ((ktParameter, firProperty) in zippedParameters) { + val parameterSource = ktParameter?.toFirSourceElement() + arguments += generateComponentAccess(parameterSource, firProperty) + } + } + calleeReference = buildResolvedNamedReference { + name = primaryConstructor.symbol.callableId.callableName + resolvedSymbol = primaryConstructor.symbol + } + } + val returnExpression = buildReturnExpression { + result = initCallExpression + this.target = target + } + body = buildSingleExpressionBlock(returnExpression) + }.also { + target.bind(it) + } ) } } diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index e5087c4e785..5e1ed6eb2d2 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -412,7 +412,6 @@ class DeclarationsConverter( delegationSpecifiers?.let { superTypeRefs += it.superTypesRef } - when { modifiers.isEnum() && (classKind == ClassKind.ENUM_CLASS) -> { delegatedSuperTypeRef = buildResolvedTypeRef { @@ -467,15 +466,15 @@ class DeclarationsConverter( //parse data class if (modifiers.isDataClass() && firPrimaryConstructor != null) { val zippedParameters = properties.map { it.source?.lightNode!! to it } - DataClassMemberGenerator( + DataClassMembersGenerator( baseSession, classNode, this, - firPrimaryConstructor.returnTypeRef, + firPrimaryConstructor, zippedParameters, context.packageFqName, context.className - ).generateMembers() + ).generate() } if (modifiers.isEnum()) { diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 94f897b6291..5771db44a4a 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -161,7 +161,7 @@ class RawFirBuilder( delegatedSuperType: FirTypeRef, delegatedSelfType: FirResolvedTypeRef, owner: KtClassOrObject, - ownerClassBuilder: FirClassBuilder, hasPrimaryConstructor: Boolean, + ownerClassBuilder: FirClassBuilder, hasPrimaryConstructor: Boolean, ownerTypeParameters: List ): FirDeclaration { return when (this) { @@ -693,15 +693,15 @@ class RawFirBuilder( val zippedParameters = classOrObject.primaryConstructorParameters.zip( declarations.filterIsInstance(), ) - DataClassMemberGenerator( + DataClassMembersGenerator( baseSession, classOrObject, this, - firPrimaryConstructor.returnTypeRef, + firPrimaryConstructor, zippedParameters, context.packageFqName, context.className - ).generateMembers() + ).generate() } if (classOrObject.hasModifier(ENUM_KEYWORD)) { diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.txt index b0ef7baba3e..51544521f37 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.txt @@ -26,6 +26,7 @@ FILE: annotated.kt } public final fun copy(): R|Two| { + ^copy R|/Two.Two|() } } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt index 9ff7f163329..1acb8aacc97 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt @@ -13,19 +13,20 @@ FILE: destructuring.kt public? final? val third: String = R|/third| public? get(): String - public final fun component1(): { + public final fun component1(): Int { ^component1 this@R|/Some|.R|/Some.first| } - public final fun component2(): { + public final fun component2(): Double { ^component2 this@R|/Some|.R|/Some.second| } - public final fun component3(): { + public final fun component3(): String { ^component3 this@R|/Some|.R|/Some.third| } public final fun copy(first: Int = this@R|/Some|.R|/Some.first|, second: Double = this@R|/Some|.R|/Some.second|, third: String = this@R|/Some|.R|/Some.third|): R|Some| { + ^copy R|/Some.Some|(this@R|/Some|.R|/Some.first|, this@R|/Some|.R|/Some.second|, this@R|/Some|.R|/Some.third|) } } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt index 2b2dcf716f2..f91dd22735a 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt @@ -48,15 +48,16 @@ FILE: for.kt public? final? val y: Int = R|/y| public? get(): Int - public final fun component1(): { + public final fun component1(): Int { ^component1 this@R|/Some|.R|/Some.x| } - public final fun component2(): { + public final fun component2(): Int { ^component2 this@R|/Some|.R|/Some.y| } public final fun copy(x: Int = this@R|/Some|.R|/Some.x|, y: Int = this@R|/Some|.R|/Some.y|): R|Some| { + ^copy R|/Some.Some|(this@R|/Some|.R|/Some.x|, this@R|/Some|.R|/Some.y|) } } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt index f1847a2f7c6..96297741183 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt @@ -10,15 +10,16 @@ FILE: lambda.kt public? final? val y: Int = R|/y| public? get(): Int - public final fun component1(): { + public final fun component1(): Int { ^component1 this@R|/Tuple|.R|/Tuple.x| } - public final fun component2(): { + public final fun component2(): Int { ^component2 this@R|/Tuple|.R|/Tuple.y| } public final fun copy(x: Int = this@R|/Tuple|.R|/Tuple.x|, y: Int = this@R|/Tuple|.R|/Tuple.y|): R|Tuple| { + ^copy R|/Tuple.Tuple|(this@R|/Tuple|.R|/Tuple.x|, this@R|/Tuple|.R|/Tuple.y|) } } diff --git a/compiler/testData/codegen/box/classes/kt6136.kt b/compiler/testData/codegen/box/classes/kt6136.kt index 0ab817bf680..14a14e1c4e0 100644 --- a/compiler/testData/codegen/box/classes/kt6136.kt +++ b/compiler/testData/codegen/box/classes/kt6136.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface Id { val id: T } diff --git a/compiler/testData/codegen/box/dataClasses/copy/kt3033.kt b/compiler/testData/codegen/box/dataClasses/copy/kt3033.kt index 5e53436a958..7fc12756d88 100644 --- a/compiler/testData/codegen/box/dataClasses/copy/kt3033.kt +++ b/compiler/testData/codegen/box/dataClasses/copy/kt3033.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR data class A(val a: Double, val b: Double) fun box() : String { diff --git a/compiler/testData/codegen/box/localClasses/localDataClass.kt b/compiler/testData/codegen/box/localClasses/localDataClass.kt index badda2c7044..33cf16258d2 100644 --- a/compiler/testData/codegen/box/localClasses/localDataClass.kt +++ b/compiler/testData/codegen/box/localClasses/localDataClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun box(): String { val capturedInConstructor = 1 diff --git a/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.txt b/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.txt index 67a0cfb673d..39db39a4cf3 100644 --- a/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.txt +++ b/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.txt @@ -206,6 +206,26 @@ FILE fqName: fileName:/dataClassWithArrayMembers.kt CALL 'public final fun (): kotlin.DoubleArray declared in .Test1' type=kotlin.DoubleArray origin=GET_PROPERTY $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (stringArray: kotlin.Array, charArray: kotlin.CharArray, booleanArray: kotlin.BooleanArray, byteArray: kotlin.ByteArray, shortArray: kotlin.ShortArray, intArray: kotlin.IntArray, longArray: kotlin.LongArray, floatArray: kotlin.FloatArray, doubleArray: kotlin.DoubleArray): .Test1 declared in .Test1' + CONSTRUCTOR_CALL 'public constructor (stringArray: kotlin.Array, charArray: kotlin.CharArray, booleanArray: kotlin.BooleanArray, byteArray: kotlin.ByteArray, shortArray: kotlin.ShortArray, intArray: kotlin.IntArray, longArray: kotlin.LongArray, floatArray: kotlin.FloatArray, doubleArray: kotlin.DoubleArray) [primary] declared in .Test1' type=.Test1 origin=null + stringArray: CALL 'public final fun (): kotlin.Array declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null + charArray: CALL 'public final fun (): kotlin.CharArray declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null + booleanArray: CALL 'public final fun (): kotlin.BooleanArray declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null + byteArray: CALL 'public final fun (): kotlin.ByteArray declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null + shortArray: CALL 'public final fun (): kotlin.ShortArray declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null + intArray: CALL 'public final fun (): kotlin.IntArray declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null + longArray: CALL 'public final fun (): kotlin.LongArray declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null + floatArray: CALL 'public final fun (): kotlin.FloatArray declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null + doubleArray: CALL 'public final fun (): kotlin.DoubleArray declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Test1, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Test1 VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? @@ -456,6 +476,11 @@ FILE fqName: fileName:/dataClassWithArrayMembers.kt CALL 'public final fun (): kotlin.Array.Test2> declared in .Test2' type=kotlin.Array.Test2> origin=GET_PROPERTY $this: GET_VAR ': .Test2.Test2> declared in .Test2.copy' type=.Test2.Test2> origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (genericArray: kotlin.Array.Test2>): .Test2.Test2> declared in .Test2' + CONSTRUCTOR_CALL 'public constructor (genericArray: kotlin.Array.Test2>) [primary] declared in .Test2' type=.Test2.Test2> origin=null + : + genericArray: CALL 'public final fun (): kotlin.Array.Test2> declared in .Test2' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test2.Test2> declared in .Test2.copy' type=.Test2.Test2> origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Test2.Test2>, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Test2.Test2> VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? @@ -537,6 +562,10 @@ FILE fqName: fileName:/dataClassWithArrayMembers.kt CALL 'public final fun (): kotlin.Array? declared in .Test3' type=kotlin.Array? origin=GET_PROPERTY $this: GET_VAR ': .Test3 declared in .Test3.copy' type=.Test3 origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (anyArrayN: kotlin.Array?): .Test3 declared in .Test3' + CONSTRUCTOR_CALL 'public constructor (anyArrayN: kotlin.Array?) [primary] declared in .Test3' type=.Test3 origin=null + anyArrayN: CALL 'public final fun (): kotlin.Array? declared in .Test3' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test3 declared in .Test3.copy' type=.Test3 origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Test3, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Test3 VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? diff --git a/compiler/testData/ir/irText/classes/dataClasses.fir.txt b/compiler/testData/ir/irText/classes/dataClasses.fir.txt index d79632a0294..cf2926903dc 100644 --- a/compiler/testData/ir/irText/classes/dataClasses.fir.txt +++ b/compiler/testData/ir/irText/classes/dataClasses.fir.txt @@ -74,6 +74,14 @@ FILE fqName: fileName:/dataClasses.kt CALL 'public final fun (): kotlin.Any declared in .Test1' type=kotlin.Any origin=GET_PROPERTY $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: kotlin.Int, y: kotlin.String, z: kotlin.Any): .Test1 declared in .Test1' + CONSTRUCTOR_CALL 'public constructor (x: kotlin.Int, y: kotlin.String, z: kotlin.Any) [primary] declared in .Test1' type=.Test1 origin=null + x: CALL 'public final fun (): kotlin.Int declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null + y: CALL 'public final fun (): kotlin.String declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null + z: CALL 'public final fun (): kotlin.Any declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1 declared in .Test1.copy' type=.Test1 origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Test1, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Test1 VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? @@ -194,6 +202,10 @@ FILE fqName: fileName:/dataClasses.kt CALL 'public final fun (): kotlin.Any? declared in .Test2' type=kotlin.Any? origin=GET_PROPERTY $this: GET_VAR ': .Test2 declared in .Test2.copy' type=.Test2 origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: kotlin.Any?): .Test2 declared in .Test2' + CONSTRUCTOR_CALL 'public constructor (x: kotlin.Any?) [primary] declared in .Test2' type=.Test2 origin=null + x: CALL 'public final fun (): kotlin.Any? declared in .Test2' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test2 declared in .Test2.copy' type=.Test2 origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Test2, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Test2 VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? @@ -349,6 +361,16 @@ FILE fqName: fileName:/dataClasses.kt CALL 'public final fun (): kotlin.Float? declared in .Test3' type=kotlin.Float? origin=GET_PROPERTY $this: GET_VAR ': .Test3 declared in .Test3.copy' type=.Test3 origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (d: kotlin.Double, dn: kotlin.Double?, f: kotlin.Float, df: kotlin.Float?): .Test3 declared in .Test3' + CONSTRUCTOR_CALL 'public constructor (d: kotlin.Double, dn: kotlin.Double?, f: kotlin.Float, df: kotlin.Float?) [primary] declared in .Test3' type=.Test3 origin=null + d: CALL 'public final fun (): kotlin.Double declared in .Test3' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test3 declared in .Test3.copy' type=.Test3 origin=null + dn: CALL 'public final fun (): kotlin.Double? declared in .Test3' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test3 declared in .Test3.copy' type=.Test3 origin=null + f: CALL 'public final fun (): kotlin.Float declared in .Test3' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test3 declared in .Test3.copy' type=.Test3 origin=null + df: CALL 'public final fun (): kotlin.Float? declared in .Test3' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test3 declared in .Test3.copy' type=.Test3 origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Test3, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Test3 VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? diff --git a/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.txt b/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.txt index 9a574361354..d21627088f6 100644 --- a/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.txt +++ b/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.txt @@ -31,6 +31,11 @@ FILE fqName: fileName:/dataClassesGeneric.kt CALL 'public final fun (): T of .Test1 declared in .Test1' type=T of .Test1 origin=GET_PROPERTY $this: GET_VAR ': .Test1.Test1> declared in .Test1.copy' type=.Test1.Test1> origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: T of .Test1): .Test1.Test1> declared in .Test1' + CONSTRUCTOR_CALL 'public constructor (x: T of .Test1) [primary] declared in .Test1' type=.Test1.Test1> origin=null + : + x: CALL 'public final fun (): T of .Test1 declared in .Test1' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test1.Test1> declared in .Test1.copy' type=.Test1.Test1> origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Test1.Test1>, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Test1.Test1> VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? @@ -121,6 +126,11 @@ FILE fqName: fileName:/dataClassesGeneric.kt CALL 'public final fun (): T of .Test2 declared in .Test2' type=T of .Test2 origin=GET_PROPERTY $this: GET_VAR ': .Test2.Test2> declared in .Test2.copy' type=.Test2.Test2> origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: T of .Test2): .Test2.Test2> declared in .Test2' + CONSTRUCTOR_CALL 'public constructor (x: T of .Test2) [primary] declared in .Test2' type=.Test2.Test2> origin=null + : + x: CALL 'public final fun (): T of .Test2 declared in .Test2' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test2.Test2> declared in .Test2.copy' type=.Test2.Test2> origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Test2.Test2>, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Test2.Test2> VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? @@ -202,6 +212,11 @@ FILE fqName: fileName:/dataClassesGeneric.kt CALL 'public final fun (): kotlin.collections.List.Test3> declared in .Test3' type=kotlin.collections.List.Test3> origin=GET_PROPERTY $this: GET_VAR ': .Test3.Test3> declared in .Test3.copy' type=.Test3.Test3> origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: kotlin.collections.List.Test3>): .Test3.Test3> declared in .Test3' + CONSTRUCTOR_CALL 'public constructor (x: kotlin.collections.List.Test3>) [primary] declared in .Test3' type=.Test3.Test3> origin=null + : + x: CALL 'public final fun (): kotlin.collections.List.Test3> declared in .Test3' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test3.Test3> declared in .Test3.copy' type=.Test3.Test3> origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Test3.Test3>, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Test3.Test3> VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? @@ -282,6 +297,10 @@ FILE fqName: fileName:/dataClassesGeneric.kt CALL 'public final fun (): kotlin.collections.List declared in .Test4' type=kotlin.collections.List origin=GET_PROPERTY $this: GET_VAR ': .Test4 declared in .Test4.copy' type=.Test4 origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: kotlin.collections.List): .Test4 declared in .Test4' + CONSTRUCTOR_CALL 'public constructor (x: kotlin.collections.List) [primary] declared in .Test4' type=.Test4 origin=null + x: CALL 'public final fun (): kotlin.collections.List declared in .Test4' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test4 declared in .Test4.copy' type=.Test4 origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Test4, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Test4 VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? diff --git a/compiler/testData/ir/irText/classes/kt31649.fir.txt b/compiler/testData/ir/irText/classes/kt31649.fir.txt index 2261e4a9cc5..8a32e1cd57a 100644 --- a/compiler/testData/ir/irText/classes/kt31649.fir.txt +++ b/compiler/testData/ir/irText/classes/kt31649.fir.txt @@ -30,6 +30,10 @@ FILE fqName: fileName:/kt31649.kt CALL 'public final fun (): kotlin.Nothing? declared in .TestData' type=kotlin.Nothing? origin=GET_PROPERTY $this: GET_VAR ': .TestData declared in .TestData.copy' type=.TestData origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (nn: kotlin.Nothing?): .TestData declared in .TestData' + CONSTRUCTOR_CALL 'public constructor (nn: kotlin.Nothing?) [primary] declared in .TestData' type=.TestData origin=null + nn: CALL 'public final fun (): kotlin.Nothing? declared in .TestData' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .TestData declared in .TestData.copy' type=.TestData origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.TestData, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.TestData VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? diff --git a/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.txt b/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.txt index b6472d25665..44cf79ae263 100644 --- a/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.txt +++ b/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.txt @@ -37,6 +37,10 @@ FILE fqName: fileName:/lambdaInDataClassDefaultParameter.kt CALL 'public final fun (): kotlin.Function2<.A, kotlin.String, kotlin.Unit> declared in .A' type=kotlin.Function2<.A, kotlin.String, kotlin.Unit> origin=GET_PROPERTY $this: GET_VAR ': .A declared in .A.copy' type=.A origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (runA: kotlin.Function2<.A, kotlin.String, kotlin.Unit>): .A declared in .A' + CONSTRUCTOR_CALL 'public constructor (runA: kotlin.Function2<.A, kotlin.String, kotlin.Unit>) [primary] declared in .A' type=.A origin=null + runA: CALL 'public final fun (): kotlin.Function2<.A, kotlin.String, kotlin.Unit> declared in .A' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .A declared in .A.copy' type=.A origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.A, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.A VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? @@ -139,6 +143,10 @@ FILE fqName: fileName:/lambdaInDataClassDefaultParameter.kt CALL 'public final fun (): kotlin.Any declared in .B' type=kotlin.Any origin=GET_PROPERTY $this: GET_VAR ': .B declared in .B.copy' type=.B origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: kotlin.Any): .B declared in .B' + CONSTRUCTOR_CALL 'public constructor (x: kotlin.Any) [primary] declared in .B' type=.B origin=null + x: CALL 'public final fun (): kotlin.Any declared in .B' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .B declared in .B.copy' type=.B origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.B, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.B VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? diff --git a/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.txt b/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.txt index 8845db395cb..59a2c8223d4 100644 --- a/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.txt +++ b/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.txt @@ -55,6 +55,13 @@ FILE fqName: fileName:/dataClassMembers.kt CALL 'public final fun (): kotlin.String declared in .Test' type=kotlin.String origin=GET_PROPERTY $this: GET_VAR ': .Test.Test> declared in .Test.copy' type=.Test.Test> origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: T of .Test, y: kotlin.String): .Test.Test> declared in .Test' + CONSTRUCTOR_CALL 'public constructor (x: T of .Test, y: kotlin.String) [primary] declared in .Test' type=.Test.Test> origin=null + : + x: CALL 'public final fun (): T of .Test declared in .Test' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test.Test> declared in .Test.copy' type=.Test.Test> origin=null + y: CALL 'public final fun (): kotlin.String declared in .Test' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .Test.Test> declared in .Test.copy' type=.Test.Test> origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Test.Test>, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Test.Test> VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? diff --git a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt index 69be1c6eb8c..a87683f8445 100644 --- a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt +++ b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt @@ -52,6 +52,12 @@ FILE fqName: fileName:/destructuringInLambda.kt CALL 'public final fun (): kotlin.Int declared in .A' type=kotlin.Int origin=GET_PROPERTY $this: GET_VAR ': .A declared in .A.copy' type=.A origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: kotlin.Int, y: kotlin.Int): .A declared in .A' + CONSTRUCTOR_CALL 'public constructor (x: kotlin.Int, y: kotlin.Int) [primary] declared in .A' type=.A origin=null + x: CALL 'public final fun (): kotlin.Int declared in .A' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .A declared in .A.copy' type=.A origin=null + y: CALL 'public final fun (): kotlin.Int declared in .A' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .A declared in .A.copy' type=.A origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.A, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.A VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt index 2694186c08b..acc5360dd92 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt @@ -167,6 +167,12 @@ FILE fqName: fileName:/enhancedNullabilityInForLoop.kt CALL 'public final fun (): kotlin.Int declared in .P' type=kotlin.Int origin=GET_PROPERTY $this: GET_VAR ': .P declared in .P.copy' type=.P origin=null BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: kotlin.Int, y: kotlin.Int): .P declared in .P' + CONSTRUCTOR_CALL 'public constructor (x: kotlin.Int, y: kotlin.Int) [primary] declared in .P' type=.P origin=null + x: CALL 'public final fun (): kotlin.Int declared in .P' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .P declared in .P.copy' type=.P origin=null + y: CALL 'public final fun (): kotlin.Int declared in .P' type=IrErrorType origin=GET_PROPERTY + $this: GET_VAR ': .P declared in .P.copy' type=.P origin=null FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.P, other:kotlin.Any?) returnType:kotlin.Boolean $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.P VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any?