I have a multiplatform module with just jvmMain an...
# multiplatform
m
I have a multiplatform module with just jvmMain and jvmTest source sets. It contains a kapt / ksp annotation processor which generates code based on common source set. I use
tschuchortdev:kotlin-compile-testing
library to test the processor. It all works fine until I start to use
expect
keyword in my jvmTest tested source. It complains that
The feature "multi platform projects" is experimental and should be enabled explicitly
. Fail even if I add
kotlin.mpp.stability.nowarn=true
to
gradle.properties
and
gradle-wrapper.properties
. Any ideas what might be wrong or how can I structure my tests differently?
e
the usage is
expect
in common sourceset,
actual
in jvm or other platform-specific sourcesets. if you have no common sourceset, there's no place for expect.
m
Is it a rule, though? You can compile project with both expect and
actual
in common code - I checked that recently. And if I have multi layered structure like common-ios-iosArm64/iosX64 then I should be able to use
expect
in ios and
actual
in iosArm64 and iosX64? There's probably hardly any use case for that, but nevertheless?
e
in a hierarchy (which is the default now) then yes, you can expect in any sourceset that has children. but jvm doesn't
m
OK, I will just try to use commonTest instead, wonder how that goes. Thank you :)
That didn't work either, unfortunately. I moved all the tests to commonTest and they can be run, but the tests that try to compile stuff with
expect
fail exactly the same (other tests continue to work just fine). The compiled code looks sth like this but with
expect interface InterfaceGenerationExample
. I assume the problem is that this source file from kotline-compile-testing is not really the same thing as the original source set that runs the tests and therefore different rules apply
e
are you trying to
expect
in your code at compile-time and
actual
in runtime-generated code? that won't work
m
not really. right now I'm just trying to test-compile an
expect
type. ultimately the library will only probably generate code without expect/actual, even if the annotated type is
expect
. But right now I'm just trying to write a failing, but compiling test for this.
e
ah. I don't know if kotlin-compile-testing works for that; may have to ask the developer
m
tbh, wouldn't even be mad if it complained about having an expect type without actual. but I only got
The feature "multi platform projects" is experimental and should be enabled explicitly
which doesn't sound right
yeah, I might end up filing an issue there
e
that is a message you get when trying to use
expect
in a JVM-only project (yes, it's misleading)