summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/Inliners.scala2
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala2
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala43
-rw-r--r--src/partest-extras/scala/tools/partest/IcodeComparison.scala73
-rwxr-xr-xtest/files/neg/t6446-additional.check6
-rwxr-xr-xtest/files/neg/t6446-missing.check5
-rw-r--r--test/files/neg/t6446-show-phases.check5
-rw-r--r--test/files/neg/t7494-no-options.check6
-rw-r--r--test/files/neg/t7622-cyclic-dependency.check1
-rw-r--r--test/files/neg/t7622-cyclic-dependency/ThePlugin.scala (renamed from test/pending/neg/t7494-cyclic-dependency/ThePlugin.scala)7
-rw-r--r--test/files/neg/t7622-cyclic-dependency/sample_2.flags (renamed from test/pending/neg/t7494-cyclic-dependency/sample_2.flags)0
-rw-r--r--test/files/neg/t7622-cyclic-dependency/sample_2.scala (renamed from test/pending/neg/t7494-cyclic-dependency/sample_2.scala)0
-rw-r--r--test/files/neg/t7622-cyclic-dependency/scalac-plugin.xml (renamed from test/pending/neg/t7494-cyclic-dependency/scalac-plugin.xml)0
-rw-r--r--test/files/neg/t7622-missing-dependency.check2
-rw-r--r--test/files/neg/t7622-missing-dependency/ThePlugin.scala33
-rw-r--r--test/files/neg/t7622-missing-dependency/sample_2.flags1
-rw-r--r--test/files/neg/t7622-missing-dependency/sample_2.scala6
-rw-r--r--test/files/neg/t7622-missing-dependency/scalac-plugin.xml5
-rw-r--r--test/files/neg/t7622-missing-required.check2
-rw-r--r--test/files/neg/t7622-missing-required.flags1
-rw-r--r--test/files/neg/t7622-missing-required.scala4
-rw-r--r--test/files/neg/t7622-multi-followers.check1
-rw-r--r--test/files/neg/t7622-multi-followers/ThePlugin.scala44
-rw-r--r--test/files/neg/t7622-multi-followers/sample_2.flags1
-rw-r--r--test/files/neg/t7622-multi-followers/sample_2.scala6
-rw-r--r--test/files/neg/t7622-multi-followers/scalac-plugin.xml5
-rw-r--r--test/files/run/inline-ex-handlers.scala4
-rw-r--r--test/files/run/programmatic-main.check9
-rw-r--r--test/files/run/t5313.scala6
-rw-r--r--test/files/run/t6102.check2
-rw-r--r--test/files/run/t6102.flags2
-rw-r--r--test/files/run/t6288b-jump-position.scala9
-rw-r--r--test/files/run/t6955.check1
-rw-r--r--test/files/run/t6955.scala12
-rw-r--r--test/files/run/t6956.check1
-rw-r--r--test/files/run/t6956.scala13
-rw-r--r--test/files/run/test-cpp.scala4
41 files changed, 277 insertions, 55 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala
index bde17b28fc..c49f23852f 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala
@@ -18,6 +18,8 @@ abstract class ClosureElimination extends SubComponent {
val phaseName = "closelim"
+ override val enabled: Boolean = settings.Xcloselim
+
/** Create a new phase */
override def newPhase(p: Phase) = new ClosureEliminationPhase(p)
diff --git a/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala b/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala
index 43c8527f41..64a0727440 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala
@@ -34,6 +34,8 @@ abstract class ConstantOptimization extends SubComponent {
/** Create a new phase */
override def newPhase(p: Phase) = new ConstantOptimizationPhase(p)
+ override val enabled: Boolean = settings.YconstOptimization
+
/**
* The constant optimization phase.
*/
diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
index 483bff6467..e373964987 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
@@ -22,6 +22,8 @@ abstract class DeadCodeElimination extends SubComponent {
val phaseName = "dce"
+ override val enabled: Boolean = settings.Xdce
+
/** Create a new phase */
override def newPhase(p: Phase) = new DeadCodeEliminationPhase(p)
diff --git a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala
index cecabda171..f4e97a91d8 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala
@@ -57,6 +57,8 @@ abstract class InlineExceptionHandlers extends SubComponent {
/** Create a new phase */
override def newPhase(p: Phase) = new InlineExceptionHandlersPhase(p)
+ override def enabled = settings.inlineHandlers
+
/**
* Inlining Exception Handlers
*/
diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
index 09095879bf..181f4bde4e 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
@@ -49,6 +49,8 @@ abstract class Inliners extends SubComponent {
val phaseName = "inliner"
+ override val enabled: Boolean = settings.inline
+
/** Debug - for timing the inliner. */
/****
private def timed[T](s: String, body: => T): T = {
diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
index 29480576ea..98d0695865 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
@@ -8,7 +8,7 @@ trait CPSUtils {
val global: Global
import global._
- var cpsEnabled = false
+ val cpsEnabled: Boolean
val verbose: Boolean = System.getProperty("cpsVerbose", "false") == "true"
def vprintln(x: =>Any): Unit = if (verbose) println(x)
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
index d3b02d74f4..a7e82e949b 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
@@ -11,41 +11,44 @@ class SelectiveCPSPlugin(val global: Global) extends Plugin {
val name = "continuations"
val description = "applies selective cps conversion"
- val anfPhase = new {val global = SelectiveCPSPlugin.this.global } with SelectiveANFTransform() {
+ val pluginEnabled = options contains "enable"
+
+ val anfPhase = new {
+ val global = SelectiveCPSPlugin.this.global
+ val cpsEnabled = pluginEnabled
+ override val enabled = cpsEnabled
+ } with SelectiveANFTransform {
val runsAfter = List("pickler")
}
- val cpsPhase = new {val global = SelectiveCPSPlugin.this.global } with SelectiveCPSTransform() {
+ val cpsPhase = new {
+ val global = SelectiveCPSPlugin.this.global
+ val cpsEnabled = pluginEnabled
+ override val enabled = cpsEnabled
+ } with SelectiveCPSTransform {
val runsAfter = List("selectiveanf")
override val runsBefore = List("uncurry")
}
val components = List[PluginComponent](anfPhase, cpsPhase)
- val checker = new { val global: SelectiveCPSPlugin.this.global.type = SelectiveCPSPlugin.this.global } with CPSAnnotationChecker
+ val checker = new {
+ val global: SelectiveCPSPlugin.this.global.type = SelectiveCPSPlugin.this.global
+ val cpsEnabled = pluginEnabled
+ } with CPSAnnotationChecker
+
+ // TODO don't muck up global with unused checkers
global.addAnnotationChecker(checker.checker)
global.analyzer.addAnalyzerPlugin(checker.plugin)
global.log("instantiated cps plugin: " + this)
- def setEnabled(flag: Boolean) = {
- checker.cpsEnabled = flag
- anfPhase.cpsEnabled = flag
- cpsPhase.cpsEnabled = flag
- }
-
- // TODO: require -enabled command-line flag
-
- override def processOptions(options: List[String], error: String => Unit) = {
- var enabled = false
- for (option <- options) {
- if (option == "enable") {
- enabled = true
- } else {
- error("Option not understood: "+option)
- }
+ override def init(options: List[String], error: String => Unit) = {
+ options foreach {
+ case "enable" => // in initializer
+ case arg => error(s"Bad argument: $arg")
}
- setEnabled(enabled)
+ pluginEnabled
}
override val optionsHelp: Option[String] =
diff --git a/src/partest-extras/scala/tools/partest/IcodeComparison.scala b/src/partest-extras/scala/tools/partest/IcodeComparison.scala
new file mode 100644
index 0000000000..24b87e898f
--- /dev/null
+++ b/src/partest-extras/scala/tools/partest/IcodeComparison.scala
@@ -0,0 +1,73 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2013 LAMP/EPFL
+ * @author Paul Phillips
+ */
+
+package scala.tools.partest
+
+import scala.tools.partest.nest.FileManager.compareContents
+import scala.compat.Platform.EOL
+
+/** A class for testing icode. All you need is this in a
+ * partest source file --
+ * {{{
+ * object Test extends IcodeComparison
+ * }}}
+ * -- and the generated output will be the icode for everything
+ * in that file. See scaladoc for possible customizations.
+ */
+abstract class IcodeComparison extends DirectTest {
+ /** The phase after which icode is printed.
+ * Override to check icode at a different point,
+ * but you can't print at a phase that is not enabled
+ * in this compiler run. Defaults to "icode".
+ */
+ def printIcodeAfterPhase = "icode"
+
+ /** When comparing the output of two phases, this is
+ * the other phase of interest, normally the preceding
+ * phase. Defaults to "icode" for tests of optimizer phases.
+ */
+ def printSuboptimalIcodeAfterPhase = "icode"
+
+ /** The source code to compile defaults to the test file.
+ * I.e., the test file compiles itself. For a comparison,
+ * the test file will be compiled three times.
+ */
+ def code = testPath.slurp()
+
+ /** By default, the test code is compiled with -usejavacp. */
+ override def extraSettings: String = "-usejavacp"
+
+ /** Compile the test code and return the contents of all
+ * (sorted) .icode files, which are immediately deleted.
+ * @param arg0 at least one arg is required
+ * @param args must include -Xprint-icode:phase
+ */
+ def collectIcode(arg0: String, args: String*): List[String] = {
+ compile("-d" :: testOutput.path :: arg0 :: args.toList : _*)
+ val icodeFiles = testOutput.files.toList filter (_ hasExtension "icode")
+
+ try icodeFiles sortBy (_.name) flatMap (f => f.lines.toList)
+ finally icodeFiles foreach (f => f.delete())
+ }
+
+ /** Collect icode at the default phase, `printIcodeAfterPhase`. */
+ def collectIcode(): List[String] = collectIcode(s"-Xprint-icode:$printIcodeAfterPhase")
+
+ /** Default show is showComparison. May be overridden for showIcode or similar. */
+ def show() = showComparison()
+
+ /** Compile the test code with and without optimization, and
+ * then print the diff of the icode.
+ */
+ def showComparison() = {
+ val lines1 = collectIcode(s"-Xprint-icode:$printSuboptimalIcodeAfterPhase")
+ val lines2 = collectIcode("-optimise", s"-Xprint-icode:$printIcodeAfterPhase")
+
+ println(compareContents(lines1, lines2))
+ }
+
+ /** Print icode at the default phase, `printIcodeAfterPhase`. */
+ def showIcode() = println(collectIcode() mkString EOL)
+}
diff --git a/test/files/neg/t6446-additional.check b/test/files/neg/t6446-additional.check
index be928095d3..6dfe072913 100755
--- a/test/files/neg/t6446-additional.check
+++ b/test/files/neg/t6446-additional.check
@@ -22,6 +22,7 @@ superaccessors 6 add super accessors in traits and nested classes
mixin 20 mixin composition
cleanup 21 platform-specific cleanups, generate reflective calls
icode 22 generate portable intermediate code
+#partest -optimise
inliner 23 optimization: do inlining
inlinehandlers 24 optimization: inline exception handlers
closelim 25 optimization: eliminate uncalled closures
@@ -30,3 +31,8 @@ inlinehandlers 24 optimization: inline exception handlers
jvm 28 generate JVM bytecode
ploogin 29 A sample phase that does so many things it's kind of hard...
terminal 30 the last phase during a compilation run
+#partest !-optimise
+ jvm 23 generate JVM bytecode
+ ploogin 24 A sample phase that does so many things it's kind of hard...
+ terminal 25 the last phase during a compilation run
+#partest
diff --git a/test/files/neg/t6446-missing.check b/test/files/neg/t6446-missing.check
index 8ede1bd260..d4afa9b630 100755
--- a/test/files/neg/t6446-missing.check
+++ b/test/files/neg/t6446-missing.check
@@ -23,6 +23,10 @@ superaccessors 6 add super accessors in traits and nested classes
mixin 20 mixin composition
cleanup 21 platform-specific cleanups, generate reflective calls
icode 22 generate portable intermediate code
+#partest !-optimise
+ jvm 23 generate JVM bytecode
+ terminal 24 the last phase during a compilation run
+#partest -optimise
inliner 23 optimization: do inlining
inlinehandlers 24 optimization: inline exception handlers
closelim 25 optimization: eliminate uncalled closures
@@ -30,3 +34,4 @@ inlinehandlers 24 optimization: inline exception handlers
dce 27 optimization: eliminate dead code
jvm 28 generate JVM bytecode
terminal 29 the last phase during a compilation run
+#partest
diff --git a/test/files/neg/t6446-show-phases.check b/test/files/neg/t6446-show-phases.check
index 73cbfb6659..10a9e08b86 100644
--- a/test/files/neg/t6446-show-phases.check
+++ b/test/files/neg/t6446-show-phases.check
@@ -22,6 +22,10 @@ superaccessors 6 add super accessors in traits and nested classes
mixin 20 mixin composition
cleanup 21 platform-specific cleanups, generate reflective calls
icode 22 generate portable intermediate code
+#partest !-optimise
+ jvm 23 generate JVM bytecode
+ terminal 24 the last phase during a compilation run
+#partest -optimise
inliner 23 optimization: do inlining
inlinehandlers 24 optimization: inline exception handlers
closelim 25 optimization: eliminate uncalled closures
@@ -29,3 +33,4 @@ inlinehandlers 24 optimization: inline exception handlers
dce 27 optimization: eliminate dead code
jvm 28 generate JVM bytecode
terminal 29 the last phase during a compilation run
+#partest
diff --git a/test/files/neg/t7494-no-options.check b/test/files/neg/t7494-no-options.check
index 04fbf0ec72..0bde84c96c 100644
--- a/test/files/neg/t7494-no-options.check
+++ b/test/files/neg/t7494-no-options.check
@@ -23,6 +23,11 @@ superaccessors 6 add super accessors in traits and nested classes
mixin 20 mixin composition
cleanup 21 platform-specific cleanups, generate reflective calls
icode 22 generate portable intermediate code
+#partest !-optimise
+ jvm 23 generate JVM bytecode
+ ploogin 24 A sample phase that does so many things it's kind of hard...
+ terminal 25 the last phase during a compilation run
+#partest -optimise
inliner 23 optimization: do inlining
inlinehandlers 24 optimization: inline exception handlers
closelim 25 optimization: eliminate uncalled closures
@@ -31,3 +36,4 @@ inlinehandlers 24 optimization: inline exception handlers
jvm 28 generate JVM bytecode
ploogin 29 A sample phase that does so many things it's kind of hard...
terminal 30 the last phase during a compilation run
+#partest
diff --git a/test/files/neg/t7622-cyclic-dependency.check b/test/files/neg/t7622-cyclic-dependency.check
new file mode 100644
index 0000000000..3546964f5f
--- /dev/null
+++ b/test/files/neg/t7622-cyclic-dependency.check
@@ -0,0 +1 @@
+error: Cycle in phase dependencies detected at cyclicdependency1, created phase-cycle.dot
diff --git a/test/pending/neg/t7494-cyclic-dependency/ThePlugin.scala b/test/files/neg/t7622-cyclic-dependency/ThePlugin.scala
index bd94ce60d7..7a905ae32d 100644
--- a/test/pending/neg/t7494-cyclic-dependency/ThePlugin.scala
+++ b/test/files/neg/t7622-cyclic-dependency/ThePlugin.scala
@@ -20,7 +20,7 @@ class ThePlugin(val global: Global) extends Plugin {
val phaseName = ThePlugin.this.name + "1"
- def newPhase(prev: Phase) = new ThePhase(prev)
+ def newPhase(prev: Phase) = new ThePhase(prev, phaseName)
}
private object thePhase2 extends PluginComponent {
@@ -30,11 +30,10 @@ class ThePlugin(val global: Global) extends Plugin {
val phaseName = ThePlugin.this.name + "2"
- def newPhase(prev: Phase) = new ThePhase(prev)
+ def newPhase(prev: Phase) = new ThePhase(prev, phaseName)
}
- private class ThePhase(prev: Phase) extends Phase(prev) {
- def name = ThePlugin.this.name
+ private class ThePhase(prev: Phase, val name: String) extends Phase(prev) {
def run {}
}
}
diff --git a/test/pending/neg/t7494-cyclic-dependency/sample_2.flags b/test/files/neg/t7622-cyclic-dependency/sample_2.flags
index db25b88a12..db25b88a12 100644
--- a/test/pending/neg/t7494-cyclic-dependency/sample_2.flags
+++ b/test/files/neg/t7622-cyclic-dependency/sample_2.flags
diff --git a/test/pending/neg/t7494-cyclic-dependency/sample_2.scala b/test/files/neg/t7622-cyclic-dependency/sample_2.scala
index 73cdc64e40..73cdc64e40 100644
--- a/test/pending/neg/t7494-cyclic-dependency/sample_2.scala
+++ b/test/files/neg/t7622-cyclic-dependency/sample_2.scala
diff --git a/test/pending/neg/t7494-cyclic-dependency/scalac-plugin.xml b/test/files/neg/t7622-cyclic-dependency/scalac-plugin.xml
index 2558d6fd03..2558d6fd03 100644
--- a/test/pending/neg/t7494-cyclic-dependency/scalac-plugin.xml
+++ b/test/files/neg/t7622-cyclic-dependency/scalac-plugin.xml
diff --git a/test/files/neg/t7622-missing-dependency.check b/test/files/neg/t7622-missing-dependency.check
new file mode 100644
index 0000000000..a0d0e30870
--- /dev/null
+++ b/test/files/neg/t7622-missing-dependency.check
@@ -0,0 +1,2 @@
+error: Phase 'myplugin' requires: List(missing)
+one error found
diff --git a/test/files/neg/t7622-missing-dependency/ThePlugin.scala b/test/files/neg/t7622-missing-dependency/ThePlugin.scala
new file mode 100644
index 0000000000..a87cbb8e45
--- /dev/null
+++ b/test/files/neg/t7622-missing-dependency/ThePlugin.scala
@@ -0,0 +1,33 @@
+package scala.test.plugins
+
+import scala.tools.nsc
+import nsc.Global
+import nsc.Phase
+import nsc.plugins.Plugin
+import nsc.plugins.PluginComponent
+
+class ThePlugin(val global: Global) extends Plugin {
+ import global._
+
+ val name = "myplugin"
+ val description = "Declares one plugin with a missing requirement"
+ val components = List[PluginComponent](thePhase)
+
+ private object thePhase extends PluginComponent {
+ val global = ThePlugin.this.global
+
+ val runsAfter = List[String]("typer")
+
+ val phaseName = ThePlugin.this.name
+
+ override val requires = List("missing")
+
+ def newPhase(prev: Phase) = new ThePhase(prev)
+ }
+
+ private class ThePhase(prev: Phase) extends Phase(prev) {
+ def name = thePhase.phaseName
+ def run {}
+ }
+}
+
diff --git a/test/files/neg/t7622-missing-dependency/sample_2.flags b/test/files/neg/t7622-missing-dependency/sample_2.flags
new file mode 100644
index 0000000000..d69035100e
--- /dev/null
+++ b/test/files/neg/t7622-missing-dependency/sample_2.flags
@@ -0,0 +1 @@
+-Xplugin:. -Xplugin-require:myplugin
diff --git a/test/files/neg/t7622-missing-dependency/sample_2.scala b/test/files/neg/t7622-missing-dependency/sample_2.scala
new file mode 100644
index 0000000000..73cdc64e40
--- /dev/null
+++ b/test/files/neg/t7622-missing-dependency/sample_2.scala
@@ -0,0 +1,6 @@
+
+package sample
+
+// just a sample that is compiled with the sample plugin enabled
+object Sample extends App {
+}
diff --git a/test/files/neg/t7622-missing-dependency/scalac-plugin.xml b/test/files/neg/t7622-missing-dependency/scalac-plugin.xml
new file mode 100644
index 0000000000..3c14061dce
--- /dev/null
+++ b/test/files/neg/t7622-missing-dependency/scalac-plugin.xml
@@ -0,0 +1,5 @@
+<plugin>
+ <name>myplugin</name>
+ <classname>scala.test.plugins.ThePlugin</classname>
+</plugin>
+
diff --git a/test/files/neg/t7622-missing-required.check b/test/files/neg/t7622-missing-required.check
new file mode 100644
index 0000000000..5982178581
--- /dev/null
+++ b/test/files/neg/t7622-missing-required.check
@@ -0,0 +1,2 @@
+error: Missing required plugin: special-plugin
+one error found
diff --git a/test/files/neg/t7622-missing-required.flags b/test/files/neg/t7622-missing-required.flags
new file mode 100644
index 0000000000..65deac6feb
--- /dev/null
+++ b/test/files/neg/t7622-missing-required.flags
@@ -0,0 +1 @@
+-Xplugin-require:special-plugin
diff --git a/test/files/neg/t7622-missing-required.scala b/test/files/neg/t7622-missing-required.scala
new file mode 100644
index 0000000000..a0ba487b24
--- /dev/null
+++ b/test/files/neg/t7622-missing-required.scala
@@ -0,0 +1,4 @@
+
+// the amazing features of this trait
+// are unlocked by compiling with a special plugin.
+trait Amazing
diff --git a/test/files/neg/t7622-multi-followers.check b/test/files/neg/t7622-multi-followers.check
new file mode 100644
index 0000000000..5cda422ff0
--- /dev/null
+++ b/test/files/neg/t7622-multi-followers.check
@@ -0,0 +1 @@
+error: Phase parser has too many followers: multi1,multi2; created phase-order.dot
diff --git a/test/files/neg/t7622-multi-followers/ThePlugin.scala b/test/files/neg/t7622-multi-followers/ThePlugin.scala
new file mode 100644
index 0000000000..e7a49a9be6
--- /dev/null
+++ b/test/files/neg/t7622-multi-followers/ThePlugin.scala
@@ -0,0 +1,44 @@
+package scala.test.plugins
+
+import scala.tools.nsc
+import nsc.Global
+import nsc.Phase
+import nsc.plugins.Plugin
+import nsc.plugins.PluginComponent
+
+class ThePlugin(val global: Global) extends Plugin {
+ import global._
+
+ val name = "multi"
+ val description = "Declares two phases that both follow parser"
+ val components = List[PluginComponent](thePhase1,thePhase2)
+
+ private object thePhase1 extends PluginComponent {
+ val global = ThePlugin.this.global
+
+ val runsAfter = List[String]()
+
+ override val runsRightAfter = Some("parser")
+
+ val phaseName = ThePlugin.this.name + "1"
+
+ def newPhase(prev: Phase) = new ThePhase(prev, phaseName)
+ }
+
+ private object thePhase2 extends PluginComponent {
+ val global = ThePlugin.this.global
+
+ val runsAfter = List[String]()
+
+ override val runsRightAfter = Some("parser")
+
+ val phaseName = ThePlugin.this.name + "2"
+
+ def newPhase(prev: Phase) = new ThePhase(prev, phaseName)
+ }
+
+ private class ThePhase(prev: Phase, val name: String) extends Phase(prev) {
+ def run {}
+ }
+}
+
diff --git a/test/files/neg/t7622-multi-followers/sample_2.flags b/test/files/neg/t7622-multi-followers/sample_2.flags
new file mode 100644
index 0000000000..d2e83e9723
--- /dev/null
+++ b/test/files/neg/t7622-multi-followers/sample_2.flags
@@ -0,0 +1 @@
+-Xplugin:. -Xplugin-require:multi
diff --git a/test/files/neg/t7622-multi-followers/sample_2.scala b/test/files/neg/t7622-multi-followers/sample_2.scala
new file mode 100644
index 0000000000..73cdc64e40
--- /dev/null
+++ b/test/files/neg/t7622-multi-followers/sample_2.scala
@@ -0,0 +1,6 @@
+
+package sample
+
+// just a sample that is compiled with the sample plugin enabled
+object Sample extends App {
+}
diff --git a/test/files/neg/t7622-multi-followers/scalac-plugin.xml b/test/files/neg/t7622-multi-followers/scalac-plugin.xml
new file mode 100644
index 0000000000..2558d6fd03
--- /dev/null
+++ b/test/files/neg/t7622-multi-followers/scalac-plugin.xml
@@ -0,0 +1,5 @@
+<plugin>
+ <name>ignored</name>
+ <classname>scala.test.plugins.ThePlugin</classname>
+</plugin>
+
diff --git a/test/files/run/inline-ex-handlers.scala b/test/files/run/inline-ex-handlers.scala
index 33e794b940..964594d258 100644
--- a/test/files/run/inline-ex-handlers.scala
+++ b/test/files/run/inline-ex-handlers.scala
@@ -1,6 +1,6 @@
-import scala.tools.partest.IcodeTest
+import scala.tools.partest.IcodeComparison
-object Test extends IcodeTest {
+object Test extends IcodeComparison {
override def printIcodeAfterPhase = "inlinehandlers"
}
diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check
index cc325cafc0..a6e53fbe92 100644
--- a/test/files/run/programmatic-main.check
+++ b/test/files/run/programmatic-main.check
@@ -22,11 +22,6 @@ superaccessors 6 add super accessors in traits and nested classes
mixin 20 mixin composition
cleanup 21 platform-specific cleanups, generate reflective calls
icode 22 generate portable intermediate code
- inliner 23 optimization: do inlining
-inlinehandlers 24 optimization: inline exception handlers
- closelim 25 optimization: eliminate uncalled closures
- constopt 26 optimization: optimize null and other constants
- dce 27 optimization: eliminate dead code
- jvm 28 generate JVM bytecode
- terminal 29 the last phase during a compilation run
+ jvm 23 generate JVM bytecode
+ terminal 24 the last phase during a compilation run
diff --git a/test/files/run/t5313.scala b/test/files/run/t5313.scala
index febfd9c3ed..4cbc29ba5d 100644
--- a/test/files/run/t5313.scala
+++ b/test/files/run/t5313.scala
@@ -1,6 +1,6 @@
-import scala.tools.partest.IcodeTest
+import scala.tools.partest.IcodeComparison
-object Test extends IcodeTest {
+object Test extends IcodeComparison {
override def printIcodeAfterPhase = "dce"
override def extraSettings: String = super.extraSettings + " -optimize"
@@ -48,7 +48,7 @@ object Test extends IcodeTest {
override def show() {
val storeLocal = "STORE_LOCAL"
- val lines1 = collectIcode("") filter (_ contains storeLocal) map (x => x.drop(x.indexOf(storeLocal)))
+ val lines1 = collectIcode() filter (_ contains storeLocal) map (x => x.drop(x.indexOf(storeLocal)))
println(lines1 mkString "\n")
}
}
diff --git a/test/files/run/t6102.check b/test/files/run/t6102.check
index 97e455647b..4e8efa7b6d 100644
--- a/test/files/run/t6102.check
+++ b/test/files/run/t6102.check
@@ -20,10 +20,12 @@
[running phase mixin on t6102.scala]
[running phase cleanup on t6102.scala]
[running phase icode on t6102.scala]
+#partest -optimise
[running phase inliner on t6102.scala]
[running phase inlinehandlers on t6102.scala]
[running phase closelim on t6102.scala]
[running phase constopt on t6102.scala]
+#partest
[running phase dce on t6102.scala]
[running phase jvm on icode]
hello
diff --git a/test/files/run/t6102.flags b/test/files/run/t6102.flags
index 72fe7b1aa0..726e2a997f 100644
--- a/test/files/run/t6102.flags
+++ b/test/files/run/t6102.flags
@@ -1 +1 @@
- -Ydead-code -Ydebug -Xfatal-warnings
+-Ydead-code -Ydebug -Xfatal-warnings
diff --git a/test/files/run/t6288b-jump-position.scala b/test/files/run/t6288b-jump-position.scala
index e22a1ab120..c5f3bbe788 100644
--- a/test/files/run/t6288b-jump-position.scala
+++ b/test/files/run/t6288b-jump-position.scala
@@ -1,6 +1,6 @@
-import scala.tools.partest.IcodeTest
+import scala.tools.partest.IcodeComparison
-object Test extends IcodeTest {
+object Test extends IcodeComparison {
override def code =
"""object Case3 { // 01
| def unapply(z: Any): Option[Int] = Some(-1) // 02
@@ -15,8 +15,5 @@ object Test extends IcodeTest {
| }
|}""".stripMargin
- override def show() {
- val lines1 = collectIcode("")
- println(lines1 mkString "\n")
- }
+ override def show() = showIcode()
}
diff --git a/test/files/run/t6955.check b/test/files/run/t6955.check
deleted file mode 100644
index 0cfbf08886..0000000000
--- a/test/files/run/t6955.check
+++ /dev/null
@@ -1 +0,0 @@
-2
diff --git a/test/files/run/t6955.scala b/test/files/run/t6955.scala
index 980aa420cc..329af688e4 100644
--- a/test/files/run/t6955.scala
+++ b/test/files/run/t6955.scala
@@ -1,4 +1,4 @@
-import scala.tools.partest.IcodeTest
+import scala.tools.partest.IcodeComparison
// this class should compile to code that uses switches (twice)
class Switches {
@@ -20,9 +20,15 @@ class Switches {
}
}
-object Test extends IcodeTest {
+object Test extends IcodeComparison {
// ensure we get two switches out of this -- ignore the rest of the output for robustness
// exclude the constant we emit for the "SWITCH ..." string below (we get the icode for all the code you see in this file)
- override def show() = println(collectIcode("").filter(x => x.indexOf("SWITCH ...") >= 0 && x.indexOf("CONSTANT(") == -1).size)
+ override def show() = {
+ val expected = 2
+ val actual = (collectIcode() filter {
+ x => x.indexOf("SWITCH ...") >= 0 && x.indexOf("CONSTANT(") == -1
+ }).size
+ assert(actual == expected)
+ }
}
diff --git a/test/files/run/t6956.check b/test/files/run/t6956.check
deleted file mode 100644
index 0cfbf08886..0000000000
--- a/test/files/run/t6956.check
+++ /dev/null
@@ -1 +0,0 @@
-2
diff --git a/test/files/run/t6956.scala b/test/files/run/t6956.scala
index 4a6583ca45..3569adf483 100644
--- a/test/files/run/t6956.scala
+++ b/test/files/run/t6956.scala
@@ -1,4 +1,4 @@
-import scala.tools.partest.IcodeTest
+import scala.tools.partest.IcodeComparison
class Switches {
private[this] final val ONE = 1
@@ -18,9 +18,14 @@ class Switches {
}
}
-object Test extends IcodeTest {
+object Test extends IcodeComparison {
// ensure we get two switches out of this -- ignore the rest of the output for robustness
// exclude the constant we emit for the "SWITCH ..." string below (we get the icode for all the code you see in this file)
- override def show() = println(collectIcode("").filter(x => x.indexOf("SWITCH ...") >= 0 && x.indexOf("CONSTANT(") == -1).size)
+ override def show() = {
+ val expected = 2
+ val actual = (collectIcode() filter {
+ x => x.indexOf("SWITCH ...") >= 0 && x.indexOf("CONSTANT(") == -1
+ }).size
+ assert(actual == expected)
+ }
}
-
diff --git a/test/files/run/test-cpp.scala b/test/files/run/test-cpp.scala
index f9fa85c4d0..c6eda56776 100644
--- a/test/files/run/test-cpp.scala
+++ b/test/files/run/test-cpp.scala
@@ -12,9 +12,9 @@
* instead of 'l'.
*/
-import scala.tools.partest.IcodeTest
+import scala.tools.partest.IcodeComparison
-object Test extends IcodeTest {
+object Test extends IcodeComparison {
override def printIcodeAfterPhase = "dce"
}