Fix ResolverSyntheticInstanceof incorrectly converting non-boolean ModifyExpressionValue to ModifyInstanceofValue#10
Open
SavageVictor wants to merge 1 commit into
Conversation
…difyExpressionValue to ModifyInstanceofValue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a
@ModifyExpressionValuemixin targets a method call whose result is used in a nearbyinstanceofcheck,ResolverSyntheticInstanceof(via theskipInsnComparisonpath) would unconditionally convert the annotation to@ModifyInstanceofValue.This is only correct when the handler returns
boolean(i.e. it truly modifies the boolean result of the instanceof check). If the handler returns a non-boolean type — because it modifies the value fed into the instanceof check — the conversion produces an invalid method signature like(LBlock;)LBlock;where(Z)Zis required, crashing at mixin apply time with:Reproduction
BigGlobe's
Biome_DontFreezeRiverWatermixin uses@ModifyExpressionValuewith handler signature(Block)BlocktargetingBlockState.getBlock(), whose result is then compared viainstanceof FluidBlock. The converter sees the nearbyinstanceofand incorrectly rewrites the mixin as@ModifyInstanceofValue, crashing the game on bootstrap.Fix
Before converting, check the handler's return type via
Type.getReturnType(context.methodNode().desc). If it is notboolean, skip the conversion and returnpass().Testing
Minecraft: 1.21.1
NeoForge: 21.1.172
With the fix applied,
Biome_DontFreezeRiverWateris correctly left as@ModifyExpressionValueand the game boots successfully.