Skip to content

use ApproximatingTypeMap to simplify exhaustivity check code #4299

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
Apr 13, 2018

Conversation

liufengyun
Copy link
Contributor

use ApproximatingTypeMap to simplify exhaustivity check code

if (maximize) lo else hi
// expose type param references to their bounds according to variance
class AbstractTypeMap(maximize: Boolean)(implicit ctx: Context) extends ApproximatingTypeMap {
variance = if (maximize) 1 else -1

def apply(tp: Type): Type = tp match {
case tp: TypeRef if tp.underlying.isInstanceOf[TypeBounds] =>
Copy link
Contributor

Choose a reason for hiding this comment

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

While you're at it, maybe replace this by tp.symbol.isTypeParam

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@allanrenucci : tp.symbol.isTypeParam will miss the case where the reference is a type member.

@allanrenucci allanrenucci merged commit ab02870 into scala:master Apr 13, 2018
@allanrenucci allanrenucci deleted the refactor-space-check branch April 13, 2018 15:07
liufengyun added a commit to dotty-staging/dotty that referenced this pull request Apr 17, 2018
1. ApproximatingTypeMap produces Nothing, which is not what is needed.
2. Avoid blind erasure which lose information about the pattern, see tests/patmat/i4314b.scala
liufengyun added a commit that referenced this pull request Apr 20, 2018
gsps pushed a commit to gsps/dotty that referenced this pull request Apr 21, 2018
1. ApproximatingTypeMap produces Nothing, which is not what is needed.
2. Avoid blind erasure which lose information about the pattern, see tests/patmat/i4314b.scala
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.

3 participants