kotlin 1.4.30: PowerAssertComponentRegistrar is not compatible with this version of compiler
dkandalov opened this issue · comments
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.4.30'
id("com.bnorm.power.kotlin-power-assert") version "0.7.0"
}
produces this on compilation
Kotlin: [Internal Error] java.lang.IllegalStateException: The provided plugin com.bnorm.power.PowerAssertComponentRegistrar is not compatible with this version of compiler
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:574)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.registerExtensionsFromPlugins(KotlinCoreEnvironment.kt:129)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:169)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:109)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:421)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:226)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:152)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1485)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
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(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.AbstractMethodError: Receiver class com.bnorm.power.PowerAssertComponentRegistrar does not define or inherit an implementation of the resolved method 'abstract void registerProjectComponents(com.intellij.mock.MockProject, org.jetbrains.kotlin.config.CompilerConfiguration)' of interface org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar.
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:566)
... 28 more
Something very strange is happening. The exception is reporting that PowerAssertComponentRegistrar
doesn't override a function with the signature of registerProjectComponents(com.intellij.mock.MockProject, org.jetbrains.kotlin.config.CompilerConfiguration)
. However, the ComponentRegistrar
class defines a function with the following signature: registerProjectComponents(org.jetbrains.kotlin.com.intellij.mock.MockProject, org.jetbrains.kotlin.config.CompilerConfiguration)
. Somehow, the project parameter is changing type.
Do you have any more detail about this project you can share? The sample directory of this project defines the same plugin versions and isn't reporting any issues.
Could it be Gradle version with embedded Kotlin discrepancy?
I sort of expect the problem to be the opposite. Kotlin/JVM and Kotlin/JS use the embedded compiler and Kotlin/Native uses the non-embedded compiler which is why there are 2 different artifacts. It appears here the non-embedded compiler is being used with a plugin compiled against the embedded compiler.
I looked into the issue and it seems to be related IntelliJ 🙄
In particular, power-assert works fine from command line, i.e. ./gradlew build
is successful.
It only fails in IntelliJ with enabled Build Tools -> Gradle -> Build and run using IntelliJ IDEA
and Build Tools -> Gradle -> Run tests using IntelliJ IDEA
.
https://github.com/dkandalov/power-assert-fail
IntelliJ IDEA 2021.1 Beta (Ultimate Edition)
Build #IU-211.6693.14, built on March 25, 2021
Kotlin: 211-1.4.21-release-IJ6693.10
or
IntelliJ IDEA 2020.3.3 (Ultimate Edition)
Build #IU-203.7717.56, built on March 15, 2021
Kotlin: 203-1.5.0-M2-release-538-IJ7717.8
Well, the error is correct. You're compiling against the embedded compiler that has this difference, whereas some environments need the regular compiler, for example, anything that's not Gradle.
I fixed this by simply changing the dependency to the regular compiler and fixing the import line. Now it works.
Maybe you could load the right class using reflection so the JAR is usable with either compiler? As it seems, this is the only namespace difference that matters, for some reason.
Just for the record using
plugins {
kotlin("jvm") version "2.0.0"
kotlin("plugin.power-assert") version "2.0.0"
}
still produces a non-obvious error when IntelliJ (2024.1.2 the latest non-EAP) is used for building and running tests:
Kotlin: [Internal Error] java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.com.intellij.psi.tree.IElementType org.jetbrains.kotlin.lexer.KotlinLexer.getTokenType()'
at org.jetbrains.kotlin.powerassert.diagram.IrDiagramKt.binaryOperatorOffset(IrDiagram.kt:204)
at org.jetbrains.kotlin.powerassert.diagram.IrDiagramKt.memberAccessOffset(IrDiagram.kt:174)
at org.jetbrains.kotlin.powerassert.diagram.IrDiagramKt.findDisplayOffset(IrDiagram.kt:158)
at org.jetbrains.kotlin.powerassert.diagram.IrDiagramKt.toValueDisplay(IrDiagram.kt:106)
at org.jetbrains.kotlin.powerassert.diagram.IrDiagramKt.irDiagramString(IrDiagram.kt:43)
at org.jetbrains.kotlin.powerassert.PowerAssertCallTransformer.diagram$recursive(PowerAssertCallTransformer.kt:138)
at org.jetbrains.kotlin.powerassert.PowerAssertCallTransformer.diagram$recursive$lambda$13(PowerAssertCallTransformer.kt:148)
at org.jetbrains.kotlin.powerassert.diagram.DiagramBuilderKt.buildDiagramNesting$lambda$0(DiagramBuilder.kt:33)
at org.jetbrains.kotlin.powerassert.diagram.DiagramBuilderKt.add(DiagramBuilder.kt:82)
at org.jetbrains.kotlin.powerassert.diagram.DiagramBuilderKt.buildExpression(DiagramBuilder.kt:52)
at org.jetbrains.kotlin.powerassert.diagram.DiagramBuilderKt.buildDiagramNesting(DiagramBuilder.kt:32)
at org.jetbrains.kotlin.powerassert.PowerAssertCallTransformer.diagram$recursive(PowerAssertCallTransformer.kt:146)
at org.jetbrains.kotlin.powerassert.PowerAssertCallTransformer.diagram$lambda$15$lambda$14(PowerAssertCallTransformer.kt:156)
at org.jetbrains.kotlin.powerassert.diagram.DiagramBuilderKt.buildDiagramNestingNullable(DiagramBuilder.kt:43)
at org.jetbrains.kotlin.powerassert.PowerAssertCallTransformer.diagram$lambda$15(PowerAssertCallTransformer.kt:155)
at org.jetbrains.kotlin.powerassert.diagram.DiagramBuilderKt.buildDiagramNestingNullable(DiagramBuilder.kt:43)
at org.jetbrains.kotlin.powerassert.diagram.DiagramBuilderKt.buildDiagramNestingNullable$default(DiagramBuilder.kt:37)
at org.jetbrains.kotlin.powerassert.PowerAssertCallTransformer.diagram(PowerAssertCallTransformer.kt:154)
at org.jetbrains.kotlin.powerassert.PowerAssertCallTransformer.visitCall(PowerAssertCallTransformer.kt:110)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:299)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:19)
at org.jetbrains.kotlin.ir.expressions.IrCall.accept(IrCall.kt:24)
at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:24)
at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:20)
at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
at org.jetbrains.kotlin.ir.expressions.IrBlockBody.transformChildren(IrBlockBody.kt:27)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBody(IrElementTransformerVoid.kt:174)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:188)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:191)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:19)
at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBlockBody.kt:20)
at org.jetbrains.kotlin.ir.expressions.IrBody.transform(IrBody.kt:20)
at org.jetbrains.kotlin.ir.declarations.IrFunction.transformChildren(IrFunction.kt:58)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:40)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFunction(IrElementTransformerVoid.kt:72)
at org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext.visitFunctionNew(IrElementTransformerVoidWithContext.kt:130)
at org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext.visitFunction(IrElementTransformerVoidWithContext.kt:83)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:128)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:131)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:19)
at org.jetbrains.kotlin.ir.declarations.IrSimpleFunction.accept(IrSimpleFunction.kt:36)
at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:24)
at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
at org.jetbrains.kotlin.ir.declarations.IrClass.transformChildren(IrClass.kt:82)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:40)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.kt:54)
at org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext.visitClassNew(IrElementTransformerVoidWithContext.kt:126)
at org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext.visitClass(IrElementTransformerVoidWithContext.kt:62)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.kt:57)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.kt:19)
at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:72)
at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:24)
at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
at org.jetbrains.kotlin.ir.declarations.IrFile.transformChildren(IrFile.kt:38)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitPackageFragment(IrElementTransformerVoid.kt:146)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.kt:160)
at org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext.visitFileNew(IrElementTransformerVoidWithContext.kt:122)
at org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext.visitFile(IrElementTransformerVoidWithContext.kt:55)
at org.jetbrains.kotlin.powerassert.PowerAssertIrGenerationExtension.generate(PowerAssertIrGenerationExtension.kt:36)
at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.applyIrGenerationExtensions(convertToIr.kt:260)
at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.convertToIrAndActualize(convertToIr.kt:139)
at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.convertToIrAndActualize$default(convertToIr.kt:65)
at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.convertToIrAndActualizeForJvm(jvmCompilerPipeline.kt:193)
at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.convertAnalyzedFirToIr(jvmCompilerPipeline.kt:167)
at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.compileModulesUsingFrontendIrAndLightTree(jvmCompilerPipeline.kt:138)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:155)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:50)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:104)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:48)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:79)
at org.jetbrains.kotlin.cli.common.CLICompiler.execAndOutputXml(CLICompiler.kt:64)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.jetbrains.kotlin.compilerRunner.CompilerRunnerUtil$invokeExecMethod$1.invoke(CompilerRunnerUtil.kt:100)
at org.jetbrains.kotlin.compilerRunner.CompilerRunnerUtil$invokeExecMethod$1.invoke(CompilerRunnerUtil.kt:92)
at org.jetbrains.kotlin.compilerRunner.CompilerRunnerUtil.withCompilerClassloader(CompilerRunnerUtil.kt:123)
at org.jetbrains.kotlin.compilerRunner.CompilerRunnerUtil.invokeExecMethod(CompilerRunnerUtil.kt:92)
at org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner.fallbackCompileStrategy(JpsKotlinCompilerRunner.kt:318)
at org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner.access$fallbackCompileStrategy(JpsKotlinCompilerRunner.kt:39)
at org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner$compileWithDaemonOrFallback$2.invoke(JpsKotlinCompilerRunner.kt:189)
at org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner$compileWithDaemonOrFallback$2.invoke(JpsKotlinCompilerRunner.kt:187)
at org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner.withDaemonOrFallback(JpsKotlinCompilerRunner.kt:250)
at org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner.compileWithDaemonOrFallback(JpsKotlinCompilerRunner.kt:187)
at org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner.runCompiler(JpsKotlinCompilerRunner.kt:200)
at org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner.runK2JvmCompiler(JpsKotlinCompilerRunner.kt:144)
at org.jetbrains.kotlin.jps.targets.KotlinJvmModuleBuildTarget.compileModuleChunk(KotlinJvmModuleBuildTarget.kt:144)
at org.jetbrains.kotlin.jps.build.KotlinBuilder.doCompileModuleChunk(KotlinBuilder.kt:644)
at org.jetbrains.kotlin.jps.build.KotlinBuilder.doBuild(KotlinBuilder.kt:472)
at org.jetbrains.kotlin.jps.build.KotlinBuilder.access$doBuild(KotlinBuilder.kt:59)
at org.jetbrains.kotlin.jps.build.KotlinBuilder$doBuild$2.invoke(KotlinBuilder.kt:347)
at org.jetbrains.kotlin.jps.build.KotlinBuilder$doBuild$2.invoke(KotlinBuilder.kt:345)
at org.jetbrains.kotlin.jps.statistic.DummyJpsStatisticsReportService.reportMetrics(JpsStatisticsReportService.kt:80)
at org.jetbrains.kotlin.jps.build.KotlinBuilder.doBuild(KotlinBuilder.kt:345)
at org.jetbrains.kotlin.jps.build.KotlinBuilder.build(KotlinBuilder.kt:308)
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1609)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1238)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1389)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1203)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:971)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:527)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:236)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:134)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:387)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:212)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:211)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)
@dkandalov Could you please report this on YouTrack as well? Problems with the official compiler plugin should be reported there while I figure out the best way to deprecate/archive this repository.