Assorted errors from Kotlin DSL experiment


(Dimitar Dimitrov) #1

I took Gradle 4.1 for a spin and tried to use all new and flashy features on a small plugin and I am getting some errors. I would appreciate help if any of these are something obvious.

This is the exception I get when I try to compile in IDEA:

Error:Kotlin: [Internal Error] java.lang.AbstractMethodError: org.gradle.kotlin.dsl.compiler.GradleKotlinDslComponentRegistrar.registerProjectComponents(Lcom/intellij/mock/MockProject;Lorg/jetbrains/kotlin/config/CompilerConfiguration;)V
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:168)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:109)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:423)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:240)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createEnvironmentWithScriptingSupport(K2JVMCompiler.kt:230)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:164)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:55)
	at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:182)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.execCompiler(CompileServiceImpl.kt:397)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$execCompiler(CompileServiceImpl.kt:99)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1.invoke(CompileServiceImpl.kt:360)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1.invoke(CompileServiceImpl.kt:99)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2$$special$$inlined$withValidClientOrSessionProxy$lambda$1.invoke(CompileServiceImpl.kt:798)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2$$special$$inlined$withValidClientOrSessionProxy$lambda$1.invoke(CompileServiceImpl.kt:99)
	at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:825)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$checkedCompile(CompileServiceImpl.kt:99)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2.invoke(CompileServiceImpl.kt:797)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2.invoke(CompileServiceImpl.kt:99)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive(CompileServiceImpl.kt:1004)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive$default(CompileServiceImpl.kt:865)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:791)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$doCompile(CompileServiceImpl.kt:99)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1.invoke(CompileServiceImpl.kt:358)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1.invoke(CompileServiceImpl.kt:99)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive(CompileServiceImpl.kt:1004)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive$default(CompileServiceImpl.kt:865)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:336)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
	at sun.rmi.transport.Transport$1.run(Transport.java:200)
	at sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

And the following (different) errors when I run gradlew build on the command line:

codacy-gradle-plugin>gradlew build
e: CodacyPlugin.kt: (28, 41): Type mismatch: inferred type is (???) -> [ERROR : <ERROR FUNCTION RETURN TYPE>] but Action<in DependencySet!>! was expected
e: CodacyPlugin.kt: (28, 43): Cannot infer a type for this parameter. Please specify it explicitly.
e: CodacyPlugin.kt: (43, 19): None of the following functions can be called with the arguments supplied:
public final fun <S : Task!> withType(p0: Class<JacocoReport!>!, p1: (JacocoReport!.() -> Unit)!): DomainObjectCollection<JacocoReport!>! defined in org.gradle.api.tasks.TaskContainer
public abstract fun <S : Task!> withType(p0: Class<JacocoReport!>!, p1: Closure<(raw) Any!>!): DomainObjectCollection<JacocoReport!>! defined in org.gradle.api.tasks.TaskContainer
public abstract fun <S : Task!> withType(p0: Class<JacocoReport!>!, p1: Action<in JacocoReport!>!): DomainObjectCollection<JacocoReport!>! defined in org.gradle.api.tasks.TaskContainer
e: CodacyPlugin.kt: (43, 56): Cannot infer a type for this parameter. Please specify it explicitly.
e: CodacyPlugin.kt: (45, 31): Type inference failed: fun <T : Task!> create(p0: String!, p1: Class<T!>!, p2: Action<in T!>!): T!
cannot be applied to
(String,Class<CodacyUploadTask>,(???) -> Task!)

e: CodacyPlugin.kt: (45, 102): Type mismatch: inferred type is (???) -> Task! but Action<in CodacyUploadTask!>! was expected
e: CodacyPlugin.kt: (45, 104): Cannot infer a type for this parameter. Please specify it explicitly.
e: CodacyPlugin.kt: (91, 60): Type mismatch: inferred type is (???) -> [ERROR : <ERROR FUNCTION RETURN TYPE>] but Action<in WorkerConfiguration!>! was expected
e: CodacyPlugin.kt: (91, 62): Cannot infer a type for this parameter. Please specify it explicitly.

(Paul Merlin) #2

Hi Dimitar,

Looks like you hit https://youtrack.jetbrains.com/issue/KT-18062

The bad effect of this issue is that IntelliJ is misguiding you when editing your plugin code from the IDE.
Hence the compilation errors when building from the command line.

I opened a pull-request against your plugin with the required fixes: https://github.com/ddimtirov/codacy-gradle-plugin/pull/3
Again, because of the mismatch between the actual compilation chain and what IntelliJ understands, it now works but you get errors in IntelliJ’s editor.

This is unfortunate but it is intended to be fixed in Kotlin IntelliJ Plugin 1.1.4 that should be out soon.
Please cast a vote on the KT issue above to show your interest.

HTH