Open JakeWharton opened 1 year ago
Thanks!
Hi @JakeWharton! I started to look into this issue and I'm a bit surprised with what I see now.
First I wanted it to fail at compile time instead of at runtime, so I added:
allprojects {
afterEvaluate {
tasks.withType(KotlinJsCompile.class) {
kotlinOptions.freeCompilerArgs += [
"-Xpartial-linkage=disable"
]
}
}
}
But it didn't fail at compile time, and it made it work at runtime too. I'm wondering if adding this flag would make all of your tests pass with k/js. In the meantime I'll ask kotlin team if it's expected - it doesn't seem to be right.
Oh, interesting. I will try later today/tonight on the real project.
edit: It worked!
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Experiencing this problem while upgrading to Kotlin 1.9.0 and Compose compiler 1.5.0.
Here is a minimally-reproducing sample: compose-js-duplicate-signatures.zip. Running
./gradlew build
will exhibit the failure.First, in the build I see this warning:
Compilation of this type and subsequent tests for this type work on every other target (JVM and a bunch of native). Only JS exhibits this problem. (Note: I have disabled all targets except JS in the sample above, but they exist in the real project)
The
insert
function is defined in theWidget.Children
interface in the 'redwood-widget' module.The
ComposeWidgetChildren
implementation in the 'redwood-widget-compose' module does override it with a generic type parameter that is a composable lambda.The JS tests for the 'redwood-widget-compose' module will fail with
Peeking at the
redwood-redwood-widget-compose.js
file, we see this:This is the real implementation whose signature has been transformed with a
$composable
name part (despite not actually being a composable function), then presumably theinsert_4q
function is the override. But then we get thisinsert_n0
function which is some kind of abstract placeholder, and then anotherinsert_4q
which invokes that placeholder (and thus overrides the firstinsert_4q
override).If you disable the Compose compiler in this module the latter two functions disappear. The test obviously still fails at runtime, but with an
IllegalStateException
about the Compose compiler not being run after theinsert
function was successfully invoked.When using Kotlin 1.8.22 and JB Compose compiler 1.4.8 only the first two JS functions are generated and the compilation and test both succeed.