Skip to content

Commit a979681

Browse files
smarterretronym
authored andcommitted
Move the patmat phase after superaccessors
In dotty, pickling trees into Tasty is done after the super accessors phase but before the pattern matching phase. But in scalac, patmat comes before superaccessors. This commit simply swaps these phases around, thus making it possible to write a compiler plugin for scalac that produces a Tasty file from the output of the superaccessors phase. (cherry picked from commit 7ad3a2e)
1 parent 0fa64e5 commit a979681

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -473,23 +473,25 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
473473
// phaseName = "patmat"
474474
object patmat extends {
475475
val global: Global.this.type = Global.this
476-
val runsAfter = List("typer")
476+
// patmat does not need to run before the superaccessors phase, because
477+
// patmat never emits `this.x` where `x` is a ParamAccessor.
478+
// (However, patmat does need to run before outer accessors generation).
479+
val runsAfter = List("superaccessors")
477480
val runsRightAfter = None
478-
// patmat doesn't need to be right after typer, as long as we run before superaccessors
479-
// (sbt does need to run right after typer, so don't conflict)
480481
} with PatternMatching
481482

482483
// phaseName = "superaccessors"
483484
object superAccessors extends {
484485
val global: Global.this.type = Global.this
485-
val runsAfter = List("patmat")
486+
val runsAfter = List("typer")
487+
// sbt needs to run right after typer, so don't conflict
486488
val runsRightAfter = None
487489
} with SuperAccessors
488490

489491
// phaseName = "extmethods"
490492
object extensionMethods extends {
491493
val global: Global.this.type = Global.this
492-
val runsAfter = List("superaccessors")
494+
val runsAfter = List("patmat")
493495
val runsRightAfter = None
494496
} with ExtensionMethods
495497

@@ -653,8 +655,8 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
653655
analyzer.namerFactory -> "resolve names, attach symbols to named trees",
654656
analyzer.packageObjects -> "load package objects",
655657
analyzer.typerFactory -> "the meat and potatoes: type the trees",
656-
patmat -> "translate match expressions",
657658
superAccessors -> "add super accessors in traits and nested classes",
659+
patmat -> "translate match expressions",
658660
extensionMethods -> "add extension methods for inline classes",
659661
pickler -> "serialize symbol tables",
660662
refChecks -> "reference/override checking, translate nested objects",

test/files/neg/t6446-additional.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
namer 2 resolve names, attach symbols to named trees
55
packageobjects 3 load package objects
66
typer 4 the meat and potatoes: type the trees
7-
patmat 5 translate match expressions
8-
superaccessors 6 add super accessors in traits and nested classes
7+
superaccessors 5 add super accessors in traits and nested classes
8+
patmat 6 translate match expressions
99
extmethods 7 add extension methods for inline classes
1010
pickler 8 serialize symbol tables
1111
refchecks 9 reference/override checking, translate nested objects

test/files/neg/t6446-missing.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Error: unable to load class: t6446.Ploogin
55
namer 2 resolve names, attach symbols to named trees
66
packageobjects 3 load package objects
77
typer 4 the meat and potatoes: type the trees
8-
patmat 5 translate match expressions
9-
superaccessors 6 add super accessors in traits and nested classes
8+
superaccessors 5 add super accessors in traits and nested classes
9+
patmat 6 translate match expressions
1010
extmethods 7 add extension methods for inline classes
1111
pickler 8 serialize symbol tables
1212
refchecks 9 reference/override checking, translate nested objects

test/files/neg/t6446-show-phases.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
namer 2 resolve names, attach symbols to named trees
55
packageobjects 3 load package objects
66
typer 4 the meat and potatoes: type the trees
7-
patmat 5 translate match expressions
8-
superaccessors 6 add super accessors in traits and nested classes
7+
superaccessors 5 add super accessors in traits and nested classes
8+
patmat 6 translate match expressions
99
extmethods 7 add extension methods for inline classes
1010
pickler 8 serialize symbol tables
1111
refchecks 9 reference/override checking, translate nested objects

test/files/neg/t7494-no-options.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ error: Error: ploogin takes no options
55
namer 2 resolve names, attach symbols to named trees
66
packageobjects 3 load package objects
77
typer 4 the meat and potatoes: type the trees
8-
patmat 5 translate match expressions
9-
superaccessors 6 add super accessors in traits and nested classes
8+
superaccessors 5 add super accessors in traits and nested classes
9+
patmat 6 translate match expressions
1010
extmethods 7 add extension methods for inline classes
1111
pickler 8 serialize symbol tables
1212
refchecks 9 reference/override checking, translate nested objects

test/files/run/programmatic-main.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
namer 2 resolve names, attach symbols to named trees
55
packageobjects 3 load package objects
66
typer 4 the meat and potatoes: type the trees
7-
patmat 5 translate match expressions
8-
superaccessors 6 add super accessors in traits and nested classes
7+
superaccessors 5 add super accessors in traits and nested classes
8+
patmat 6 translate match expressions
99
extmethods 7 add extension methods for inline classes
1010
pickler 8 serialize symbol tables
1111
refchecks 9 reference/override checking, translate nested objects

0 commit comments

Comments
 (0)