Skip to content

Fix #1045 #1053

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 5 commits into from
Feb 8, 2016
Merged

Fix #1045 #1053

merged 5 commits into from
Feb 8, 2016

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Feb 4, 2016

Thanks for putting me on the right track here @smarter. approximateUnion was indeed to blame.
In addition to distributing `|' inside refinements I also had to work on unifying type arguments.

Review by @smarter

This gives in general a supertype, that's OK for approximation.
See ee76fda for an explanation.
See comment in Typer#approximateUnion for an explanation.
Fixes scala#1045.
The test checks that Scala collections perform within 10x of Java collections.
That's not something we need to test for dotty. And because of the heavily
parallel execution of the tests it does not always hold. This is the second
time in a a month that this particular test failed on jenkins. I think we lost
enough cycles on it.
return tp1.derivedRefinedType(
approximateUnion(OrType(tp1.parent, tp2.parent)),
tp1.refinedName,
homogenizedUnion(tp1.refinedInfo, tp2.refinedInfo).substRefinedThis(tp2, RefinedThis(tp1)))
Copy link
Member

Choose a reason for hiding this comment

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

Why not homogenizedUnion(tp1.refinedInfo, tp2.refinedInfo.substRefinedThis(tp2, RefinedThis(tp1))) ? This should require less traversals and is closer to what we were doing before ee76fda

@smarter
Copy link
Member

smarter commented Feb 5, 2016

Have you considered adding a parameter to TypeComparer#distributeOr instead to allow approximations? This would reduce the amount of traversals we would have to do, I'm not sure if the result would be more or less easy to understand than this.

@odersky
Copy link
Contributor Author

odersky commented Feb 6, 2016

@smarter After having thought about it, I believe it's better to leave approximateUnion and distributeOr separate.

tp.tp2 match {
case tp2: TypeProxy if !isClassRef(tp2) =>
approximateUnion(tp.tp1 | next(tp2))
def approximateOr(tp1: Type, tp2: Type)(implicit ctx: Context): Type = {
Copy link
Member

Choose a reason for hiding this comment

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

The implicit Context argument is unnecessary: TypeOps self-type is already a Context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. That was a leftover of a previous version where something got added to the context.

@smarter
Copy link
Member

smarter commented Feb 7, 2016

Otherwise LGTM

odersky added a commit that referenced this pull request Feb 8, 2016
@odersky odersky merged commit cb5935e into scala:master Feb 8, 2016
@smarter smarter mentioned this pull request Feb 8, 2016
@allanrenucci allanrenucci deleted the fix-#1045 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