-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
The essential change is that we do not throw away more precise info of the avoided type if the expected type is fully defined.
Oh, it was SI-1569, not our issues. |
val tree1 = ascribeType(tree, avoid(tree.tpe, localSyms)) | ||
ensureNoLocalRefs(tree1, pt, localSyms, forcedDefined = true) | ||
} else | ||
val avoidingType = avoid(tree.tpe, localSyms) |
There was a problem hiding this comment.
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.
No more try-again business necessary.
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: TyperAssigner -> TypeAssigner
Thanks! I'll see if I have time to have a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
The essential change is that we do not throw away more
precise info of the avoided type if the expected type
is fully defined.