Disable data class copy function body in raw FIR
After this commit we require 'copy' body generation in FIR2IR converter
This commit is contained in:
committed by
Mikhail Glukhikh
parent
a849cc7da4
commit
d3f00280e9
@@ -14,10 +14,7 @@ import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||
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.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
@@ -89,7 +86,7 @@ internal fun KtClassOrObject.generateCopyFunction(
|
||||
isInfix = false, isInline = false,
|
||||
isTailRec = false, isExternal = false,
|
||||
isSuspend = false, receiverTypeRef = null,
|
||||
returnTypeRef = FirImplicitTypeRefImpl(session, this)
|
||||
returnTypeRef = firPrimaryConstructor.returnTypeRef//FirImplicitTypeRefImpl(session, this)
|
||||
).apply {
|
||||
val copyFunction = this
|
||||
val zippedParameters =
|
||||
@@ -105,29 +102,31 @@ internal fun KtClassOrObject.generateCopyFunction(
|
||||
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)
|
||||
}
|
||||
)
|
||||
|
||||
body = FirEmptyExpressionBlock(session)
|
||||
// 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)
|
||||
// }
|
||||
// )
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -29,8 +29,7 @@ FILE: annotated.kt
|
||||
super<kotlin/Any>()
|
||||
}
|
||||
|
||||
public final fun copy(): <implicit> {
|
||||
^copy R|/Two.Two|()
|
||||
public final fun copy(): R|Two| {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ 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|): <implicit> {
|
||||
^copy R|/Some.Some|(R|<local>/first|, R|<local>/second|, R|<local>/third|)
|
||||
public final fun copy(first: Int = R|/Some.first|, second: Double = R|/Some.second|, third: String = R|/Some.third|): R|Some| {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,8 +43,7 @@ FILE: for.kt
|
||||
^component2 R|/Some.y|
|
||||
}
|
||||
|
||||
public final fun copy(x: Int = R|/Some.x|, y: Int = R|/Some.y|): <implicit> {
|
||||
^copy R|/Some.Some|(R|<local>/x|, R|<local>/y|)
|
||||
public final fun copy(x: Int = R|/Some.x|, y: Int = R|/Some.y|): R|Some| {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ FILE: lambda.kt
|
||||
^component2 R|/Tuple.y|
|
||||
}
|
||||
|
||||
public final fun copy(x: Int = R|/Tuple.x|, y: Int = R|/Tuple.y|): <implicit> {
|
||||
^copy R|/Tuple.Tuple|(R|<local>/x|, R|<local>/y|)
|
||||
public final fun copy(x: Int = R|/Tuple.x|, y: Int = R|/Tuple.y|): R|Tuple| {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user