Skip to content

Fix #360: Improve avoidance algorithm #2078

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 4 commits into from
Mar 12, 2017
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 12, 2017

The essential change is that we do not throw away more
precise info of the avoided type if the expected type
is fully defined.

The essential change is that we do not throw away more
precise info of the avoided type if the expected type
is fully defined.
@odersky odersky requested a review from smarter March 12, 2017 11:27
@smarter
Copy link
Member

smarter commented Mar 12, 2017

I don't see how this is related to #1569, did you mean some other issue number? I can suggest #360 which I'm happy to see is fixed by this PR!

@odersky
Copy link
Contributor Author

odersky commented Mar 12, 2017

Oh, it was SI-1569, not our issues.

@odersky odersky changed the title Fix #1569: Improve avoidance algorithm Fix #360: Improve avoidance algorithm Mar 12, 2017
val tree1 = ascribeType(tree, avoid(tree.tpe, localSyms))
ensureNoLocalRefs(tree1, pt, localSyms, forcedDefined = true)
} else
val avoidingType = avoid(tree.tpe, localSyms)
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 on top of this method needs to be updated now that the order of operations changed.

@odersky
Copy link
Contributor Author

odersky commented Mar 12, 2017

@smarter I investigated whether we could base TypeAssigner#avoid on ApproximatingTypeMap. But it seems to be pretty tricky to do so, so for the moment I abandoned the effort. See branch change-avoid-via-approx on staging for the current state of the effort. We still get discrepancies where the new avoid is not as good as the old one. I am going to let it be for now, but if you want to take a look please go ahead.

/** Ensure that an expression's type can be expressed without references to locally defined
* symbols. This is done by adding a type ascription of a widened type that does
* not refer to the locally defined symbols. The widened type is computed using
* `TyperAssigner#avoid`. However, if the expected type is fully defined and not
Copy link
Member

Choose a reason for hiding this comment

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

typo: TyperAssigner -> TypeAssigner

@smarter
Copy link
Member

smarter commented Mar 12, 2017

We still get discrepancies where the new avoid is not as good as the old one. I am going to let it be for now, but if you want to take a look please go ahead.

Thanks! I'll see if I have time to have a look.

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@smarter smarter merged commit 4f15021 into scala:master Mar 12, 2017
@allanrenucci allanrenucci deleted the fix-#1569-v2 branch December 14, 2017 16:59
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