-
Notifications
You must be signed in to change notification settings - Fork 47
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
Unneeded @Suppress("UNSAFE_CALL") causes build warning #200
Comments
Thank you for reporting this |
It's not really a bug, but more of a deliberate choice to avoid null checking in custom actions. As you can see by the comment above in the .stg file, there is an alternative which I'll switch to as soon as error suppression isn't allowed anymore. At the moment you can ignore it, unless it somehow messes up your pipeline. |
Not urgent, just an annoying warning in the build pipeline that can't be suppressed. Thanks for looking at this! |
The difference between what the comment says and what I actually see in the compiled output is that |
IIRC the MySQL grammar we use for benchmarking has got actions that reference the parameter. I'll have a look soon tho, don't have much free time lately. |
I think I remember why we have that
Now, my comment
doesn't seem to hold true anymore, as my experiments show that we could modify other rules, such as:
I will keep investigating, but any other idea or thought is welcomed. You can also find the parser rule attributes at page 276 of the ANTL4 Reference book. |
When compiling a parser generated by antlr-kotlin 1.0.1 using Kotlin 2.0.20 and Gradle 8.11 the Kotlin compiler emits this warning:
The Suppression comes from this resource file that defines the template for semantic predicates:
https://github.com/Strumenta/antlr-kotlin/blob/master/antlr-kotlin-target/src/main/resources/org/antlr/v4/tool/templates/codegen/Kotlin/Kotlin.stg#L381-L382
The notes indicate that the function body references the
_localctx
parameter which is a nullable type. In practice, the generated functions seem to always referencecontext
instead. As an example from the parser I've attached:Attached is a Gradle project with a made-up arithmetic grammar to reproduce the error. Build with
./gradlew build
.A wild guess is that the suppression was added earlier in development and it's no longer needed, but it may also simply be that the grammars I've tried never hit a path that would cause a
_localctx
reference to be generated.issue-repro.zip
The text was updated successfully, but these errors were encountered: