fix(compiler): Fix compatibility with Kotlin 2.3.0#1046
Conversation
| override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) { | ||
| val messageCollector = | ||
| configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE) | ||
| val pluginId: String = PLUGIN_ID |
There was a problem hiding this comment.
Bug: The SentryKotlinCompilerPlugin class is missing the override keyword for the pluginId property, which is required to implement the abstract property from CompilerPluginRegistrar in Kotlin 2.3.0.
Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The SentryKotlinCompilerPlugin class implements CompilerPluginRegistrar, which in Kotlin 2.3.0 introduced a new abstract property pluginId. The implementation in SentryKotlinCompilerPlugin.kt defines pluginId but is missing the required override keyword. This will cause a compilation error, such as "Unimplemented abstract member," for any user compiling their project with Kotlin 2.3.0 or later. This prevents the compiler plugin from loading and breaks the build, despite the PR's goal of adding compatibility for this Kotlin version.
💡 Suggested Fix
Add the override keyword to the pluginId property in the SentryKotlinCompilerPlugin class. The line should be changed from val pluginId: String = PLUGIN_ID to override val pluginId: String = PLUGIN_ID to correctly implement the abstract property from the superclass.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location:
sentry-kotlin-compiler-plugin/src/main/kotlin/io/sentry/SentryKotlinCompilerPlugin.kt#L23
Potential issue: The `SentryKotlinCompilerPlugin` class implements
`CompilerPluginRegistrar`, which in Kotlin 2.3.0 introduced a new abstract property
`pluginId`. The implementation in `SentryKotlinCompilerPlugin.kt` defines `pluginId` but
is missing the required `override` keyword. This will cause a compilation error, such as
"Unimplemented abstract member," for any user compiling their project with Kotlin 2.3.0
or later. This prevents the compiler plugin from loading and breaks the build, despite
the PR's goal of adding compatibility for this Kotlin version.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 7832056
There was a problem hiding this comment.
Weird that this isn't a compile error if true.
There was a problem hiding this comment.
yeah, this is true, but we have to compile against 2.3.0 for that and currently we're not doing that 😅 So we're tricking the compilation process here a bit, but at the "runtime" of the plugin it's present and not throwing.
I'm thinking compiling against 2.3.0 might break compatibility with older versions, so I decided to go for this middle-ground until we bump it later on.
📜 Description
Specifies
pluginIdintroduced in Kotlin 2.3.0 for CompilerPluginRegistrar💡 Motivation and Context
Fixes #1042
💚 How did you test it?
Manually
📝 Checklist
🔮 Next steps