Skip to content

Fix #2998: Constrain type from above before interpolating variables #3774

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 2 commits into from
Jan 12, 2018

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 7, 2018

When interpolating type variables we should use all available information
at this point, including the expected result type. One situation where this makes
a difference is if the expected type is a singleton type, because type variables
are instantiated to singleton types only if their upper bounds are singleton types.

Also fixes #2997.

@odersky
Copy link
Contributor Author

odersky commented Jan 7, 2018

test performance please

@dottybot
Copy link
Member

dottybot commented Jan 7, 2018

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

@dottybot
Copy link
Member

dottybot commented Jan 7, 2018

Performance test finished successfully:

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

Benchmarks is based on merging with master (7e402a7)

When interpolating type variables we should use all available information
at this point, including the expected result type. One situation where this makes
a difference is if the expected type is a singleton type, because type variables
are instantiated to singleton types only if their upper bounds are singleton types.

Also fixes scala#2997.
@odersky
Copy link
Contributor Author

odersky commented Jan 7, 2018

test performance please

@dottybot
Copy link
Member

dottybot commented Jan 7, 2018

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

@dottybot
Copy link
Member

dottybot commented Jan 7, 2018

Performance test finished successfully:

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

Benchmarks is based on merging with master (7e402a7)

Performance tests indicated a 3% slowdown for dotty. Trying to mitigate that
by avoiding constraining types multiple times.
@odersky
Copy link
Contributor Author

odersky commented Jan 8, 2018

test performance please

@dottybot
Copy link
Member

dottybot commented Jan 8, 2018

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

@dottybot
Copy link
Member

dottybot commented Jan 8, 2018

Performance test finished successfully:

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

Benchmarks is based on merging with master (7e402a7)

@odersky
Copy link
Contributor Author

odersky commented Jan 8, 2018

The last commit seemed to have helped performance, so we are good on that count, I think.

case _ => false
}

var isConstrained = false
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be cleaner to do:

var isConstrained = tree.isInstanceOf[Apply] || tree.tpe.isInstanceOf[MethodOrPoly]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw that comment to late, after merging. I'll attach the change to a subsequent PR.

@odersky odersky merged commit fbe4237 into scala:master Jan 12, 2018
@allanrenucci allanrenucci deleted the fix-#2998 branch January 13, 2018 09:22
odersky added a commit to dotty-staging/dotty that referenced this pull request Jan 13, 2018
This commit cleans up a piece of code of scala#3774 (which is already merged).
It was suggested in review comments.
odersky added a commit to dotty-staging/dotty that referenced this pull request Jan 14, 2018
This commit cleans up a piece of code of scala#3774 (which is already merged).
It was suggested in review comments.
odersky added a commit to dotty-staging/dotty that referenced this pull request Jan 15, 2018
This commit cleans up a piece of code of scala#3774 (which is already merged).
It was suggested in review comments.
allanrenucci added a commit to allanrenucci/dotty that referenced this pull request Jan 23, 2018
This commit cleans up a piece of code of scala#3774 (which is already
merged). It was suggested in a review comments.
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.

Special handling in the typer of scala.Singleton is missing
3 participants