Strange "Unresolved reference:" error after upgrading to Kotlin 1.0.5 - kotlin

I have a project that contains 2 modules. A Java module that contains my java code. And a Kotlin module that contains my Kotlin code. The Kotlin module depends on the java module. That is, there is nothing in the Java module that references the Kotlin module. But the Kotlin module relies on Java classes from the Java module.
This project I haven't opened for 6 months or so.
It worked fine before. It was kotlin 1.something. Whatever was the latest in June.
Now I have updated to the latest Kotlin version.
But one of my java module java classes cannot be referenced anymore from the Kotlin module. It is only 1 of the classes, the Kotlin module references a lot of other classes from the Java module just fine still.
I am hoping someone can tell me what is going on. Maybe there were some changes to Kotlin in the last 6 months that cause this?
The message I get in all Kotlin files in the Kotlin module that reference JSBot is this:
Error:(191, 39) Kotlin: Unresolved reference: JSBot
The JSBot import in the kt files is correct. Other classes from the Java module even in the same java package are recognized and compile without errors.
Here is the JSBot.java declaration (in the java module):
public abstract class JSBot extends Evaluable implements Name {
...
}
Other abstract java classes are referenced fine though from the Kotlin module. So I can't really understand what is going on. It is just this one Java class.
But, in earlier Kotlin versions (v1.0 through whatever was latest in June) it compiled fine. I just get this error now. I haven't changed any code. Only updated to kotlin plugin 1.0.5
Could anyone give me some hints what to do? I am stuck and can't figure out where to go from here.
I updated my maven .pom to 1.0.5 from 1.0.0, but that didn't help.

seems to be resolved, issue will be fixed in Kotlin release described in comments above. Please don't delete this question, it might be helpful to others that encounter this kotlin bug.

Related

Class 'my.example.Class' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler

I am using IntelliJ, I published a library but when I try to use it, I get the warning: Class 'my.packge.MyClass' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler.
I am using the same build.gradle.kts on both projects, same kotlin version (1.6.21).
The weirdest part is that if I do build, the projects build just fine without any error.
Any suggestions on what could be going on?
Seem to be Kotlin's bug:
https://youtrack.jetbrains.com/issue/KTIJ-21563
Watch it in order to be notified once it has updates. See this article if you are not familiar with YouTrack.

Intellij-idea Debugger - Coroutine tab : "An error occurred on fetching information"

I'm trying to do some coroutine example represented on : https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/test/guide/example-basic-02.kt
and It's debugger not working properly.
As you see, even code about coroutine like 'runBlocking' or 'launch' is not detected by intellisense,
I don't know what is my problem.
First my project is kotlin Console program, and
What I've done to import kotlinx.coroutine to my project are :
at Project Structure, Module downloaded org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-RC from Maven, when downloading checked Trasitive-something and Source, and added at library.
at Settings -> Build -> Kotlin compiler, changed language version and API version to 1.5, which is experimental version of Kotlin
at Project tool and build.gradle.kts, added
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-RC") at dependencies,
kotlin("jvm") version "1.5.0" at plugins
Just run projects works well, but I can't use any context menu when using code about coroutine and as you know, it's really annoying me. any help would be appreciated.
I had the same problem but it seems to be fixed in 1.5.0. See https://youtrack.jetbrains.com/issue/KTIJ-11620
I meet this problem today, I use the latest the Coroutine library version and my kotlin version is 1.6.21 which is not the latest.
I just update my kotlin version to the latest version 1.8.10.

How to update kotlin compiler embedable?

I have common library with own libraries and build tools for gradle. Like SDK. I updated kotlin to 1.2.71. All ok. I also updated kotlin dsl to newest RC release(no effect).
Then I have projects, which are using this mine SDK. Problem ocurred, when I switched to version 1.2.71 on those projects, because "BuildUtilKt.makeModuleFile" was removed.
Unable to find method 'org.jetbrains.kotlin.incremental.BuildUtilKt.makeModuleFile(Ljava/lang/String;ZLjava/io/File;Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/io/File;'.
or
Unable to find method 'org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments.setCommonSources([Ljava/lang/String;)V'.
I know how to remove dependencies, when I have it in compile, but I don't know where from I am getting "kotlin-compiler-embeddable:1.2.41"
Tried:
- compileOnly("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.2.71") in buildSrc
- runtime "org.jetbrains.kotlin:kotlin-compiler-embeddable:1.2.71"
it doesn't work.
Here are printed dependencies: gist

How can I configure Kotlin coroutines for Gradle with the Kotlin DSL?

Using Gradle 4.4.1 with the Kotlin-DSL, I want to configure the experimental Kotlin coroutines in my Kotlin 1.2.20 project. This proves to be surprisingly difficult.
The official Kotlin documentation itself only mentions Gradle with the Groovy DSL instead of Kotlin.
The Kotlin-DSL project has an example for coroutines that does not work. Probably, it’s for an older Gradle version (the Kotlin version in that script is 1.1.51, which is suspicious in itself).
PS: Even IntelliJ’s configure Kotlin writes incorrect Gradle code. Is downgrading the only option?
Addendum: The build script was very red in IntelliJ IDEA. The IDE kept adding import statements all the time. It seems that these futile attempts were what made the script non-functional. I disabled ‘Add unambiguos imports on the fly’ temporarily, and even though the script remained mostly red, Gradle could execute it. And afterwards, the error notices withing IntelliJ were gone as well.
Assuming you have the kotlin plugin applied to the project:
import org.jetbrains.kotlin.gradle.dsl.Coroutines
plugins {
kotlin("jvm")
}
kotlin { // type is KotlinJvmProjectExtension
experimental.coroutines = Coroutines.ENABLE
}
This works for me with Gradle 4.4.1 and 4.5-rc-1, and I should also work for versions before that. If you are bringing in the Kotlin plugin by using buildscript instead of plugins, you may not have the generated accessors and will have to use extensions.getByType(KotlinJvmProjectExtension::class.java).apply {} (or something like that).

Loading Kotlin generated classes at runtime from Java

I have 2 projects...
My main java project and a kotlin sub project that I moved some java classes out of the main project into and converted into kotlin.
I've configured the kotlin project to have a dependency on the main java project, it works quite well since IJ is constantly recompiling java classes in the main project.
But now that i've extracted classes from the Java project, it won't compile anymore of course - it needs to access the kotlin project.
However, I don't know how to do that.. can someone explain? thanks
my kotlin out folder is empty whenever I look at it
Kotlin generates perfectly ordinary Java class files, so you can use Class.forName() and Class<?>.getConstructor().getNewInstance() with them just as well as with classes compiled from Java source code.