Skip to content

Commit

Permalink
Childless
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Jul 1, 2024
1 parent 504693f commit 110379e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ object SpaceEngine {
case tp if tp.classSymbol.isAllOf(JavaEnum) => tp.classSymbol.children.map(_.termRef)
// the class of a java enum value is the enum class, so this must follow SingletonType to not loop infinitely

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

object Childless:
def unapply(tp: Type)(using Context): Result =
Result(if tp.classSymbol.children.isEmpty then tp else NoType)
class Result(val get: Type) extends AnyVal:
def isEmpty: Boolean = !get.exists

/** Show friendly type name with current scope in mind
*
* E.g. C.this.B --> B if current owner is C
Expand Down

0 comments on commit 110379e

Please sign in to comment.