Skip to content
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

Fix class range removal logic after a method overload #593

Merged
merged 1 commit into from Jan 31, 2021

Conversation

alangpierce
Copy link
Owner

Class field handling generates a rangesToRemove array describing the tokens
that we should remove as we walk the class, but the logic expected us to always
visit exactly the start token of each range. When a class body has method
overloads, the processToken logic to handle that overload (also removing it)
was skipping over one of the ranges to remove, so none of the later ranges to
remove were being matched. To fix, we can use a >= comparison to make sure we
handle ranges to remove if they're not already handled.

Possibly a safer approach could be to revisit which ranges to remove we actually
emit so that we can be confident that processTokenisn't copying them
unexpectedly, but that would require a bit more care, and hopefully this area of
code will go away when class field support is dropped in the future.

Class field handling generates a `rangesToRemove` array describing the tokens
that we should remove as we walk the class, but the logic expected us to always
visit exactly the start token of each range. When a class body has method
overloads, the `processToken` logic to handle that overload (also removing it)
was skipping over one of the ranges to remove, so none of the later ranges to
remove were being matched. To fix, we can use a `>=` comparison to make sure we
handle ranges to remove if they're not already handled.

Possibly a safer approach could be to revisit which ranges to remove we actually
emit so that we can be confident that `processToken`isn't copying them
unexpectedly, but that would require a bit more care, and hopefully this area of
code will go away when class field support is dropped in the future.
@codecov
Copy link

codecov bot commented Jan 31, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@f1b87da). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #593   +/-   ##
=======================================
  Coverage        ?   81.87%           
=======================================
  Files           ?       55           
  Lines           ?     5571           
  Branches        ?     1314           
=======================================
  Hits            ?     4561           
  Misses          ?      726           
  Partials        ?      284           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f1b87da...d090361. Read the comment docs.

@github-actions
Copy link

Benchmark results

Before this PR: 252.1 thousand lines per second
After this PR: 253.8 thousand lines per second

Measured change: 0.67% faster (0.07% faster to 2.28% faster)
Summary: Probably faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant