Skip to content

Commit

Permalink
Merge pull request #9211 from dwijnand/exhaust-private-is-effectively…
Browse files Browse the repository at this point in the history
…-sealed

Treat private as "effectively sealed"
  • Loading branch information
lrytz committed Sep 18, 2020
2 parents e11c86b + 326ab01 commit 575b225
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -121,7 +121,7 @@ trait TreeAndTypeAnalysis extends Debugging {
def enumerateChildren(sym: Symbol) = {
sym.sealedChildren.toList
.sortBy(_.sealedSortName)
.filterNot(x => x.isSealed && x.isAbstractClass && !isPrimitiveValueClass(x))
.filterNot(x => (x.isSealed || x.isPrivate) && x.isAbstractClass && !isPrimitiveValueClass(x))
}

// enumerate only direct subclasses,
Expand All @@ -147,7 +147,7 @@ trait TreeAndTypeAnalysis extends Debugging {
// all of their children must be and they cannot otherwise be created.
sym.sealedDescendants.toList
sortBy (_.sealedSortName)
filterNot (x => x.isSealed && x.isAbstractClass && !isPrimitiveValueClass(x))
filterNot (x => (x.isSealed || x.isPrivate) && x.isAbstractClass && !isPrimitiveValueClass(x))
)

List(debug.patmatResult(s"enum sealed tp=$tp, tpApprox=$tpApprox as") {
Expand Down
11 changes: 11 additions & 0 deletions test/files/pos/t6159.scala
@@ -0,0 +1,11 @@
// scalac: -Werror
trait A {
sealed abstract class X
private class X1 extends X with X2 { }
private trait X2 extends X
sealed trait X3 extends X

def f(x: X) = x match {
case _: X1 => 0
}
}

0 comments on commit 575b225

Please sign in to comment.