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

Do not generate Return nodes for throw expressions #5082

Merged

Conversation

nicolasstucki
Copy link
Contributor

Namely throw MatchError.

@nicolasstucki nicolasstucki force-pushed the small-pattern-match-optimization branch from 831f9eb to f88c09b Compare September 5, 2018 13:39
@nicolasstucki nicolasstucki requested a review from sjrd September 5, 2018 13:39
@@ -839,7 +839,8 @@ object PatternMatcher {
default
}
case ResultPlan(tree) =>
Return(tree, ref(resultLabel))
if (tree.symbol eq defn.throwMethod) tree // Namely MatchError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want to be more general and test something like tree.tpe <:< NothingTpe instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

@nicolasstucki nicolasstucki self-assigned this Sep 5, 2018
@@ -839,7 +839,7 @@ object PatternMatcher {
default
}
case ResultPlan(tree) =>
if (tree.symbol eq defn.throwMethod) tree // Namely MatchError
if (tree.tpe <:< defn.NothingType) tree // Namely MatchError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is not accurate anymore. It should say "for example MatchError". Otherwise LGTM.

@nicolasstucki nicolasstucki merged commit eda6b0c into scala:master Sep 5, 2018
@nicolasstucki nicolasstucki deleted the small-pattern-match-optimization branch September 5, 2018 15:27
odersky added a commit to dotty-staging/dotty that referenced this pull request Jun 29, 2021
BarkingBad pushed a commit to BarkingBad/dotty that referenced this pull request Jul 23, 2021
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.

2 participants