-
Notifications
You must be signed in to change notification settings - Fork 177
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
Calls to static @Invoker methods with dummy body cause "unreachable code" warnings #2284
Comments
|
IntelliJ is too smart for its own good. |
Unfortunately this is not easy to fix. IntelliJ's dataflow inspections are hardcoded with no extension points for plugins. There is no way to tell it that actually no, this expression won't throw, and prevent it from highlighting the subsequent code as unused. So far the inspection has only highlighted the casts themselves, so we were able to check for a mixin cast and suppress the highlight. However this is hard to tell the difference between actually unreachable code and bogus unreachable code without unreliable heuristics. |
Perhaps a pull request adding the required extension points could be made to intellij community edition |
Note that JetBrains will be disabling this inspection by default as it is causing problems with other frameworks too: https://youtrack.jetbrains.com/issue/IDEA-352283 |
Minecraft Development for IntelliJ plugin version
2024.1-1.7.4
IntelliJ version
2024.1
Operating System
Linux Mint 21.1
Target platform
Mixins
Description of the bug
Mixins that define an
@Invoker
for a static target method are required to provide a body for the mixin method, but these methods are usually implemented to always throw an exception, for example:The target method (
net.minecraft.advancements.CriteriaTriggers#register
) usually completes without throwing an exception. However, code using that invoker method causes following lines to be reported as "unreachable code" by IntelliJ:(Code from Botania repository: https://github.com/VazkiiMods/Botania classes vazkii.botania.mixin.CriteriaTriggersAccessor and vazkii.botania.common.advancements.BotaniaCriteriaTriggers from the Xplat module, targeting Minecraft 1.20.1)
The text was updated successfully, but these errors were encountered: