Skip to content

Simplify merging in lub/glb, avoid unnecessary constraints #9053

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
Jun 1, 2020

Conversation

smarter
Copy link
Member

@smarter smarter commented May 26, 2020

In mergeIfSuper, to simplify tp1 | tp2, we first check if tp2 can
be made a subtype of tp1. If so we could just return tp1 but this
isn't what we did before this commit: at that point we checked if tp1
could be made a subtype of tp2 and in that case prefered returning
tp2 to tp1. I haven't been able to find a reason for this (the
comment says "keep existing type if possible" which I don't understand).

On the other hand, I've found cases where this logic broke type
inference because the second subtype check inferred extraneous
constraints (see added testcase). So this commit simply removes this
logic, it does the same for mergeIfSub which contains similar logic to
simplify tp1 & tp2, though this one is less problematic since it
always runs with frozen constraints.

In `mergeIfSuper`, to simplify `tp1 | tp2`, we first check if `tp2` can
be made a subtype of `tp1`. If so we could just return `tp1` but this
isn't what we did before this commit: at that point we checked if `tp1`
could be made a subtype of `tp2` and in that case prefered returning
`tp2` to `tp1`. I haven't been able to find a reason for this (the
comment says "keep existing type if possible" which I don't understand).

On the other hand, I've found cases where this logic broke type
inference because the second subtype check inferred extraneous
constraints (see added testcase). So this commit simply removes this
logic, it does the same for `mergeIfSub` which contains similar logic to
simplify `tp1 & tp2`, though this one is less problematic since it
always runs with frozen constraints.
@smarter smarter requested a review from odersky May 26, 2020 15:54
@odersky
Copy link
Contributor

odersky commented May 26, 2020

check performance please

@odersky
Copy link
Contributor

odersky commented May 26, 2020

test performance please

@dottybot
Copy link
Member

performance test scheduled: 1 job(s) in queue, 0 running.

@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/9053/ to see the changes.

Benchmarks is based on merging with master (587945b)

@odersky
Copy link
Contributor

odersky commented May 29, 2020

Let's try the performance test again. I really wish we had more precision here.

@odersky
Copy link
Contributor

odersky commented May 29, 2020

test performance please

1 similar comment
@odersky
Copy link
Contributor

odersky commented May 29, 2020

test performance please

@dottybot
Copy link
Member

performance test scheduled: 2 job(s) in queue, 1 running.

@odersky
Copy link
Contributor

odersky commented May 30, 2020

test performance please

@odersky
Copy link
Contributor

odersky commented May 30, 2020

performance tests seem to have a mind of their own whether they agree to run something 😉

@smarter
Copy link
Member Author

smarter commented May 30, 2020

@liufengyun is the benchmark test stuck?

@liufengyun
Copy link
Contributor

I have manually scheduled the job.

The benchmark test encountered a problem related to a mistake in the PR #9055 (see lampepfl/bench#201), I've fixed that manually.

We fixed one problem related to the bot being not responsive recently (lampepfl/bench#170). But it seems there might be other problems (most likely related to network). I'll have a look.

@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/9053/ to see the changes.

Benchmarks is based on merging with master (e5e489e)

@odersky odersky merged commit d2bc109 into scala:master Jun 1, 2020
@odersky odersky deleted the merge-constraint branch June 1, 2020 10:51
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.

4 participants