Skip to content

Commit

Permalink
Space: Cache space decomposition & other refactoring (#16937)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand authored Feb 22, 2023
2 parents 847eccc + daef636 commit a2da1a6
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 263 deletions.
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,12 @@ class Definitions {
})

@tu lazy val ListClass: Symbol = requiredClass("scala.collection.immutable.List")
def ListType: TypeRef = ListClass.typeRef
@tu lazy val ListModule: Symbol = requiredModule("scala.collection.immutable.List")
@tu lazy val NilModule: Symbol = requiredModule("scala.collection.immutable.Nil")
def NilType: TermRef = NilModule.termRef
@tu lazy val ConsClass: Symbol = requiredClass("scala.collection.immutable.::")
def ConsType: TypeRef = ConsClass.typeRef
@tu lazy val SeqFactoryClass: Symbol = requiredClass("scala.collection.SeqFactory")

@tu lazy val SingletonClass: ClassSymbol =
Expand Down
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2182,14 +2182,16 @@ object Types {

// --- NamedTypes ------------------------------------------------------------------

abstract class NamedType extends CachedProxyType, ValueType { self =>
abstract class NamedType extends CachedProxyType, ValueType, Product { self =>

type ThisType >: this.type <: NamedType
type ThisName <: Name

val prefix: Type
def designator: Designator
protected def designator_=(d: Designator): Unit
def _1: Type
def _2: Designator

assert(NamedType.validPrefix(prefix), s"invalid prefix $prefix")

Expand Down Expand Up @@ -2931,6 +2933,7 @@ object Types {
def apply(prefix: Type, designator: Name, denot: Denotation)(using Context): NamedType =
if (designator.isTermName) TermRef.apply(prefix, designator.asTermName, denot)
else TypeRef.apply(prefix, designator.asTypeName, denot)
def unapply(tp: NamedType): NamedType = tp

def validPrefix(prefix: Type): Boolean = prefix.isValueType || (prefix eq NoPrefix)
}
Expand Down
13 changes: 7 additions & 6 deletions compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package dotty.tools
package dotc
package transform

import scala.annotation.tailrec
import core._
import MegaPhase._
import collection.mutable
import Symbols._, Contexts._, Types._, StdNames._, NameOps._
import patmat.SpaceEngine
import util.Spans._
import typer.Applications.*
import SymUtils._
Expand All @@ -16,9 +15,12 @@ import Decorators._
import NameKinds.{PatMatStdBinderName, PatMatAltsName, PatMatResultName}
import config.Printers.patmatch
import reporting._
import dotty.tools.dotc.ast._
import ast._
import util.Property._

import scala.annotation.tailrec
import scala.collection.mutable

/** The pattern matching transform.
* After this phase, the only Match nodes remaining in the code are simple switches
* where every pattern is an integer or string constant
Expand All @@ -45,9 +47,8 @@ class PatternMatcher extends MiniPhase {
val translated = new Translator(matchType, this).translateMatch(tree)

// check exhaustivity and unreachability
val engine = new patmat.SpaceEngine
engine.checkExhaustivity(tree)
engine.checkRedundancy(tree)
SpaceEngine.checkExhaustivity(tree)
SpaceEngine.checkRedundancy(tree)

translated.ensureConforms(matchType)
}
Expand Down
Loading

0 comments on commit a2da1a6

Please sign in to comment.