Testing upgrading my project to Kotlin 1.9.0, and ...
# compiler
Testing upgrading my project to Kotlin 1.9.0, and I'm getting a compile error with Gradle code that was working in 1.8.20. (Will drop details in a 🧵 ) Is this the right channel to ping? Just want to double check if it's user error before filing a bug. But if this is real, I can't imagine I'd be the only one hitting it...
Problematic line is here: https://github.com/varabyte/kobweb/blob/0f0c6a48d68efadeda4236263a075329c5583446/g[…]main/kotlin/com/varabyte/kobweb/gradle/core/KobwebCorePlugin.kt
Copy code
project.buildTargets.withType<KotlinJsIrTarget>.configureEach {
  val jsTarget = JsTarget(this)
The "this" going into the callback should be
but with Kotlin 1.9.0 I'm getting this error:
Copy code
e: file:///home/d9n/Code/scratch/kobweb/gradle-plugins/core/src/main/kotlin/com/varabyte/kobweb/gradle/core/KobwebCorePlugin.kt:54:37 Type mismatch: inferred type is KobwebCorePlugin but KotlinJsIrTarget was expected
so it thinks "this" is coming from the parent scope.
The Gradle API here is Java:
Copy code
void configureEach(Action<? super T> action);

public interface Action<T> {
     * Performs this action against the given object.
     * @param t The object to perform the action on.
    void execute(T t);
I wonder if
is doing something funky that is confusing the Kotlin 1.9.0 compiler? Because I'm having trouble imagining how to create such a functional interface manually.
Copy code
fun interface Action<T> {
  fun T.execute()
If anyone wants to repro, here's the steps I have currently • In a tmp dir somewhere... •
git clone <https://github.com/varabyte/kobweb> && cd kobweb
• Edit
compose = 1.4.1
compose = 1.4.3
kotlin = 1.8.20
kotlin = 1.9.0
./gradlew :gradle-plugins:core:build
Of course, if anyone has a project with a Gradle plugin that uses configureEach, then I guess they should update the compiler to Kotlin 1.9.0 and see if it's working there?
Gradle code should use the embedded Kotlin version that ships with Gradle; no Gradle version currently supports 1.9.0. Note this is separate from using
which configures Kotlin for your application code.
The list of embedded Kotlin versions is here.
You are the only one hitting this (well, likely a small group) due to tweaking Gradle internals that aren’t designed to be changed.
A quick review of your repo shows several challenges, primarily mixing
and `kotlin("jvm")`:
Copy code
plugins {
	// this brings in embedded kotlin + java-gradle-plugin and a few other settings

    // never mix this with `kotlin-dsl` - either a module is building Gradle code (`kotlin-dsl`) or application code (kotlin("jvm)"))

    // both of these are redundant, included via `kotlin-dsl`

You can, of course, upgrade the application code (not the plugins) to Kotlin 1.9.0 separately from the embedded Kotlin version with Gradle.
fyi, this topic is better suited for #gradle
Thanks for clarifying! Makes sense.