Skip to content

Space: Cache space decomposition & other refactoring #16937

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

Merged
merged 16 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2905,6 +2907,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