Skip to content

Commit 5994ea7

Browse files
committed
Childless
1 parent 3ba51a6 commit 5994ea7

File tree

1 file changed

+7
-1
lines changed
  • compiler/src/dotty/tools/dotc/transform/patmat

1 file changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

+7-1
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ object SpaceEngine {
616616
case tp if tp.classSymbol.isAllOf(JavaEnum) => tp.classSymbol.children.map(_.termRef)
617617
// the class of a java enum value is the enum class, so this must follow SingletonType to not loop infinitely
618618

619-
case tp @ AppliedType(Parts(parts), targs) if tp.classSymbol.children.isEmpty =>
619+
case Childless(tp @ AppliedType(Parts(parts), targs)) =>
620620
// It might not obvious that it's OK to apply the type arguments of a parent type to child types.
621621
// But this is guarded by `tp.classSymbol.children.isEmpty`,
622622
// meaning we'll decompose to the same class, just not the same type.
@@ -676,6 +676,12 @@ object SpaceEngine {
676676
final class PartsExtractor(val get: List[Type]) extends AnyVal:
677677
def isEmpty: Boolean = get == ListOfNoType
678678

679+
object Childless:
680+
def unapply(tp: Type)(using Context): Result =
681+
Result(if tp.classSymbol.children.isEmpty then tp else NoType)
682+
class Result(val get: Type) extends AnyVal:
683+
def isEmpty: Boolean = !get.exists
684+
679685
/** Show friendly type name with current scope in mind
680686
*
681687
* E.g. C.this.B --> B if current owner is C

0 commit comments

Comments
 (0)