From b3a9abe5e2a4bab7256629de9769141558ba06a3 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 25 Sep 2018 16:34:15 +1000 Subject: [PATCH] Defer the pattern matching phase until after refchecks Continuing from #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 8fd8e367ed89312a73c2d87d4543c8c012145c82) --- src/compiler/scala/tools/nsc/Global.scala | 23 ++++++++++--------- .../scala/tools/nsc/PipelineMain.scala | 3 ++- test/files/neg/t6446-additional.check | 10 ++++---- test/files/neg/t6446-missing.check | 10 ++++---- test/files/neg/t6446-show-phases.check | 10 ++++---- test/files/neg/t7494-no-options.check | 10 ++++---- test/files/run/programmatic-main.check | 10 ++++---- test/files/run/t1434.check | 3 +++ test/files/run/t6288.check | 2 +- 9 files changed, 43 insertions(+), 38 deletions(-) create mode 100644 test/files/run/t1434.check diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index efcfd8d2a358..49a00cba8573 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -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 @@ -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 diff --git a/src/compiler/scala/tools/nsc/PipelineMain.scala b/src/compiler/scala/tools/nsc/PipelineMain.scala index eaddadc2aecb..8571017d992d 100644 --- a/src/compiler/scala/tools/nsc/PipelineMain.scala +++ b/src/compiler/scala/tools/nsc/PipelineMain.scala @@ -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(())) diff --git a/test/files/neg/t6446-additional.check b/test/files/neg/t6446-additional.check index 9d4af37b987f..5b48c1e79fa5 100644 --- a/test/files/neg/t6446-additional.check +++ b/test/files/neg/t6446-additional.check @@ -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 diff --git a/test/files/neg/t6446-missing.check b/test/files/neg/t6446-missing.check index 65b5e5dc0964..d8e822cecd1f 100644 --- a/test/files/neg/t6446-missing.check +++ b/test/files/neg/t6446-missing.check @@ -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 diff --git a/test/files/neg/t6446-show-phases.check b/test/files/neg/t6446-show-phases.check index 373f63e5b259..436a02643597 100644 --- a/test/files/neg/t6446-show-phases.check +++ b/test/files/neg/t6446-show-phases.check @@ -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 diff --git a/test/files/neg/t7494-no-options.check b/test/files/neg/t7494-no-options.check index 1bf5c2371197..9fd03ab0ba03 100644 --- a/test/files/neg/t7494-no-options.check +++ b/test/files/neg/t7494-no-options.check @@ -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 diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check index 373f63e5b259..436a02643597 100644 --- a/test/files/run/programmatic-main.check +++ b/test/files/run/programmatic-main.check @@ -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 diff --git a/test/files/run/t1434.check b/test/files/run/t1434.check new file mode 100644 index 000000000000..8483ac94f7c7 --- /dev/null +++ b/test/files/run/t1434.check @@ -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" + ^ diff --git a/test/files/run/t6288.check b/test/files/run/t6288.check index 86b6b95628e9..955e27b0aad8 100644 --- a/test/files/run/t6288.check +++ b/test/files/run/t6288.check @@ -5,7 +5,7 @@ [106][106][106]Case3.super.(); [13]() }; - [21]def unapply([29]z: [32]): [21]Option[Int] = [56][52][52]scala.Some.apply[[52]Int]([57]-1); + [21]def unapply([29]z: [32]): [21]Option[Int] = [56][52][52]new [52]Some[Int]([57]-1); [64]{ [64]case val x1: [64]String = [64]""; [64]case5()[84]{