Skip to content

Fix #2871: Recognize more types as structural selections #2875

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 1 commit into from
Jul 18, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jul 16, 2017

The previous condition was flawed because a type such as

{ val x: Int } && {}

should still be recognized as a structural selection of x. @LPTK, do you want to review?

The previous condition was flawed because a type such as

  { val x: Int } && {}

should still be recognized as a structural selection of `x`.
@LPTK
Copy link
Contributor

LPTK commented Jul 17, 2017

@odersky sure.

Copy link
Contributor

@LPTK LPTK left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -659,10 +659,8 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
rname == tree.name || hasRefinement(parent)
case tp: TypeProxy =>
hasRefinement(tp.underlying)
case tp: OrType =>
case tp: AndOrType =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I correct in assuming that if an intersection type has a component C that has a (non-structural) member f then a selection of .f on a value of that type will have its symbol filled in before isStructuralTermSelect is called?
Thus the condition !tree.symbol.exists below will not be satisfied, and we will not be issuing unnecessary structural selections. This is even if the type intersection also has a structural type containing a field f (on the other hand it seems like such types are consistently converted into refinements on C, e.g. C & {f:A} is represented as C{f:A} or just C if C#f =:= A).

@odersky odersky merged commit 3ce184f into scala:master Jul 18, 2017
@allanrenucci allanrenucci deleted the fix-#2871 branch December 14, 2017 19:18
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