Open Vivecstel opened 1 month ago
Hi! I am aware of this problem. Currently, I'm unable to investigate and fix the issue, because the Poko compiler plugin that Mokkery uses is also broken by Kotlin 2.1.0-Beta1
. I will release a snapshot version as soon as Poko is fixed.
perfect thanks
Hi @lupuuss , is this the same issue with kotlin 2.0.21?
when attempting to update our project from 2.0.20 to 2.0.21, I see tests failing to run due to
e: java.lang.NullPointerException
at dev.mokkery.plugin.ir.IrClassKt.addOverridingProperty(IrClass.***:128)
at dev.mokkery.plugin.ir.IrClassKt.addOverridingProperty(IrClass.***:111)
at dev.mokkery.plugin.ir.IrClassKt.overrideAllOverridableProperties(IrClass.***:102)
at dev.mokkery.plugin.transformers.BuildMockClassKt.buildMockClass(BuildMockClass.***:99)
at dev.mokkery.plugin.transformers.MokkeryTransformer.replaceWithMock$lambda$1(MokkeryTransformer.***:95)
at dev.mokkery.plugin.core.HashMapCache.getOrPut(Cache.***:22)
at dev.mokkery.plugin.transformers.MokkeryTransformer.replaceWithMock(MokkeryTransformer.***:95)
at dev.mokkery.plugin.transformers.MokkeryTransformer.visitCall(MokkeryTransformer.***:67)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.***:299)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.***:19)
at org.jetbrains.kotlin.ir.expressions.IrCall.accept(IrCall.***:24)
at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.***:24)
at org.jetbrains.kotlin.ir.expressions.IrExpressionBody.transformChildren(IrExpressionBody.***:31)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBody(IrElementTransformerVoid.***:174)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpressionBody(IrElementTransformerVoid.***:182)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpressionBody(IrElementTransformerVoid.***:185)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpressionBody(IrElementTransformerVoid.***:19)
at org.jetbrains.kotlin.ir.expressions.IrExpressionBody.accept(IrExpressionBody.***:21)
at org.jetbrains.kotlin.ir.expressions.IrExpressionBody.transform(IrExpressionBody.***:24)
at org.jetbrains.kotlin.ir.declarations.IrField.transformChildren(IrField.***:47)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.***:40)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitField(IrElementTransformerVoid.***:96)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitField(IrElementTransformerVoid.***:99)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitField(IrElementTransformerVoid.***:19)
at org.jetbrains.kotlin.ir.declarations.IrField.accept(IrField.***:40)
at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.***:33)
at org.jetbrains.kotlin.ir.declarations.IrProperty.transformChildren(IrProperty.***:54)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.***:40)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitProperty(IrElementTransformerVoid.***:116)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitProperty(IrElementTransformerVoid.***:119)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitProperty(IrElementTransformerVoid.***:19)
at org.jetbrains.kotlin.ir.declarations.IrProperty.accept(IrProperty.***:45)
at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.***:33)
at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.***:35)
at org.jetbrains.kotlin.ir.declarations.IrClass.transformChildren(IrClass.***:82)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.***:40)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.***:54)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.***:57)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.***:19)
at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.***:72)
at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.***:33)
at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.***:35)
at org.jetbrains.kotlin.ir.declarations.IrFile.transformChildren(IrFile.***:38)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitPackageFragment(IrElementTransformerVoid.***:146)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.***:160)
at dev.mokkery.plugin.core.CoreTransformer.visitFile(CoreTransformer.***:21)
at dev.mokkery.plugin.transformers.MokkeryTransformer.visitFile(MokkeryTransformer.***:82)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.***:163)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.***:19)
at org.jetbrains.kotlin.ir.declarations.IrFile.accept(IrFile.***:28)
at org.jetbrains.kotlin.ir.declarations.IrFile.transform(IrFile.***:31)
at org.jetbrains.kotlin.ir.declarations.IrFile.transform(IrFile.***:20)
at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.***:35)
at org.jetbrains.kotlin.ir.declarations.IrModuleFragment.transformChildren(IrModuleFragment.***:43)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitModuleFragment(IrElementTransformerVoid.***:108)
at dev.mokkery.plugin.transformers.MokkeryTransformer.visitModuleFragment(MokkeryTransformer.***:87)
at dev.mokkery.plugin.MokkeryIrGenerationExtension.generate(MokkeryIrGenerationExtension.***:16)
at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.applyIrGenerationExtensions(convertToIr.***:442)
at org.jetbrains.kotlin.fir.pipeline.Fir2IrPipeline.runActualizationPipeline(convertToIr.***:246)
at org.jetbrains.kotlin.fir.pipeline.Fir2IrPipeline.convertToIrAndActualize(convertToIr.***:130)
at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.convertToIrAndActualize(convertToIr.***:99)
at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.convertToIrAndActualize$default(convertToIr.***:72)
at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.convertToIrAndActualizeForJvm(jvmCompilerPipeline.***:196)
at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.convertAnalyzedFirToIr(jvmCompilerPipeline.***:169)
at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.compileModulesUsingFrontendIrAndLightTree(jvmCompilerPipeline.***:140)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.***:148)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.***:43)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.***:103)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.***:49)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.***:101)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.***:464)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.***:73)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.doCompile(IncrementalCompilerRunner.***:506)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.***:423)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.***:301)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.***:129)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.***:675)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.***:92)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.***:1660)
at jdk.internal.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
I see the current version of poko is 0.17.0, but maybe would need to be 0.17.2 to support 2.0.21?
@zkovar I moved it to separate issue as it's not related to this issue.
Update on 2.1.0 support: Poko with 2.1.0-Beta2 support was released so I will be able to adjust Mokkery and release a snapshot with 2.1.0-Beta2 support soon.
Any update for this ?
Sorry for lack of updates. I was busy releasing Mokkery 2.5.0
. Since the last update I was able to investigate Kotlin 2.1.0 update:
I'm aiming to resolve the issues at the end of this week. If Kotlin 2.1.0 support is urgent for you, I should be able to release a snapshot that contains K/N bug, that I'll fix later.
Perfect thanks. No it is not urgent as 2.1.0 is in rc and stable yet
Update: In Kotlin 2.1.0, the #44 fix is no longer needed and actually causes the previously mentioned K/N crash, further complicating backward compatibility. As a result, I’ve decided to drop backward compatibility. While this isn’t ideal for users, it brings advantages to the Mokkery codebase by allowing the removal of compatibility fallbacks, making it easier to support Kotlin 2.1.0.
Since adding support for Kotlin 2.1.0 was simpler without backward compatibility, I’ve already released a snapshot version, 2.6.0-SNAPSHOT, which is compiled with Kotlin 2.1.0-RC and should work with previous betas and future stable release.
To use this version, add the following repository to both plugin and regular dependencies:
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
I'll provide a stable release whenever Kotlin 2.1.0 stable release is available.
When updating kotlin version to 2.1.0-Beta1 tests using mockery fail with:
With kotlin 2.0.20 the tests succeed.