Skip to content

Fix #6255: Don't check unreachability for Expr[T] #6260

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

Merged
merged 2 commits into from
Apr 10, 2019

Conversation

liufengyun
Copy link
Contributor

This seems to be the best strategy for now, given that
the implicit args trick is only used for matching Expr[T],
and case _ => is always used in such cases.

Otherwise, we will need to reason equality of Terms, which is subtle.

@smarter
Copy link
Member

smarter commented Apr 8, 2019

Otherwise, we will need to reason equality of Terms, which is subtle.

You can do =:= on termref which won't give any false positive, isn't that good enough?

@liufengyun
Copy link
Contributor Author

Otherwise, we will need to reason equality of Terms, which is subtle.

You can do =:= on termref which won't give any false positive, isn't that good enough?

That will be on the safe side, but will not help in checking Expr[T], given that the parameters are not really implicit, but some trees:

      case scala.internal.quoted.Matcher.unapply[Unit](())('{1}, x$2) => 
        ()
      case scala.internal.quoted.Matcher.unapply[Unit](())('{2}, x$2) => 

@smarter
Copy link
Member

smarter commented Apr 8, 2019

Ah that's more complicated indeed, we do have a simple structural equality implementation for trees but I don't know if it's powerful enough for what you need: https://github.com/lampepfl/dotty/blob/eae5a38f24be24fbd6f9b583a687a7738747e5a0/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala#L785-L789

This seems to be the best strategy for now, given that
the implicit args trick is only used for matching Expr[T].

Otherwise, we will need to reason equality of Terms, which is subtle.
@liufengyun liufengyun changed the title Fix #6255: Don't check exhaustivity for Expr[T] Fix #6255: Don't check unreachability for Expr[T] Apr 8, 2019
@abgruszecki
Copy link
Contributor

abgruszecki commented Apr 9, 2019

@liufengyun can we have a comment documenting why checking unreachability does not work for Expr in particular? If I understand everything correctly, it could go something like this:

// Ignore Expr for unreachability as a special case.
// Quote patterns produce repeated calls to the same unapply method,
// but with different implicit parameters.
// Since we understand repeated calls to the same unapply method to overlap
// and two unapply methods in one `match` with same arguments cannot normally have different implicits,
// the easiest solution is just to ignore Expr.

@liufengyun
Copy link
Contributor Author

@AleksanderBG Thanks for spelling it out, yes, that is what I have in mind.

Copy link
Contributor

@abgruszecki abgruszecki left a comment

Choose a reason for hiding this comment

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

LGTM!

@liufengyun liufengyun merged commit e750a8a into scala:master Apr 10, 2019
@liufengyun liufengyun deleted the fix-6255 branch April 10, 2019 11:17
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.

3 participants