Skip to content

2.4.0 beta1 fix - #26

Closed
dropbeardevs wants to merge 2 commits into
InsertKoinIO:mainfrom
dropbeardevs:2.4.0-beta1-fix
Closed

2.4.0 beta1 fix#26
dropbeardevs wants to merge 2 commits into
InsertKoinIO:mainfrom
dropbeardevs:2.4.0-beta1-fix

Conversation

@dropbeardevs

Copy link
Copy Markdown

Summary

When running the compiler plugin when the project uses Kotlin 2.4.0-Beta1, we would get this compiler error:

error message: java.lang.ClassCastException: class org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarAdapter$Companion cannot be cast to class org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor (org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarAdapter$Companion and org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor are in unnamed module of loader 'app')

This fix is to change the return type of buildDeprecatedHiddenAnnotation() from IrConstructorCall? to IrAnnotation? as the abstract annotations type changes from List in Kotlin 2.3.20 to List in version 2.4.0-Beta1, causing the cast error.

Since IrAnnotation inherits from IrConstructorCall, the cast also works with version 2.3.20, so a side benefit is that this fix is a backwards-compatible change and the plugin will work with Kotlin 2.3.20 projects, even though the plugin is compiled with version 2.4.0-Beta1.

I've also updated the golden files to match the 2.4.0-Beta1 output. There were minimum changes in the outputs with the new version of Kotlin, and all the tests pass. I've tested locally with a project compiled with both 2.4.0-Beta1 and 2.3.20.

Fix FirExtensionRegistrarAdapter cast error by changing return type to IrAnnotation.
Also adds compatibility with Kotlin 2.4.0-Beta1
@Webwag-NPA

Copy link
Copy Markdown

Hello @dropbeardevs
I tried this fork with the latest Kotlin 2.4.0-RC but there are some breaking changes between Beta1 and RC versions.
I have no experience on compiler plugin development, can you tell me if you reproduce on your side?
Thanks!

@dropbeardevs

Copy link
Copy Markdown
Author

Hello @dropbeardevs I tried this fork with the latest Kotlin 2.4.0-RC but there are some breaking changes between Beta1 and RC versions. I have no experience on compiler plugin development, can you tell me if you reproduce on your side? Thanks!

Howdy @Webwag-NPA - thank you for letting me know. I'm able to reproduce the breaking changes. It seems like there are even bigger changes with the RC version that might take a while to fix :( (such is the life of trying to keep up with compiler plugins) I'll have to dive deeper into the changes and hopefully have a fix soon.

@Webwag-NPA

Copy link
Copy Markdown

Re @dropbeardevs!
I managed to make it work based on the latest fixes branch commit using Codex: https://github.com/Webwag-NPA/koin-compiler-plugin/tree/fixes.
I still have some tests that does not pass but I don't see any regression in my application after publishing it locally.

@dropbeardevs dropbeardevs closed this by deleting the head repository Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants