Skip to content

Commit 8f0e44c

Browse files
committed
Let phases themselves decide whether they have to do anything.
Instead of having `Run.rootContext` hard-code the filtering.
1 parent 660977c commit 8f0e44c

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

compiler/src/dotty/tools/backend/sjs/GenSJSIR.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class GenSJSIR extends Phase {
99
def phaseName: String = "genSJSIR"
1010

1111
def run(implicit ctx: Context): Unit = {
12-
new JSCodeGen().run()
12+
if (ctx.settings.scalajs.value)
13+
new JSCodeGen().run()
1314
}
1415
}

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
4242
*/
4343
protected[this] def rootContext(implicit ctx: Context): Context = {
4444
ctx.initialize()(ctx)
45-
46-
val actualPhases = if (ctx.settings.scalajs.value) {
47-
// Remove phases that Scala.js does not want
48-
comp.phases.mapConserve(_.filter {
49-
case _: transform.FunctionalInterfaces => false
50-
case _ => true
51-
}).filter(_.nonEmpty)
52-
} else {
53-
// Remove Scala.js-related phases
54-
comp.phases.mapConserve(_.filter {
55-
case _: sjs.GenSJSIR => false
56-
case _ => true
57-
}).filter(_.nonEmpty)
58-
}
59-
60-
ctx.base.setPhasePlan(actualPhases)
61-
45+
ctx.base.setPhasePlan(comp.phases)
6246
val rootScope = new MutableScope
6347
val bootstrap = ctx.fresh
6448
.setPeriod(Period(comp.nextRunId, FirstPhaseId))

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class FunctionalInterfaces extends MiniPhase {
3333
val List(implParamTypes) = implType.paramInfoss
3434
val implResultType = implType.resultType
3535

36-
if (defn.isSpecializableFunction(cls, implParamTypes, implResultType)) {
36+
if (defn.isSpecializableFunction(cls, implParamTypes, implResultType) &&
37+
!ctx.settings.scalajs.value) { // never do anything for Scala.js, but do this test as late as possible not to slow down Scala/JVM
3738
val names = ctx.atPhase(ctx.erasurePhase) {
3839
implicit ctx => cls.typeParams.map(_.name)
3940
}

0 commit comments

Comments
 (0)