I teach Intro CS in Kotlin in the fall and like to...
# intellij
e
I teach Intro CS in Kotlin in the fall and like to start students with the REPL, which I was able to get working in 2022 and 2023 but not this year. Specifically, I installed IntelliJ IDEA 2024.1.4 (Ultimate Edition) with OpenJDK 21.0.1, created a project with the IntelliJ build system, and added a short file
Conversation.kt
. When I open the REPL, rebuild the application, and try calling it, I get the error:
Copy code
error: class 'ConversationKt' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler
converse()
I found this 2022 bug report. Any suggestions?
h
What happens when you use 2024.2 RC?
e
@hfhbd I haven't tried that. Is there a reason to think that would work? I prefer to steer my novice students to full releases rather than RCs. I'm updating to 2024.1.6 now.
h
Maybe because the Kotlin plugin uses 2.0.0 and K2 and 2024.2 supports full K2, but didn’t check it.
k
The REPL uses whatever version of Kotlin comes with IntelliJ. Check
KotlinVersion.CURRENT
. I've got IntelliJ IDEA 2024.2 (which has recently been fully released) and it uses Kotlin 1.9.24. You'll need to compile your projects with a version of Kotlin that's not later than 1.9.
Having said that, I find the REPL a bit hard to use (it is still marked as experimental) but I find it much nicer to use a Kotlin scratch file instead (menu: New -> Scratch File).
e
Thank you. I was planning to use Kotlin 2, but 1.9 is fine.
Thanks for those tips! I was able to get the REPL working by changing the compiler version to 1.9.0, but I like the scratch file, which I hadn't tried before.
👍 1