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

SI-7877 Only look for unapplies in term trees #2992

Merged
merged 1 commit into from Sep 27, 2013

Conversation

retronym
Copy link
Member

Since Scala 2.10.2, the enclosed test case has crashed
in the backend. Before, we correctly rejected this pattern match.

My bisection landed at a merge commit f16f4ab, although both
parents were good. So I don't quite trust that.

I do think the regression stems from the changes to allow:

case rx"AB(.+)" =>

Examples of this are in run/t7715.scala.

This commit limits the search for extractors to cases where the
function within the Apply is a term tree.

Review by @xeno-by

@@ -3245,7 +3245,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
if (!tree.isErrorTyped) setError(tree) else tree
// @H change to setError(treeCopy.Apply(tree, fun, args))

case ExtractorType(unapply) if mode.inPatternMode =>
case ExtractorType(unapply) if mode.inPatternMode && fun.isTerm =>
Copy link
Member

Choose a reason for hiding this comment

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

How about integrating this check into ExtractorType?

Copy link
Member Author

Choose a reason for hiding this comment

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

Won't work: that's only considering the type, and the extra test must be made on the tree to exclude TypeTree(<C[T]>) but allow Ident("X") or <<RichSC(StringContext()).rx>>.

Copy link
Member

Choose a reason for hiding this comment

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

Oh wow, didn't realize it's so complicated. Then how about renaming ExtractorType, so that it doesn't trick people into it being an ultimate authority? Something like HasUnapplyMember. Also a comment here most definitely will help.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Since Scala 2.10.2, the enclosed test case has crashed
in the backend. Before, we correctly rejected this pattern match.

My bisection landed at a merge commit f16f4ab, although both
parents were good. So I don't quite trust that.

I do think the regression stems from the changes to allow:

    case rx"AB(.+)" =>

Examples of this are in run/t7715.scala.

This commit limits the search for extractors to cases where the
function within the Apply is a term tree.
@xeno-by
Copy link
Member

xeno-by commented Sep 27, 2013

lgtm

retronym added a commit that referenced this pull request Sep 27, 2013
 Only look for unapplies in term trees
@retronym retronym merged commit 091f3ba into scala:master Sep 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants