Skip to content

Refined types can cause an exception in exhaustivity checks #2253

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 Apr 13, 2017 · 0 comments
Closed

Refined types can cause an exception in exhaustivity checks #2253

abgruszecki opened this issue Apr 13, 2017 · 0 comments

Comments

@abgruszecki
Copy link
Contributor

As in title, some refined types are not handled in SpaceEngine#expose:

sealed trait S
object O extends S
trait T
def m(s: S { val x: Int }) = s match { case _: T => ; }

Compiling this prints the trees being transformed + this error message:

Exception in thread "main" scala.MatchError: TypeRef(TermRef(ThisType(TypeRef(NoPrefix,<root>)),scala)/withSig(Signature(List(),)),Int) (of class dotty.tools.dotc.core.Types$CachedTypeRef)
	at dotty.tools.dotc.transform.patmat.SpaceEngine.expose(Space.scala:520)
	at dotty.tools.dotc.transform.patmat.SpaceEngine$$anonfun$27.apply(Space.scala:349)
	at dotty.tools.dotc.transform.patmat.SpaceEngine$$anonfun$27.apply(Space.scala:346)
	at scala.collection.TraversableLike$$anonfun$filterImpl$1.apply(TraversableLike.scala:259)
	at scala.collection.immutable.List.foreach(List.scala:381)
	at scala.collection.TraversableLike$class.filterImpl(TraversableLike.scala:258)
	at scala.collection.TraversableLike$class.filter(TraversableLike.scala:270)
	at scala.collection.AbstractTraversable.filter(Traversable.scala:104)
	at dotty.tools.dotc.transform.patmat.SpaceEngine.decompose(Space.scala:346)
	at dotty.tools.dotc.transform.patmat.SpaceLogic$class.tryDecompose1$3(Space.scala:198)
	at dotty.tools.dotc.transform.patmat.SpaceLogic$class.minus(Space.scala:206)
	at dotty.tools.dotc.transform.patmat.SpaceEngine.minus(Space.scala:243)
	at dotty.tools.dotc.transform.patmat.SpaceEngine.checkExhaustivity(Space.scala:555)
liufengyun added a commit to dotty-staging/dotty that referenced this issue Apr 13, 2017
@liufengyun liufengyun self-assigned this Apr 13, 2017
liufengyun added a commit that referenced this issue Apr 13, 2017
Fix #2253: avoid match exception in case of refinement types
liufengyun added a commit that referenced this issue Apr 14, 2017
Fix #2253 edge cases: recurse into refined type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants