Skip to content

Commit 6cc53c7

Browse files
committed
Finish rebase over dotty upstream
1 parent f79f06f commit 6cc53c7

File tree

7 files changed

+13
-7
lines changed

7 files changed

+13
-7
lines changed

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import Periods._
77
import Symbols._
88
import Types._
99
import Scopes._
10-
import typer.{FrontEnd, Typer, ImportInfo, RefChecks}
11-
import reporting.{Reporter, ConsoleReporter}
10+
import typer.{FrontEnd, ImportInfo, RefChecks, Typer}
11+
import reporting.{ConsoleReporter, Reporter}
1212
import Phases.Phase
1313
import transform._
1414
import util.FreshNameCreator
1515
import transform.TreeTransforms.{TreeTransform, TreeTransformer}
1616
import core.DenotTransformers.DenotTransformer
1717
import core.Denotations.SingleDenotation
18-
19-
import dotty.tools.backend.jvm.{LabelDefs, GenBCode, CollectSuperCalls}
18+
import dotty.tools.backend.jvm.{CollectSuperCalls, GenBCode, LabelDefs}
19+
import dotty.tools.dotc.transform.linker.Simplify
2020

2121
/** The central class of the dotc compiler. The job of a compiler is to create
2222
* runs, which process given `phases` in a given `rootContext`.
@@ -60,6 +60,9 @@ class Compiler {
6060
new HoistSuperArgs, // Hoist complex arguments of supercalls to enclosing scope
6161
new ClassOf), // Expand `Predef.classOf` calls.
6262
List(new TryCatchPatterns, // Compile cases in try/catch
63+
new PatternConstantsFactorization, // extract common constant matches from patterns
64+
new PatternTypeFactorization, // extract common type matches from patterns
65+
6366
new PatternMatcher, // Compile pattern matches
6467
new ExplicitOuter, // Add accessors to outer classes from nested ones.
6568
new ExplicitSelf, // Make references to non-trivial self types explicit as casts
@@ -74,6 +77,7 @@ class Compiler {
7477
new ElimByName, // Expand by-name parameter references
7578
new AugmentScala2Traits, // Expand traits defined in Scala 2.11 to simulate old-style rewritings
7679
new ResolveSuper, // Implement super accessors and add forwarders to trait methods
80+
new Simplify, // Perform local optimizations, simplified versions of what linker does.
7781
new PrimitiveForwarders, // Add forwarders to trait methods that have a mismatch between generic and primitives
7882
new ArrayConstructors), // Intercept creation of (non-generic) arrays and intrinsify.
7983
List(new Erasure), // Rewrite types to JVM model, erasing all type parameters, abstract types and refinements.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ object StdNames {
434434
val isArray: N = "isArray"
435435
val isDefinedAt: N = "isDefinedAt"
436436
val isDefinedAtImpl: N = "$isDefinedAt"
437+
val isDefined: N = "isDefined"
437438
val isEmpty: N = "isEmpty"
438439
val isInstanceOf_ : N = "isInstanceOf"
439440
val java: N = "java"

src/dotty/tools/dotc/transform/linker/Analysis.scala renamed to compiler/src/dotty/tools/dotc/transform/linker/Analysis.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object Analysis {
5656
"scala.runtime.BoxesRunTime.unboxToChar",
5757
"scala.runtime.BoxesRunTime.unboxToFloat"
5858
)
59-
59+
6060
def effectsDontEscape(t: Tree)(implicit ctx: Context) = {
6161
t match {
6262
case Apply(fun, args) if fun.symbol.isConstructor && constructorWhiteList.contains(fun.symbol.owner.fullName.toString) =>

src/dotty/tools/dotc/transform/PatternConstantsFactorization.scala renamed to compiler/src/dotty/tools/dotc/transform/linker/PatternConstantsFactorization.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,5 @@ class PatternConstantsFactorization extends PatternFactorization {
110110
val innerMatch = transformFollowing(Match(selector, cases))
111111
CaseDef(pattern, EmptyTree, innerMatch)
112112
}
113+
113114
}

src/dotty/tools/dotc/transform/PatternFactorization.scala renamed to compiler/src/dotty/tools/dotc/transform/linker/PatternFactorization.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import TreeTransforms._
2525
trait PatternFactorization extends MiniPhaseTransform {
2626
import dotty.tools.dotc.ast.tpd._
2727

28-
protected def asInnerMatchIfNeeded(caseDefs: List[CaseDef], fallbackOpt: Option[Tree])(implicit ctx: Context, info: TransformerInfo): CaseDef
28+
protected def asInnerMatchIfNeeded(selectorSym: Symbol, caseDefs: List[CaseDef], fallbackOpt: Option[Tree])(implicit ctx: Context, info: TransformerInfo): CaseDef
2929
protected def factorized(cases: List[CaseDef])(implicit ctx: Context, info: TransformerInfo): (List[List[CaseDef]], List[CaseDef])
3030
protected def shouldSwap(case1: CaseDef, case2: CaseDef)(implicit ctx: Context): Boolean
3131

@@ -63,7 +63,7 @@ trait PatternFactorization extends MiniPhaseTransform {
6363
Apply(Ident(fallbackDefDef.symbol.termRef), Nil)
6464
}
6565

66-
val newFactoredCases = factoredCases.map(asInnerMatchIfNeeded(_, fallbackOpt))
66+
val newFactoredCases = factoredCases.map(asInnerMatchIfNeeded(selectorSym, _, fallbackOpt))
6767

6868
val fallbackCaseOpt = fallbackOpt.map { fallback =>
6969
CaseDef(Underscore(fallback.symbol.info), EmptyTree, fallback)

0 commit comments

Comments
 (0)