Skip to content

Commit

Permalink
Defer the pattern matching phase until after refchecks
Browse files Browse the repository at this point in the history
Continuing from scala#6552.

The motivation is run the pickler phase earlier, as its intermediate
output can be used as an input to downstream compilation in a
pipelined build architecture.

(cherry picked from commit 8fd8e36)
  • Loading branch information
retronym committed Dec 4, 2018
1 parent 92a8ab9 commit b3a9abe
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 38 deletions.
23 changes: 12 additions & 11 deletions src/compiler/scala/tools/nsc/Global.scala
Original file line number Diff line number Diff line change
Expand Up @@ -487,19 +487,10 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
val global: Global.this.type = Global.this
} with Analyzer

// phaseName = "patmat"
object patmat extends {
val global: Global.this.type = Global.this
val runsAfter = List("typer")
val runsRightAfter = None
// patmat doesn't need to be right after typer, as long as we run before superaccessors
// (sbt does need to run right after typer, so don't conflict)
} with PatternMatching

// phaseName = "superaccessors"
object superAccessors extends {
val global: Global.this.type = Global.this
val runsAfter = List("patmat")
val runsAfter = List("typer")
val runsRightAfter = None
} with SuperAccessors

Expand All @@ -524,10 +515,20 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
val runsRightAfter = None
} with RefChecks

// phaseName = "patmat"
object patmat extends {
val global: Global.this.type = Global.this
// patmat does not need to run before the superaccessors phase, because
// patmat never emits `this.x` where `x` is a ParamAccessor.
// (However, patmat does need to run before outer accessors generation).
val runsAfter = List("refchecks")
val runsRightAfter = None
} with PatternMatching

// phaseName = "uncurry"
override object uncurry extends {
val global: Global.this.type = Global.this
val runsAfter = List("refchecks")
val runsAfter = List("patmat")
val runsRightAfter = None
} with UnCurry

Expand Down
3 changes: 2 additions & 1 deletion src/compiler/scala/tools/nsc/PipelineMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ class PipelineMainClass(label: String, parallelism: Int, strategy: BuildStrategy
outlineTimer.start()
val run2 = new compiler.Run() {
override def advancePhase(): Unit = {
if (compiler.phase == this.picklerPhase) {
val phase = compiler.phase
if (phase == this.picklerPhase) {
registerPickleClassPath(command.settings.outputDirs.getSingleOutput.get, symData)
outlineTimer.stop()
outlineDone.complete(Success(()))
Expand Down
10 changes: 5 additions & 5 deletions test/files/neg/t6446-additional.check
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
namer 2 resolve names, attach symbols to named trees
packageobjects 3 load package objects
typer 4 the meat and potatoes: type the trees
patmat 5 translate match expressions
superaccessors 6 add super accessors in traits and nested classes
extmethods 7 add extension methods for inline classes
pickler 8 serialize symbol tables
refchecks 9 reference/override checking, translate nested objects
superaccessors 5 add super accessors in traits and nested classes
extmethods 6 add extension methods for inline classes
pickler 7 serialize symbol tables
refchecks 8 reference/override checking, translate nested objects
patmat 9 translate match expressions
uncurry 10 uncurry, translate function values to anonymous classes
fields 11 synthesize accessors and fields, add bitmaps for lazy vals
tailcalls 12 replace tail calls by jumps
Expand Down
10 changes: 5 additions & 5 deletions test/files/neg/t6446-missing.check
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Error: unable to load class: t6446.Ploogin
namer 2 resolve names, attach symbols to named trees
packageobjects 3 load package objects
typer 4 the meat and potatoes: type the trees
patmat 5 translate match expressions
superaccessors 6 add super accessors in traits and nested classes
extmethods 7 add extension methods for inline classes
pickler 8 serialize symbol tables
refchecks 9 reference/override checking, translate nested objects
superaccessors 5 add super accessors in traits and nested classes
extmethods 6 add extension methods for inline classes
pickler 7 serialize symbol tables
refchecks 8 reference/override checking, translate nested objects
patmat 9 translate match expressions
uncurry 10 uncurry, translate function values to anonymous classes
fields 11 synthesize accessors and fields, add bitmaps for lazy vals
tailcalls 12 replace tail calls by jumps
Expand Down
10 changes: 5 additions & 5 deletions test/files/neg/t6446-show-phases.check
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
namer 2 resolve names, attach symbols to named trees
packageobjects 3 load package objects
typer 4 the meat and potatoes: type the trees
patmat 5 translate match expressions
superaccessors 6 add super accessors in traits and nested classes
extmethods 7 add extension methods for inline classes
pickler 8 serialize symbol tables
refchecks 9 reference/override checking, translate nested objects
superaccessors 5 add super accessors in traits and nested classes
extmethods 6 add extension methods for inline classes
pickler 7 serialize symbol tables
refchecks 8 reference/override checking, translate nested objects
patmat 9 translate match expressions
uncurry 10 uncurry, translate function values to anonymous classes
fields 11 synthesize accessors and fields, add bitmaps for lazy vals
tailcalls 12 replace tail calls by jumps
Expand Down
10 changes: 5 additions & 5 deletions test/files/neg/t7494-no-options.check
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ error: Error: ploogin takes no options
namer 2 resolve names, attach symbols to named trees
packageobjects 3 load package objects
typer 4 the meat and potatoes: type the trees
patmat 5 translate match expressions
superaccessors 6 add super accessors in traits and nested classes
extmethods 7 add extension methods for inline classes
pickler 8 serialize symbol tables
refchecks 9 reference/override checking, translate nested objects
superaccessors 5 add super accessors in traits and nested classes
extmethods 6 add extension methods for inline classes
pickler 7 serialize symbol tables
refchecks 8 reference/override checking, translate nested objects
patmat 9 translate match expressions
uncurry 10 uncurry, translate function values to anonymous classes
fields 11 synthesize accessors and fields, add bitmaps for lazy vals
tailcalls 12 replace tail calls by jumps
Expand Down
10 changes: 5 additions & 5 deletions test/files/run/programmatic-main.check
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
namer 2 resolve names, attach symbols to named trees
packageobjects 3 load package objects
typer 4 the meat and potatoes: type the trees
patmat 5 translate match expressions
superaccessors 6 add super accessors in traits and nested classes
extmethods 7 add extension methods for inline classes
pickler 8 serialize symbol tables
refchecks 9 reference/override checking, translate nested objects
superaccessors 5 add super accessors in traits and nested classes
extmethods 6 add extension methods for inline classes
pickler 7 serialize symbol tables
refchecks 8 reference/override checking, translate nested objects
patmat 9 translate match expressions
uncurry 10 uncurry, translate function values to anonymous classes
fields 11 synthesize accessors and fields, add bitmaps for lazy vals
tailcalls 12 replace tail calls by jumps
Expand Down
3 changes: 3 additions & 0 deletions test/files/run/t1434.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
t1434.scala:7: warning: comparing values of types Null and Null using `!=' will always yield false
case a: A[_] if(a.op != null) => "with op"
^
2 changes: 1 addition & 1 deletion test/files/run/t6288.check
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[106][106][106]Case3.super.<init>();
[13]()
};
[21]def unapply([29]z: [32]<type: [32]scala.Any>): [21]Option[Int] = [56][52][52]scala.Some.apply[[52]Int]([57]-1);
[21]def unapply([29]z: [32]<type: [32]scala.Any>): [21]Option[Int] = [56][52][52]new [52]Some[Int]([57]-1);
[64]{
[64]case <synthetic> val x1: [64]String = [64]"";
[64]case5()[84]{
Expand Down

0 comments on commit b3a9abe

Please sign in to comment.