diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/DataClassUtils.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/DataClassUtils.kt index a1e8018cdb9..9828376bf52 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/DataClassUtils.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/DataClassUtils.kt @@ -9,21 +9,24 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.FirFunctionTarget import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.declarations.FirClass +import org.jetbrains.kotlin.fir.declarations.FirConstructor import org.jetbrains.kotlin.fir.declarations.FirProperty -import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.impl.FirClassImpl import org.jetbrains.kotlin.fir.declarations.impl.FirMemberFunctionImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl +import org.jetbrains.kotlin.fir.expressions.impl.FirFunctionCallImpl import org.jetbrains.kotlin.fir.expressions.impl.FirQualifiedAccessExpressionImpl import org.jetbrains.kotlin.fir.expressions.impl.FirReturnExpressionImpl import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtClassOrObject +import org.jetbrains.kotlin.psi.KtTypeReference internal fun KtClassOrObject.generateComponentFunctions( session: FirSession, firClass: FirClassImpl, packageFqName: FqName, classFqName: FqName @@ -67,4 +70,64 @@ internal fun KtClassOrObject.generateComponentFunctions( } ) } +} + +private val copyName = Name.identifier("copy") + +internal fun KtClassOrObject.generateCopyFunction( + session: FirSession, firClass: FirClassImpl, packageFqName: FqName, classFqName: FqName, + firPrimaryConstructor: FirConstructor, + toFirOrErrorTypeRef: KtTypeReference?.() -> FirTypeRef +) { + val symbol = FirFunctionSymbol(CallableId(packageFqName, classFqName, copyName)) + firClass.addDeclaration( + FirMemberFunctionImpl( + session, this, symbol, copyName, + Visibilities.PUBLIC, Modality.FINAL, + isExpect = false, isActual = false, + isOverride = false, isOperator = false, + isInfix = false, isInline = false, + isTailRec = false, isExternal = false, + isSuspend = false, receiverTypeRef = null, + returnTypeRef = FirImplicitTypeRefImpl(session, this) + ).apply { + val copyFunction = this + val zippedParameters = + primaryConstructorParameters.zip(firClass.declarations.filterIsInstance()) + for ((ktParameter, firProperty) in zippedParameters) { + val name = ktParameter.nameAsSafeName + valueParameters += FirValueParameterImpl( + session, ktParameter, name, + ktParameter.typeReference.toFirOrErrorTypeRef(), + FirQualifiedAccessExpressionImpl(session, ktParameter).apply { + calleeReference = FirResolvedCallableReferenceImpl(session, ktParameter, name, firProperty.symbol) + }, + isCrossinline = false, isNoinline = false, isVararg = false + ) + } + body = FirSingleExpressionBlock( + session, + FirReturnExpressionImpl( + session, this@generateCopyFunction, + FirFunctionCallImpl(session, this@generateCopyFunction).apply { + calleeReference = FirResolvedCallableReferenceImpl( + session, this@generateCopyFunction, firClass.name, + firPrimaryConstructor.symbol + ) + }.apply { + for ((ktParameter, firParameter) in primaryConstructorParameters.zip(valueParameters)) { + this.arguments += FirQualifiedAccessExpressionImpl(session, ktParameter).apply { + calleeReference = FirResolvedCallableReferenceImpl( + session, ktParameter, firParameter.name, firParameter.symbol + ) + } + } + } + ).apply { + target = FirFunctionTarget(null) + target.bind(copyFunction) + } + ) + } + ) } \ No newline at end of file diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index c8b7130017c..3f781b412c3 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -547,6 +547,10 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) { if (classOrObject.hasModifier(DATA_KEYWORD) && firPrimaryConstructor != null) { classOrObject.generateComponentFunctions(session, firClass, packageFqName, className) + classOrObject.generateCopyFunction(session, firClass, packageFqName, className, firPrimaryConstructor) { + toFirOrErrorType() + } + // TODO: equals, hashCode, toString } firClass diff --git a/compiler/fir/psi2fir/testData/rawBuilder/expressions/annotated.txt b/compiler/fir/psi2fir/testData/rawBuilder/expressions/annotated.txt index 95cee7bdbb9..df22475d15d 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/expressions/annotated.txt +++ b/compiler/fir/psi2fir/testData/rawBuilder/expressions/annotated.txt @@ -29,6 +29,10 @@ FILE: annotated.kt super() } + public final fun copy(): { + ^copy R|/Two.Two|() + } + } public? final? fun bar(two: Two): kotlin/Unit { lval : = two# diff --git a/compiler/fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt b/compiler/fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt index dd6f4395180..36fb16202a8 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt +++ b/compiler/fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt @@ -25,6 +25,10 @@ FILE: destructuring.kt ^component3 R|/Some.third| } + public final fun copy(first: Int = R|/Some.first|, second: Double = R|/Some.second|, third: String = R|/Some.third|): { + ^copy R|/Some.Some|(R|/first|, R|/second|, R|/third|) + } + } public? final? fun foo(some: Some): kotlin/Unit { lval : = some# diff --git a/compiler/fir/psi2fir/testData/rawBuilder/expressions/for.txt b/compiler/fir/psi2fir/testData/rawBuilder/expressions/for.txt index ea74e083be1..8d06c3b920b 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/expressions/for.txt +++ b/compiler/fir/psi2fir/testData/rawBuilder/expressions/for.txt @@ -43,6 +43,10 @@ FILE: for.kt ^component2 R|/Some.y| } + public final fun copy(x: Int = R|/Some.x|, y: Int = R|/Some.y|): { + ^copy R|/Some.Some|(R|/x|, R|/y|) + } + } public? final? fun baz(set: Set): kotlin/Unit { lval : = set# diff --git a/compiler/fir/psi2fir/testData/rawBuilder/expressions/lambda.txt b/compiler/fir/psi2fir/testData/rawBuilder/expressions/lambda.txt index 55f54d7c11a..2696ea9005e 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/expressions/lambda.txt +++ b/compiler/fir/psi2fir/testData/rawBuilder/expressions/lambda.txt @@ -18,6 +18,10 @@ FILE: lambda.kt ^component2 R|/Tuple.y| } + public final fun copy(x: Int = R|/Tuple.x|, y: Int = R|/Tuple.y|): { + ^copy R|/Tuple.Tuple|(R|/x|, R|/y|) + } + } public? final? inline fun use(f: ( (Tuple) -> Int )): { ^use f#(Tuple#(Int(1), Int(2))) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt index 6e636d43ce2..08cb27a6498 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt @@ -538,6 +538,9 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn } override fun transformFunctionCall(functionCall: FirFunctionCall, data: Any?): CompositeTransformResult { + if (functionCall.calleeReference is FirResolvedCallableReference && functionCall.resultType is FirImplicitTypeRef) { + storeTypeFromCallee(functionCall) + } if (functionCall.calleeReference !is FirSimpleNamedReference) return functionCall.compose() val expectedTypeRef = data as FirTypeRef? val completeInference = diff --git a/compiler/fir/resolve/testData/resolve/copy.kt b/compiler/fir/resolve/testData/resolve/copy.kt new file mode 100644 index 00000000000..c4fe1712a7d --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/copy.kt @@ -0,0 +1,8 @@ +data class Some(val x: Int, val y: String) + +fun test(some: Some) { + val other = some.copy(y = "123") + val another = some.copy(x = 123) + val same = some.copy() + val different = some.copy(456, "456") +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/copy.txt b/compiler/fir/resolve/testData/resolve/copy.txt new file mode 100644 index 00000000000..0489878f096 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/copy.txt @@ -0,0 +1,31 @@ +FILE: copy.kt + public final data class Some : R|kotlin/Any| { + public constructor(x: R|kotlin/Int|, y: R|kotlin/String|): R|Some| { + super() + } + + public final val x: R|kotlin/Int| = R|/x| + public get(): R|kotlin/Int| + + public final val y: R|kotlin/String| = R|/y| + public get(): R|kotlin/String| + + public final fun component1(): R|kotlin/Int| { + ^component1 R|/Some.x| + } + + public final fun component2(): R|kotlin/String| { + ^component2 R|/Some.y| + } + + public final fun copy(x: R|kotlin/Int| = R|/Some.x|, y: R|kotlin/String| = R|/Some.y|): R|Some| { + ^copy R|/Some.Some|(R|/x|, R|/y|) + } + + } + public final fun test(some: R|Some|): R|kotlin/Unit| { + lval other: R|Some| = R|/some|.R|/Some.copy|(y = String(123)) + lval another: R|Some| = R|/some|.R|/Some.copy|(x = Int(123)) + lval same: R|Some| = R|/some|.R|/Some.copy|() + lval different: R|Some| = R|/some|.R|/Some.copy|(Int(456), String(456)) + } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/components.txt b/compiler/fir/resolve/testData/resolve/stdlib/components.txt index a12ef4d776f..4224aeea314 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/components.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/components.txt @@ -18,6 +18,10 @@ FILE: components.kt ^component2 R|/D.y| } + public final fun copy(x: R|kotlin/Int| = R|/D.x|, y: R|kotlin/String| = R|/D.y|): R|D| { + ^copy R|/D.D|(R|/x|, R|/y|) + } + } public final fun foo(list: R|kotlin/collections/List|): R|kotlin/Unit| { lval : R|kotlin/collections/List| = R|/list| 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 873ee86ae4a..c5fdb25201a 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java @@ -34,6 +34,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase { runTest("compiler/fir/resolve/testData/resolve/companion.kt"); } + @TestMetadata("copy.kt") + public void testCopy() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/copy.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/dataClassWithArrayMembers.fir.txt b/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.txt index 7edaedcc608..369954c26f9 100644 --- a/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.txt +++ b/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.txt @@ -158,7 +158,48 @@ FILE fqName: fileName:/dataClassWithArrayMembers.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component9 (): kotlin.DoubleArray declared in .Test1' CALL 'public final fun (): kotlin.DoubleArray declared in .Test1' type=kotlin.DoubleArray origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.Test1, 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) returnType:.Test1 + $this: VALUE_PARAMETER name: type:.Test1 + VALUE_PARAMETER name:stringArray index:0 type:kotlin.Array + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Array declared in .Test1' type=kotlin.Array origin=null + VALUE_PARAMETER name:charArray index:1 type:kotlin.CharArray + EXPRESSION_BODY + CALL 'public final fun (): kotlin.CharArray declared in .Test1' type=kotlin.CharArray origin=null + VALUE_PARAMETER name:booleanArray index:2 type:kotlin.BooleanArray + EXPRESSION_BODY + CALL 'public final fun (): kotlin.BooleanArray declared in .Test1' type=kotlin.BooleanArray origin=null + VALUE_PARAMETER name:byteArray index:3 type:kotlin.ByteArray + EXPRESSION_BODY + CALL 'public final fun (): kotlin.ByteArray declared in .Test1' type=kotlin.ByteArray origin=null + VALUE_PARAMETER name:shortArray index:4 type:kotlin.ShortArray + EXPRESSION_BODY + CALL 'public final fun (): kotlin.ShortArray declared in .Test1' type=kotlin.ShortArray origin=null + VALUE_PARAMETER name:intArray index:5 type:kotlin.IntArray + EXPRESSION_BODY + CALL 'public final fun (): kotlin.IntArray declared in .Test1' type=kotlin.IntArray origin=null + VALUE_PARAMETER name:longArray index:6 type:kotlin.LongArray + EXPRESSION_BODY + CALL 'public final fun (): kotlin.LongArray declared in .Test1' type=kotlin.LongArray origin=null + VALUE_PARAMETER name:floatArray index:7 type:kotlin.FloatArray + EXPRESSION_BODY + CALL 'public final fun (): kotlin.FloatArray declared in .Test1' type=kotlin.FloatArray origin=null + VALUE_PARAMETER name:doubleArray index:8 type:kotlin.DoubleArray + EXPRESSION_BODY + CALL 'public final fun (): kotlin.DoubleArray declared in .Test1' type=kotlin.DoubleArray 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: GET_VAR 'stringArray: kotlin.Array declared in .Test1.copy' type=IrErrorType origin=null + charArray: GET_VAR 'charArray: kotlin.CharArray declared in .Test1.copy' type=IrErrorType origin=null + booleanArray: GET_VAR 'booleanArray: kotlin.BooleanArray declared in .Test1.copy' type=IrErrorType origin=null + byteArray: GET_VAR 'byteArray: kotlin.ByteArray declared in .Test1.copy' type=IrErrorType origin=null + shortArray: GET_VAR 'shortArray: kotlin.ShortArray declared in .Test1.copy' type=IrErrorType origin=null + intArray: GET_VAR 'intArray: kotlin.IntArray declared in .Test1.copy' type=IrErrorType origin=null + longArray: GET_VAR 'longArray: kotlin.LongArray declared in .Test1.copy' type=IrErrorType origin=null + floatArray: GET_VAR 'floatArray: kotlin.FloatArray declared in .Test1.copy' type=IrErrorType origin=null + doubleArray: GET_VAR 'doubleArray: kotlin.DoubleArray declared in .Test1.copy' type=IrErrorType origin=null + 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 @@ -195,7 +236,17 @@ FILE fqName: fileName:/dataClassWithArrayMembers.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Array.Test2> declared in .Test2' CALL 'public final fun (): kotlin.Array.Test2> declared in .Test2' type=kotlin.Array.Test2> origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.Test2, genericArray:kotlin.Array.Test2>) returnType:.Test2> + $this: VALUE_PARAMETER name: type:.Test2 + VALUE_PARAMETER name:genericArray index:0 type:kotlin.Array.Test2> + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Array.Test2> declared in .Test2' type=kotlin.Array.Test2> origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (genericArray: kotlin.Array.Test2>): .Test2> declared in .Test2' + CONSTRUCTOR_CALL 'public constructor (genericArray: kotlin.Array>) [primary] declared in .Test2' type=.Test2> origin=null + : + genericArray: GET_VAR 'genericArray: kotlin.Array.Test2> declared in .Test2.copy' type=IrErrorType origin=null + 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 @@ -231,7 +282,16 @@ FILE fqName: fileName:/dataClassWithArrayMembers.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Array? declared in .Test3' CALL 'public final fun (): kotlin.Array? declared in .Test3' type=kotlin.Array? origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.Test3, anyArrayN:kotlin.Array?) returnType:.Test3 + $this: VALUE_PARAMETER name: type:.Test3 + VALUE_PARAMETER name:anyArrayN index:0 type:kotlin.Array? + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Array? declared in .Test3' type=kotlin.Array? 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: GET_VAR 'anyArrayN: kotlin.Array? declared in .Test3.copy' type=IrErrorType origin=null + 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 diff --git a/compiler/testData/ir/irText/classes/dataClasses.fir.txt b/compiler/testData/ir/irText/classes/dataClasses.fir.txt index bd4d5334525..786912f7e95 100644 --- a/compiler/testData/ir/irText/classes/dataClasses.fir.txt +++ b/compiler/testData/ir/irText/classes/dataClasses.fir.txt @@ -56,7 +56,24 @@ FILE fqName: fileName:/dataClasses.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component3 (): kotlin.Any declared in .Test1' CALL 'public final fun (): kotlin.Any declared in .Test1' type=kotlin.Any origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.Test1, x:kotlin.Int, y:kotlin.String, z:kotlin.Any) returnType:.Test1 + $this: VALUE_PARAMETER name: type:.Test1 + VALUE_PARAMETER name:x index:0 type:kotlin.Int + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Int declared in .Test1' type=kotlin.Int origin=null + VALUE_PARAMETER name:y index:1 type:kotlin.String + EXPRESSION_BODY + CALL 'public final fun (): kotlin.String declared in .Test1' type=kotlin.String origin=null + VALUE_PARAMETER name:z index:2 type:kotlin.Any + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Any declared in .Test1' type=kotlin.Any 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: GET_VAR 'x: kotlin.Int declared in .Test1.copy' type=IrErrorType origin=null + y: GET_VAR 'y: kotlin.String declared in .Test1.copy' type=IrErrorType origin=null + z: GET_VAR 'z: kotlin.Any declared in .Test1.copy' type=IrErrorType origin=null + 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 @@ -92,7 +109,16 @@ FILE fqName: fileName:/dataClasses.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Any? declared in .Test2' CALL 'public final fun (): kotlin.Any? declared in .Test2' type=kotlin.Any? origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.Test2, x:kotlin.Any?) returnType:.Test2 + $this: VALUE_PARAMETER name: type:.Test2 + VALUE_PARAMETER name:x index:0 type:kotlin.Any? + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Any? declared in .Test2' type=kotlin.Any? 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: GET_VAR 'x: kotlin.Any? declared in .Test2.copy' type=IrErrorType origin=null + 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 @@ -179,7 +205,28 @@ FILE fqName: fileName:/dataClasses.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component4 (): kotlin.Float? declared in .Test3' CALL 'public final fun (): kotlin.Float? declared in .Test3' type=kotlin.Float? origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.Test3, d:kotlin.Double, dn:kotlin.Double?, f:kotlin.Float, df:kotlin.Float?) returnType:.Test3 + $this: VALUE_PARAMETER name: type:.Test3 + VALUE_PARAMETER name:d index:0 type:kotlin.Double + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Double declared in .Test3' type=kotlin.Double origin=null + VALUE_PARAMETER name:dn index:1 type:kotlin.Double? + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Double? declared in .Test3' type=kotlin.Double? origin=null + VALUE_PARAMETER name:f index:2 type:kotlin.Float + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Float declared in .Test3' type=kotlin.Float origin=null + VALUE_PARAMETER name:df index:3 type:kotlin.Float? + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Float? declared in .Test3' type=kotlin.Float? 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: GET_VAR 'd: kotlin.Double declared in .Test3.copy' type=IrErrorType origin=null + dn: GET_VAR 'dn: kotlin.Double? declared in .Test3.copy' type=IrErrorType origin=null + f: GET_VAR 'f: kotlin.Float declared in .Test3.copy' type=IrErrorType origin=null + df: GET_VAR 'df: kotlin.Float? declared in .Test3.copy' type=IrErrorType origin=null + 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 diff --git a/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.txt b/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.txt index 26d0940c623..de1716f083a 100644 --- a/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.txt +++ b/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.txt @@ -23,7 +23,17 @@ FILE fqName: fileName:/dataClassesGeneric.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component1 (): T of .Test1 declared in .Test1' CALL 'public final fun (): T of .Test1 declared in .Test1' type=T of .Test1 origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.Test1, x:T of .Test1) returnType:.Test1> + $this: VALUE_PARAMETER name: type:.Test1 + VALUE_PARAMETER name:x index:0 type:T of .Test1 + EXPRESSION_BODY + CALL 'public final fun (): T of .Test1 declared in .Test1' type=T of .Test1 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: T of .Test1): .Test1> declared in .Test1' + CONSTRUCTOR_CALL 'public constructor (x: T of ) [primary] declared in .Test1' type=.Test1> origin=null + : + x: GET_VAR 'x: T of .Test1 declared in .Test1.copy' type=IrErrorType origin=null + 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 @@ -60,7 +70,17 @@ FILE fqName: fileName:/dataClassesGeneric.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component1 (): T of .Test2 declared in .Test2' CALL 'public final fun (): T of .Test2 declared in .Test2' type=T of .Test2 origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.Test2, x:T of .Test2) returnType:.Test2> + $this: VALUE_PARAMETER name: type:.Test2 + VALUE_PARAMETER name:x index:0 type:T of .Test2 + EXPRESSION_BODY + CALL 'public final fun (): T of .Test2 declared in .Test2' type=T of .Test2 origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: T of .Test2): .Test2> declared in .Test2' + CONSTRUCTOR_CALL 'public constructor (x: T of ) [primary] declared in .Test2' type=.Test2> origin=null + : + x: GET_VAR 'x: T of .Test2 declared in .Test2.copy' type=IrErrorType origin=null + 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 @@ -97,7 +117,17 @@ FILE fqName: fileName:/dataClassesGeneric.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.collections.List.Test3> declared in .Test3' CALL 'public final fun (): kotlin.collections.List.Test3> declared in .Test3' type=kotlin.collections.List.Test3> origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.Test3, x:kotlin.collections.List.Test3>) returnType:.Test3> + $this: VALUE_PARAMETER name: type:.Test3 + VALUE_PARAMETER name:x index:0 type:kotlin.collections.List.Test3> + EXPRESSION_BODY + CALL 'public final fun (): kotlin.collections.List.Test3> declared in .Test3' type=kotlin.collections.List.Test3> origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: kotlin.collections.List.Test3>): .Test3> declared in .Test3' + CONSTRUCTOR_CALL 'public constructor (x: kotlin.collections.List>) [primary] declared in .Test3' type=.Test3> origin=null + : + x: GET_VAR 'x: kotlin.collections.List.Test3> declared in .Test3.copy' type=IrErrorType origin=null + 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 @@ -133,7 +163,16 @@ FILE fqName: fileName:/dataClassesGeneric.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.collections.List declared in .Test4' CALL 'public final fun (): kotlin.collections.List declared in .Test4' type=kotlin.collections.List origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.Test4, x:kotlin.collections.List) returnType:.Test4 + $this: VALUE_PARAMETER name: type:.Test4 + VALUE_PARAMETER name:x index:0 type:kotlin.collections.List + EXPRESSION_BODY + CALL 'public final fun (): kotlin.collections.List declared in .Test4' type=kotlin.collections.List 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: GET_VAR 'x: kotlin.collections.List declared in .Test4.copy' type=IrErrorType origin=null + 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 diff --git a/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.txt b/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.txt index 1a5b295b708..1f54ce384ca 100644 --- a/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.txt +++ b/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.txt @@ -28,7 +28,16 @@ FILE fqName: fileName:/lambdaInDataClassDefaultParameter.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Function2<.A, kotlin.String, kotlin.Unit> declared in .A' CALL 'public final fun (): kotlin.Function2<.A, kotlin.String, kotlin.Unit> declared in .A' type=kotlin.Function2<.A, kotlin.String, kotlin.Unit> origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.A, runA:kotlin.Function2<.A, kotlin.String, kotlin.Unit>) returnType:.A + $this: VALUE_PARAMETER name: type:.A + VALUE_PARAMETER name:runA index:0 type:kotlin.Function2<.A, kotlin.String, kotlin.Unit> + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Function2<.A, kotlin.String, kotlin.Unit> declared in .A' type=kotlin.Function2<.A, kotlin.String, kotlin.Unit> 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: GET_VAR 'runA: kotlin.Function2<.A, kotlin.String, kotlin.Unit> declared in .A.copy' type=IrErrorType origin=null + 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 @@ -73,7 +82,16 @@ FILE fqName: fileName:/lambdaInDataClassDefaultParameter.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Any declared in .B' CALL 'public final fun (): kotlin.Any declared in .B' type=kotlin.Any origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.B, x:kotlin.Any) returnType:.B + $this: VALUE_PARAMETER name: type:.B + VALUE_PARAMETER name:x index:0 type:kotlin.Any + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Any declared in .B' type=kotlin.Any 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: GET_VAR 'x: kotlin.Any declared in .B.copy' type=IrErrorType origin=null + 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 diff --git a/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.txt b/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.txt index f9ad0bace03..1e51c285ee2 100644 --- a/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.txt +++ b/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.txt @@ -42,7 +42,21 @@ FILE fqName: fileName:/dataClassMembers.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.String declared in .Test' CALL 'public final fun (): kotlin.String declared in .Test' type=kotlin.String origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.Test, x:T of .Test, y:kotlin.String) returnType:.Test> + $this: VALUE_PARAMETER name: type:.Test + VALUE_PARAMETER name:x index:0 type:T of .Test + EXPRESSION_BODY + CALL 'public final fun (): T of .Test declared in .Test' type=T of .Test origin=null + VALUE_PARAMETER name:y index:1 type:kotlin.String + EXPRESSION_BODY + CALL 'public final fun (): kotlin.String declared in .Test' type=kotlin.String origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (x: T of .Test, y: kotlin.String): .Test> declared in .Test' + CONSTRUCTOR_CALL 'public constructor (x: T of , y: kotlin.String) [primary] declared in .Test' type=.Test> origin=null + : + x: GET_VAR 'x: T of .Test declared in .Test.copy' type=IrErrorType origin=null + y: GET_VAR 'y: kotlin.String declared in .Test.copy' type=IrErrorType origin=null + 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 diff --git a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt index 872b9aca973..ad0fc5334c0 100644 --- a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt +++ b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt @@ -39,7 +39,20 @@ FILE fqName: fileName:/destructuringInLambda.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.Int declared in .A' CALL 'public final fun (): kotlin.Int declared in .A' type=kotlin.Int origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + FUN name:copy visibility:public modality:FINAL <> ($this:.A, x:kotlin.Int, y:kotlin.Int) returnType:.A + $this: VALUE_PARAMETER name: type:.A + VALUE_PARAMETER name:x index:0 type:kotlin.Int + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Int declared in .A' type=kotlin.Int origin=null + VALUE_PARAMETER name:y index:1 type:kotlin.Int + EXPRESSION_BODY + CALL 'public final fun (): kotlin.Int declared in .A' type=kotlin.Int 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: GET_VAR 'x: kotlin.Int declared in .A.copy' type=IrErrorType origin=null + y: GET_VAR 'y: kotlin.Int declared in .A.copy' type=IrErrorType origin=null + 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