Skip to content

Commit

Permalink
Change Kotlin version to 2.1.20-dev-6370
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierSegoviaCordoba committed Dec 13, 2024
1 parent c70101f commit 3f20a95
Show file tree
Hide file tree
Showing 24 changed files with 85 additions and 63 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[versions]
hubdle = "0.8.1"
hubdleCatalog = "0.4.1"
javiersc-kotlin-compiler-extensions = "0.5.1+2.1.0"
jetbrains-kotlin = "2.1.0"
javiersc-kotlin-compiler-extensions = "0.6.0+2.1.20-dev-6370-SNAPSHOT"
jetbrains-kotlin = "2.1.20-dev-6370"

[libraries]
hubdle-catalog = { module = "com.javiersc.hubdle:hubdle-version-catalog", version.ref = "hubdleCatalog" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirCallChecker
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
import org.jetbrains.kotlin.fir.declarations.FirReceiverParameter
import org.jetbrains.kotlin.fir.declarations.hasAnnotation
import org.jetbrains.kotlin.fir.declarations.utils.isData
import org.jetbrains.kotlin.fir.expressions.FirAnonymousFunctionExpression
Expand All @@ -31,8 +32,8 @@ import org.jetbrains.kotlin.fir.expressions.FirThisReceiverExpression
import org.jetbrains.kotlin.fir.references.toResolvedFunctionSymbol
import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.resolve.toRegularClassSymbol
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirThisOwnerSymbol
import org.jetbrains.kotlin.fir.types.resolvedType

internal object BreakingCallsChecker : FirCallChecker(MppCheckerKind.Common) {
Expand Down Expand Up @@ -95,7 +96,7 @@ internal object BreakingCallsChecker : FirCallChecker(MppCheckerKind.Common) {
val extensionReceiver: FirPropertyAccessExpression =
setOrUpdateCall.extensionReceiver?.asFirOrNull<FirPropertyAccessExpression>()
?: return Failure.BrokenChain(setOrUpdateCall)
val updateOrSetThisBoundSymbol: FirBasedSymbol<*> =
val updateOrSetThisBoundSymbol: FirThisOwnerSymbol<*> =
setOrUpdateCall.dispatchReceiver
?.asFirOrNull<FirThisReceiverExpression>()
?.calleeReference
Expand All @@ -120,7 +121,11 @@ internal object BreakingCallsChecker : FirCallChecker(MppCheckerKind.Common) {
?.asFirOrNull<FirThisReceiverExpression>()
?.calleeReference
?.boundSymbol
?.fir ?: return Failure.NoCopyScope(setOrUpdateCall)
?.fir
?.asFirOrNull<FirReceiverParameter>()
?.containingDeclarationSymbol
?.fir
?: return Failure.NoCopyScope(setOrUpdateCall)
val isCopyScope: Boolean =
context.callsOrAssignments
.asSequence()
Expand All @@ -147,9 +152,9 @@ internal object BreakingCallsChecker : FirCallChecker(MppCheckerKind.Common) {

private fun FirExpression.isBreakingChainCall(
session: FirSession,
updateOrSetThisBoundSymbol: FirBasedSymbol<*>
updateOrSetThisBoundSymbol: FirThisOwnerSymbol<*>,
): CheckerResult {
val thisBoundSymbol: FirBasedSymbol<*>? =
val thisBoundSymbol: FirThisOwnerSymbol<*>? =
this.asFirOrNull<FirThisReceiverExpression>()?.calleeReference?.boundSymbol
if (updateOrSetThisBoundSymbol == thisBoundSymbol) return Success

Expand All @@ -159,7 +164,7 @@ internal object BreakingCallsChecker : FirCallChecker(MppCheckerKind.Common) {

val receiver: FirExpression? = this.dispatchReceiver

val dispatcherBoundSymbol: FirBasedSymbol<*>? =
val dispatcherBoundSymbol: FirThisOwnerSymbol<*>? =
receiver?.asFirOrNull<FirThisReceiverExpression>()?.calleeReference?.boundSymbol

val hasSameBoundSymbol: Boolean = dispatcherBoundSymbol == updateOrSetThisBoundSymbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.expressions.buildUnaryArgumentList
import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall
import org.jetbrains.kotlin.fir.expressions.builder.buildPropertyAccessExpression
import org.jetbrains.kotlin.fir.expressions.calleeReference
import org.jetbrains.kotlin.fir.expressions.contextReceiverArguments
import org.jetbrains.kotlin.fir.expressions.contextArguments
import org.jetbrains.kotlin.fir.expressions.dispatchReceiver
import org.jetbrains.kotlin.fir.expressions.explicitReceiver
import org.jetbrains.kotlin.fir.expressions.extensionReceiver
Expand Down Expand Up @@ -71,7 +71,7 @@ internal class FirKopyAssignExpressionAltererExtension(
explicitReceiver = variableAssignment.explicitReceiver
dispatchReceiver = variableAssignment.dispatchReceiver
extensionReceiver = variableAssignment.extensionReceiver
contextReceiverArguments += variableAssignment.contextReceiverArguments
contextArguments += variableAssignment.contextArguments
}
argumentList = buildUnaryArgumentList(rightArgument)
calleeReference = buildSimpleNamedReference {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import org.jetbrains.kotlin.ir.types.classOrFail
import org.jetbrains.kotlin.ir.types.typeWith
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
import org.jetbrains.kotlin.ir.util.functions
import org.jetbrains.kotlin.ir.util.getArguments
import org.jetbrains.kotlin.ir.util.getArgumentsWithIr
import org.jetbrains.kotlin.ir.util.getPropertyGetter
import org.jetbrains.kotlin.ir.util.getSimpleFunction
import org.jetbrains.kotlin.ir.util.indexOrMinusOne
Expand Down Expand Up @@ -90,9 +90,8 @@ internal class IrSetOrUpdateCallTransformer(
return originalCallCallWithAlsoCall
}

private inner class SetValueTransformer(
private val expressionCall: IrCall,
) : IrElementTransformerVoid() {
private inner class SetValueTransformer(private val expressionCall: IrCall) :
IrElementTransformerVoid() {
override fun visitExpression(expression: IrExpression): IrExpression {
fun original(): IrExpression = super.visitExpression(expression)
if (expression !in expressionCall.valueArguments) return original()
Expand All @@ -106,9 +105,8 @@ internal class IrSetOrUpdateCallTransformer(
}
}

private inner class UpdateReturnTransformer(
private val expressionCall: IrCall,
) : IrElementTransformerVoid() {
private inner class UpdateReturnTransformer(private val expressionCall: IrCall) :
IrElementTransformerVoid() {
override fun visitReturn(expression: IrReturn): IrExpression {
fun original(): IrExpression = super.visitReturn(expression)
val parent: IrDeclarationParent =
Expand All @@ -132,7 +130,7 @@ internal class IrSetOrUpdateCallTransformer(

private fun IrPluginContext.createAlsoCall(
expression: IrCall,
expressionParent: IrDeclarationParent
expressionParent: IrDeclarationParent,
): IrCall? {
val setOrUpdateType: IrType = expression.extensionReceiver?.type ?: return null

Expand Down Expand Up @@ -171,7 +169,7 @@ internal class IrSetOrUpdateCallTransformer(
private fun createAlsoBlockFunction(
expressionParent: IrDeclarationParent,
setOrUpdateType: IrType,
expression: IrCall
expression: IrCall,
): IrSimpleFunction? {
val alsoBlockFunction: IrSimpleFunction =
pluginContext.irFactory
Expand All @@ -197,7 +195,7 @@ internal class IrSetOrUpdateCallTransformer(
?: return null
val atomicGetterLazySetFunctionCall: IrCall? =
expression.createAtomicGetterLazySetFunctionCall(
copyChainCall = copyChainCall,
copyChainCall = copyChainCall
)
if (atomicGetterLazySetFunctionCall != null) {
+atomicGetterLazySetFunctionCall
Expand Down Expand Up @@ -230,7 +228,7 @@ internal class IrSetOrUpdateCallTransformer(
val isLast: Boolean = next == dispatchers.last()
val argumentValue: IrDeclarationReference =
if (isLast) alsoItValueParameterGetValue
else next.apply { this.dispatchReceiver = current }
else next.apply { insertDispatchReceiver(current) }

val copyCall: IrCall? =
current.symbol.createCopyCall(
Expand All @@ -246,8 +244,8 @@ internal class IrSetOrUpdateCallTransformer(
val copyChainCall: IrCall =
calls.reduce { acc, irCall ->
val argumentIndex: Int =
irCall.getArguments().firstNotNullOfOrNull {
val index = it.first.indexOrMinusOne
irCall.getArgumentsWithIr().firstNotNullOfOrNull { (valueParameter, _) ->
val index: Int = valueParameter.descriptor.indexOrMinusOne
if (index != -1) index else null
} ?: return null
irCall.putValueArgument(argumentIndex, acc)
Expand All @@ -271,10 +269,10 @@ internal class IrSetOrUpdateCallTransformer(
buildList {
val extensionReceiver: IrMemberAccessExpression<*> =
runCatching {
extensionReceiver
?.asIrOrNull<IrMemberAccessExpression<*>>()
?.deepCopyWithSymbols()
}
extensionReceiver
?.asIrOrNull<IrMemberAccessExpression<*>>()
?.deepCopyWithSymbols()
}
.getOrNull() ?: return@buildList

add(extensionReceiver)
Expand Down Expand Up @@ -303,8 +301,7 @@ internal class IrSetOrUpdateCallTransformer(
val kotlinCopyFunctionSymbol: IrSimpleFunctionSymbol =
dataClass.owner.functions
.firstOrNull {
it.name == copyName &&
!it.hasAnnotation(kopyFunctionCopyFqName)
it.name == copyName && !it.hasAnnotation(kopyFunctionCopyFqName)
}
?.symbol ?: return null
irCall(kotlinCopyFunctionSymbol).apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ FILE fqName:com.javiersc.kotlin.kopy.playground fileName:/no-kopy-annotation-on-
VALUE_PARAMETER name:zip index:3 type:kotlin.String
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Address modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Address modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.Unit
FUN GENERATED[com.javiersc.kotlin.kopy.compiler.fir.Key] name:copy visibility:public modality:FINAL <> ($this:com.javiersc.kotlin.kopy.playground.Address, copy:@[ExtensionFunctionType] kotlin.Function1<com.javiersc.kotlin.kopy.playground.Address, kotlin.Unit>) returnType:com.javiersc.kotlin.kopy.playground.Address [infix]
annotations:
KopyOptIn
Expand Down Expand Up @@ -358,7 +358,7 @@ FILE fqName:com.javiersc.kotlin.kopy.playground fileName:/no-kopy-annotation-on-
VALUE_PARAMETER name:last index:1 type:kotlin.String
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Name modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Name modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.Unit
FUN GENERATED[com.javiersc.kotlin.kopy.compiler.fir.Key] name:copy visibility:public modality:FINAL <> ($this:com.javiersc.kotlin.kopy.playground.Name, copy:@[ExtensionFunctionType] kotlin.Function1<com.javiersc.kotlin.kopy.playground.Name, kotlin.Unit>) returnType:com.javiersc.kotlin.kopy.playground.Name [infix]
annotations:
KopyOptIn
Expand Down Expand Up @@ -594,7 +594,7 @@ FILE fqName:com.javiersc.kotlin.kopy.playground fileName:/no-kopy-annotation-on-
VALUE_PARAMETER name:privateInfo index:2 type:com.javiersc.kotlin.kopy.playground.PrivateInfo
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Person modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Person modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.Unit
FUN GENERATED[com.javiersc.kotlin.kopy.compiler.fir.Key] name:copy visibility:public modality:FINAL <> ($this:com.javiersc.kotlin.kopy.playground.Person, copy:@[ExtensionFunctionType] kotlin.Function1<com.javiersc.kotlin.kopy.playground.Person, kotlin.Unit>) returnType:com.javiersc.kotlin.kopy.playground.Person [infix]
annotations:
KopyOptIn
Expand Down Expand Up @@ -836,7 +836,7 @@ FILE fqName:com.javiersc.kotlin.kopy.playground fileName:/no-kopy-annotation-on-
VALUE_PARAMETER name:dob index:1 type:kotlin.String
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:PrivateInfo modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:PrivateInfo modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.Unit
FUN GENERATED_DATA_CLASS_MEMBER name:component1 visibility:public modality:FINAL <> ($this:com.javiersc.kotlin.kopy.playground.PrivateInfo) returnType:kotlin.String [operator]
$this: VALUE_PARAMETER name:<this> type:com.javiersc.kotlin.kopy.playground.PrivateInfo
BLOCK_BODY
Expand Down
4 changes: 2 additions & 2 deletions kopy-compiler/test-data/box/edge/simple-1.fir.ir.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ FILE fqName:com.javiersc.kotlin.kopy.playground fileName:/simple-1.kt
VALUE_PARAMETER name:pet index:1 type:com.javiersc.kotlin.kopy.playground.Pet
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:House modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:House modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.Unit
FUN GENERATED[com.javiersc.kotlin.kopy.compiler.fir.Key] name:copy visibility:public modality:FINAL <> ($this:com.javiersc.kotlin.kopy.playground.House, copy:@[ExtensionFunctionType] kotlin.Function1<com.javiersc.kotlin.kopy.playground.House, kotlin.Unit>) returnType:com.javiersc.kotlin.kopy.playground.House [infix]
annotations:
KopyOptIn
Expand Down Expand Up @@ -268,7 +268,7 @@ FILE fqName:com.javiersc.kotlin.kopy.playground fileName:/simple-1.kt
VALUE_PARAMETER name:age index:1 type:kotlin.Int
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Pet modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Pet modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.Unit
FUN GENERATED[com.javiersc.kotlin.kopy.compiler.fir.Key] name:copy visibility:public modality:FINAL <> ($this:com.javiersc.kotlin.kopy.playground.Pet, copy:@[ExtensionFunctionType] kotlin.Function1<com.javiersc.kotlin.kopy.playground.Pet, kotlin.Unit>) returnType:com.javiersc.kotlin.kopy.playground.Pet [infix]
annotations:
KopyOptIn
Expand Down
8 changes: 4 additions & 4 deletions kopy-compiler/test-data/box/nest-copy-set.fir.ir.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ FILE fqName:com.javiersc.kotlin.kopy.playground fileName:/nest-copy-set.kt
VALUE_PARAMETER name:isValid index:1 type:kotlin.Boolean
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Bar modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Bar modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.Unit
FUN GENERATED[com.javiersc.kotlin.kopy.compiler.fir.Key] name:copy visibility:public modality:FINAL <> ($this:com.javiersc.kotlin.kopy.playground.Bar, copy:@[ExtensionFunctionType] kotlin.Function1<com.javiersc.kotlin.kopy.playground.Bar, kotlin.Unit>) returnType:com.javiersc.kotlin.kopy.playground.Bar [infix]
annotations:
KopyOptIn
Expand Down Expand Up @@ -268,7 +268,7 @@ FILE fqName:com.javiersc.kotlin.kopy.playground fileName:/nest-copy-set.kt
VALUE_PARAMETER name:text index:1 type:kotlin.String
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Baz modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Baz modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.Unit
FUN GENERATED[com.javiersc.kotlin.kopy.compiler.fir.Key] name:copy visibility:public modality:FINAL <> ($this:com.javiersc.kotlin.kopy.playground.Baz, copy:@[ExtensionFunctionType] kotlin.Function1<com.javiersc.kotlin.kopy.playground.Baz, kotlin.Unit>) returnType:com.javiersc.kotlin.kopy.playground.Baz [infix]
annotations:
KopyOptIn
Expand Down Expand Up @@ -492,7 +492,7 @@ FILE fqName:com.javiersc.kotlin.kopy.playground fileName:/nest-copy-set.kt
VALUE_PARAMETER name:letter index:1 type:kotlin.Char
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Foo modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Foo modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.Unit
FUN GENERATED[com.javiersc.kotlin.kopy.compiler.fir.Key] name:copy visibility:public modality:FINAL <> ($this:com.javiersc.kotlin.kopy.playground.Foo, copy:@[ExtensionFunctionType] kotlin.Function1<com.javiersc.kotlin.kopy.playground.Foo, kotlin.Unit>) returnType:com.javiersc.kotlin.kopy.playground.Foo [infix]
annotations:
KopyOptIn
Expand Down Expand Up @@ -704,7 +704,7 @@ FILE fqName:com.javiersc.kotlin.kopy.playground fileName:/nest-copy-set.kt
VALUE_PARAMETER name:number index:0 type:kotlin.Int
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Qux modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Qux modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.Unit
FUN GENERATED[com.javiersc.kotlin.kopy.compiler.fir.Key] name:copy visibility:public modality:FINAL <> ($this:com.javiersc.kotlin.kopy.playground.Qux, copy:@[ExtensionFunctionType] kotlin.Function1<com.javiersc.kotlin.kopy.playground.Qux, kotlin.Unit>) returnType:com.javiersc.kotlin.kopy.playground.Qux [infix]
annotations:
KopyOptIn
Expand Down
Loading

0 comments on commit 3f20a95

Please sign in to comment.