Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization fails with Kotlin 2.0.0-Beta4 and K2 Kapt flag enabled #2580

Closed
aftabahmadTW opened this issue Feb 26, 2024 · 3 comments
Closed
Assignees
Labels

Comments

@aftabahmadTW
Copy link

aftabahmadTW commented Feb 26, 2024

Describe the bug
Not sure if this is the best place to report it. I was trying out Kotlin 2.0.0-Beta4 in our company codebase. When trying it with kapt.use.k2 set to true, we noticed that we were getting errors in the generated code for serialization.

Stack trace provided:

> Task :app:kaptGenerateStubsDebugKotlin
w: K2 kapt is an experimental feature. Use with caution.

> Task :app:kaptDebugKotlin FAILED
serialization/app/build/tmp/kapt3/stubs/debug/com/sample/serialization/response/SampleResponse.java:94: error: illegal '.'
        public static final com.sample.serialization.response.SampleResponse..serializer INSTANCE = null;

You can see it generates the code with a double dot here: SampleResponse..serializer

To Reproduce
serialization.zip

I attached a small sample which highlights this issue. If you set kapt.use.k2=false then the project compiles and runs however setting it to true causes the issue above.

Hopefully the sample is useful.

Expected behavior
I would expect that kapt doesn't interfere with kotlinx-serialization.

Environment

  • Kotlin version: 2.0.0-Beta4
  • Library version: 1.6.3
  • Kotlin platforms: Android
  • Gradle version: 8.2
  • Other relevant context: kapt.use.k2=true
@pdvrieze
Copy link
Contributor

Does the serialization work without kapt but with the k2 compiler enabled?

@aftabahmadTW
Copy link
Author

aftabahmadTW commented Feb 27, 2024

Yes, if kapt isn't involved it works or if the flag kapt.use.k2 is false that also works.

@sandwwraith sandwwraith self-assigned this Feb 27, 2024
@sandwwraith
Copy link
Member

Looks like you've already filed https://youtrack.jetbrains.com/issue/KT-66147 which is resolved by https://youtrack.jetbrains.com/issue/KT-65399 in Beta-5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants