Skip to content

Commit a2da1a6

Browse files
authored
Space: Cache space decomposition & other refactoring (#16937)
2 parents 847eccc + daef636 commit a2da1a6

File tree

7 files changed

+247
-263
lines changed

7 files changed

+247
-263
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,12 @@ class Definitions {
530530
})
531531

532532
@tu lazy val ListClass: Symbol = requiredClass("scala.collection.immutable.List")
533+
def ListType: TypeRef = ListClass.typeRef
533534
@tu lazy val ListModule: Symbol = requiredModule("scala.collection.immutable.List")
534535
@tu lazy val NilModule: Symbol = requiredModule("scala.collection.immutable.Nil")
536+
def NilType: TermRef = NilModule.termRef
535537
@tu lazy val ConsClass: Symbol = requiredClass("scala.collection.immutable.::")
538+
def ConsType: TypeRef = ConsClass.typeRef
536539
@tu lazy val SeqFactoryClass: Symbol = requiredClass("scala.collection.SeqFactory")
537540

538541
@tu lazy val SingletonClass: ClassSymbol =

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2182,14 +2182,16 @@ object Types {
21822182

21832183
// --- NamedTypes ------------------------------------------------------------------
21842184

2185-
abstract class NamedType extends CachedProxyType, ValueType { self =>
2185+
abstract class NamedType extends CachedProxyType, ValueType, Product { self =>
21862186

21872187
type ThisType >: this.type <: NamedType
21882188
type ThisName <: Name
21892189

21902190
val prefix: Type
21912191
def designator: Designator
21922192
protected def designator_=(d: Designator): Unit
2193+
def _1: Type
2194+
def _2: Designator
21932195

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

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

29352938
def validPrefix(prefix: Type): Boolean = prefix.isValueType || (prefix eq NoPrefix)
29362939
}

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ package dotty.tools
22
package dotc
33
package transform
44

5-
import scala.annotation.tailrec
65
import core._
76
import MegaPhase._
8-
import collection.mutable
97
import Symbols._, Contexts._, Types._, StdNames._, NameOps._
8+
import patmat.SpaceEngine
109
import util.Spans._
1110
import typer.Applications.*
1211
import SymUtils._
@@ -16,9 +15,12 @@ import Decorators._
1615
import NameKinds.{PatMatStdBinderName, PatMatAltsName, PatMatResultName}
1716
import config.Printers.patmatch
1817
import reporting._
19-
import dotty.tools.dotc.ast._
18+
import ast._
2019
import util.Property._
2120

21+
import scala.annotation.tailrec
22+
import scala.collection.mutable
23+
2224
/** The pattern matching transform.
2325
* After this phase, the only Match nodes remaining in the code are simple switches
2426
* where every pattern is an integer or string constant
@@ -45,9 +47,8 @@ class PatternMatcher extends MiniPhase {
4547
val translated = new Translator(matchType, this).translateMatch(tree)
4648

4749
// check exhaustivity and unreachability
48-
val engine = new patmat.SpaceEngine
49-
engine.checkExhaustivity(tree)
50-
engine.checkRedundancy(tree)
50+
SpaceEngine.checkExhaustivity(tree)
51+
SpaceEngine.checkRedundancy(tree)
5152

5253
translated.ensureConforms(matchType)
5354
}

0 commit comments

Comments
 (0)