Skip to content

Commit 46bbcf7

Browse files
committed
Defer the pattern matching phase until after refchecks
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)
1 parent 92a8ab9 commit 46bbcf7

File tree

8 files changed

+40
-36
lines changed

8 files changed

+40
-36
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -487,15 +487,6 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
487487
val global: Global.this.type = Global.this
488488
} with Analyzer
489489

490-
// phaseName = "patmat"
491-
object patmat extends {
492-
val global: Global.this.type = Global.this
493-
val runsAfter = List("typer")
494-
val runsRightAfter = None
495-
// patmat doesn't need to be right after typer, as long as we run before superaccessors
496-
// (sbt does need to run right after typer, so don't conflict)
497-
} with PatternMatching
498-
499490
// phaseName = "superaccessors"
500491
object superAccessors extends {
501492
val global: Global.this.type = Global.this
@@ -524,10 +515,20 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
524515
val runsRightAfter = None
525516
} with RefChecks
526517

518+
// phaseName = "patmat"
519+
object patmat extends {
520+
val global: Global.this.type = Global.this
521+
// patmat does not need to run before the superaccessors phase, because
522+
// patmat never emits `this.x` where `x` is a ParamAccessor.
523+
// (However, patmat does need to run before outer accessors generation).
524+
val runsAfter = List("refchecks")
525+
val runsRightAfter = None
526+
} with PatternMatching
527+
527528
// phaseName = "uncurry"
528529
override object uncurry extends {
529530
val global: Global.this.type = Global.this
530-
val runsAfter = List("refchecks")
531+
val runsAfter = List("patmat")
531532
val runsRightAfter = None
532533
} with UnCurry
533534

test/files/neg/t6446-additional.check

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
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
9-
extmethods 7 add extension methods for inline classes
10-
pickler 8 serialize symbol tables
11-
refchecks 9 reference/override checking, translate nested objects
7+
superaccessors 5 add super accessors in traits and nested classes
8+
extmethods 6 add extension methods for inline classes
9+
pickler 7 serialize symbol tables
10+
refchecks 8 reference/override checking, translate nested objects
11+
patmat 9 translate match expressions
1212
uncurry 10 uncurry, translate function values to anonymous classes
1313
fields 11 synthesize accessors and fields, add bitmaps for lazy vals
1414
tailcalls 12 replace tail calls by jumps

test/files/neg/t6446-missing.check

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ 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
10-
extmethods 7 add extension methods for inline classes
11-
pickler 8 serialize symbol tables
12-
refchecks 9 reference/override checking, translate nested objects
8+
superaccessors 5 add super accessors in traits and nested classes
9+
extmethods 6 add extension methods for inline classes
10+
pickler 7 serialize symbol tables
11+
refchecks 8 reference/override checking, translate nested objects
12+
patmat 9 translate match expressions
1313
uncurry 10 uncurry, translate function values to anonymous classes
1414
fields 11 synthesize accessors and fields, add bitmaps for lazy vals
1515
tailcalls 12 replace tail calls by jumps

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
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
9-
extmethods 7 add extension methods for inline classes
10-
pickler 8 serialize symbol tables
11-
refchecks 9 reference/override checking, translate nested objects
7+
superaccessors 5 add super accessors in traits and nested classes
8+
extmethods 6 add extension methods for inline classes
9+
pickler 7 serialize symbol tables
10+
refchecks 8 reference/override checking, translate nested objects
11+
patmat 9 translate match expressions
1212
uncurry 10 uncurry, translate function values to anonymous classes
1313
fields 11 synthesize accessors and fields, add bitmaps for lazy vals
1414
tailcalls 12 replace tail calls by jumps

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ 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
10-
extmethods 7 add extension methods for inline classes
11-
pickler 8 serialize symbol tables
12-
refchecks 9 reference/override checking, translate nested objects
8+
superaccessors 5 add super accessors in traits and nested classes
9+
extmethods 6 add extension methods for inline classes
10+
pickler 7 serialize symbol tables
11+
refchecks 8 reference/override checking, translate nested objects
12+
patmat 9 translate match expressions
1313
uncurry 10 uncurry, translate function values to anonymous classes
1414
fields 11 synthesize accessors and fields, add bitmaps for lazy vals
1515
tailcalls 12 replace tail calls by jumps

test/files/run/programmatic-main.check

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
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
9-
extmethods 7 add extension methods for inline classes
10-
pickler 8 serialize symbol tables
11-
refchecks 9 reference/override checking, translate nested objects
7+
superaccessors 5 add super accessors in traits and nested classes
8+
extmethods 6 add extension methods for inline classes
9+
pickler 7 serialize symbol tables
10+
refchecks 8 reference/override checking, translate nested objects
11+
patmat 9 translate match expressions
1212
uncurry 10 uncurry, translate function values to anonymous classes
1313
fields 11 synthesize accessors and fields, add bitmaps for lazy vals
1414
tailcalls 12 replace tail calls by jumps

test/files/run/t1434.check

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
t1434.scala:7: warning: comparing values of types Null and Null using `!=' will always yield false
2+
case a: A[_] if(a.op != null) => "with op"
3+
^

test/files/run/t6288.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[106][106][106]Case3.super.<init>();
66
[13]()
77
};
8-
[21]def unapply([29]z: [32]<type: [32]scala.Any>): [21]Option[Int] = [56][52][52]scala.Some.apply[[52]Int]([57]-1);
8+
[21]def unapply([29]z: [32]<type: [32]scala.Any>): [21]Option[Int] = [56][52][52]new [52]Some[Int]([57]-1);
99
[64]{
1010
[64]case <synthetic> val x1: [64]String = [64]"";
1111
[64]case5()[84]{

0 commit comments

Comments
 (0)