Skip to content

Patmat exhaustivity checks sometimes don't consider path-dependant children #3455

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

Closed
abgruszecki opened this issue Nov 10, 2017 · 2 comments
Closed
Assignees

Comments

@abgruszecki
Copy link
Contributor

abgruszecki commented Nov 10, 2017

The following code compiles without any warnings:

trait AxisCompanion {
   sealed trait Format
   object Format {
      case object Decimal extends Format
      case object Integer extends Format
   }
}
object Axis extends AxisCompanion
class Axis {
   import Axis._
   def test( f: Format ) = f match {
      case Format.Integer => "Int"
   }
}

Note that Axis#test is inexhaustive. The underlying problem is that when children of Format are to be located, symbols for AxisCompanion.Format.Decimal and .Integer are obtained and are subsequently ousted in refine, as they are not subtypes of Axis.Format. The paths of .Decimal and .Format should be adapted to the path of their parent type.

@liufengyun - this was discovered when implementing intersection-based useless pattern checks in #3454. I found the cause for it, but as I'm running out of time and I'd prefer to focus on typechecker integration, I'm simply raising the issue here.

@liufengyun
Copy link
Contributor

@AleksanderBG Thanks for reporting, it has to do with prefix inference in child instantiation. I'll have a look.

@liufengyun liufengyun self-assigned this Nov 10, 2017
liufengyun added a commit to dotty-staging/dotty that referenced this issue Nov 14, 2017
liufengyun added a commit to dotty-staging/dotty that referenced this issue Nov 14, 2017
@liufengyun
Copy link
Contributor

Fixed in #3475

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

No branches or pull requests

2 participants