2.4.0 beta1 fix - #26
Conversation
Fix FirExtensionRegistrarAdapter cast error by changing return type to IrAnnotation. Also adds compatibility with Kotlin 2.4.0-Beta1
|
Hello @dropbeardevs |
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. |
|
Re @dropbeardevs! |
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.