Draft
Avoid unused mutable match rebinding in AntiAliasing#1744
Conversation
|
|
Copilot
AI
changed the title
[WIP] Fix undesirable type casts and bindings in AntiAliasing phase
Avoid unused mutable match rebinding in AntiAliasing
Jun 4, 2026
Collaborator
|
What if I have in change function a more general line case Cons(n) => change(n.v) There is again no need for any casts as far as I can tell. |
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.
AntiAliasing was rebinding mutable pattern variables even when the binder was never referenced, which introduced unnecessary
asInstanceOfcasts and triggered downstream type encoding in simple matches. This change keeps the existing alias-tracking behavior for used mutable binders while leaving unused ones untouched.Normalizer change
AntiAliasingto binders that are actually referenced in the case guard or RHS.Effect on extracted trees
val n = l.asInstanceOf[Cons].nextfor cases wherenis unused.instanceOf/type-encoding noise in debug output and later phases.Regression coverage
SwapInstanceOfpattern-match case.asInstanceOf[Cons].nextrebinding.Example of the case covered by the change:
Before, AntiAliasing rewrote the
Consbranch to introduce an unused binding derived froml.asInstanceOf[Cons].next. With this change, that rebinding is only introduced when the mutable binder is actually used.