Skip to content

Commit 3d42032

Browse files
committed
Revert changes to compiler
As the compiler supports already adding custom phases, there is no need to add the phases to the compiler.
1 parent a855575 commit 3d42032

File tree

6 files changed

+47
-19
lines changed

6 files changed

+47
-19
lines changed

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ class Compiler {
5757
new CheckReentrant, // Internal use only: Check that compiled program has no data races involving global vars
5858
new ElimPackagePrefixes, // Eliminate references to package prefixes in Select nodes
5959
new CookComments, // Cook the comments: expand variables, doc, etc.
60-
new CompleteJavaEnums, // Fill in constructors for Java enums
61-
new SetDefTree) :: // set `symbol.defTree`
60+
new CompleteJavaEnums) :: // Fill in constructors for Java enums
6261
List(new CheckStatic, // Check restrictions that apply to @static members
6362
new ElimRepeated, // Rewrite vararg parameters and arguments
6463
new ExpandSAMs, // Expand single abstract method closures to anonymous classes
@@ -70,7 +69,6 @@ class Compiler {
7069
new HoistSuperArgs, // Hoist complex arguments of supercalls to enclosing scope
7170
new ClassOf, // Expand `Predef.classOf` calls.
7271
new RefChecks) :: // Various checks mostly related to abstract members and overriding
73-
// new SetDefTreeOff) :: // unset `symbol.defTree`
7472
List(new ElimOpaque, // Turn opaque into normal aliases
7573
new TryCatchPatterns, // Compile cases in try/catch
7674
new PatternMatcher, // Compile pattern matches

sbt-dotty/sbt-test/sbt-dotty/analyzer-plugin/plugin/Analyzer.scala

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,24 @@ import Decorators._
1313
import Symbols.Symbol
1414
import Constants.Constant
1515
import Types._
16-
import transform.{SetDefTree, SetDefTreeOff}
16+
import transform.{CheckStatic}
1717

18-
class InitChecker extends PluginPhase with StandardPlugin {
18+
class InitPlugin extends StandardPlugin {
1919
import tpd._
20-
21-
val name: String = "initChecker"
20+
val name: String = "initPlugin"
2221
override val description: String = "checks that under -Yretain-trees we may get tree for all symbols"
2322

24-
val phaseName = name
23+
def init(options: List[String]): List[PluginPhase] =
24+
(new SetDefTree) :: (new InitChecker) :: Nil
25+
}
2526

26-
override val runsAfter = Set(SetDefTree.name)
27-
override val runsBefore = Set(SetDefTreeOff.name)
27+
class InitChecker extends PluginPhase {
28+
import tpd._
2829

29-
def init(options: List[String]): List[PluginPhase] = this :: Nil
30+
val phaseName = "symbolTreeChecker"
31+
32+
override val runsAfter = Set(SetDefTree.name)
33+
override val runsBefore = Set(CheckStatic.name)
3034

3135
private def checkDef(tree: Tree)(implicit ctx: Context): Tree = {
3236
if (tree.symbol.defTree.isEmpty)

compiler/src/dotty/tools/dotc/transform/SetDefTree.scala renamed to sbt-dotty/sbt-test/sbt-dotty/analyzer-plugin/plugin/SetDefTree.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
package dotty.tools.dotc.transform
1+
package analyzer
22

33
import dotty.tools.dotc.ast.tpd
44
import dotty.tools.dotc.core.Contexts.Context
55
import dotty.tools.dotc.transform.MegaPhase._
6+
import dotty.tools.dotc.transform.{ReifyQuotes, FirstTransform}
7+
import dotty.tools.dotc.plugins._
68

79
/** Set the `defTree` property of symbols for compile plugins
810
* that perform "whole-program" analysis.
911
*
1012
* All plugins that depend on `symbol.defTree` should sit
1113
* between the phase `SetDefTree` and `SetDefTreeOff`.
1214
*/
13-
class SetDefTree extends MiniPhase {
15+
class SetDefTree extends PluginPhase {
1416
import tpd._
1517

1618
override val phaseName: String = SetDefTree.name
1719
override def runsAfter: Set[String] = Set(ReifyQuotes.name)
20+
override def runsBefore: Set[String] = Set(FirstTransform.name)
1821
// don't allow plugins to change tasty
1922
// research plugins can still change the phase plan at will
2023

compiler/src/dotty/tools/dotc/transform/SetDefTreeOff.scala renamed to sbt-dotty/sbt-test/sbt-dotty/analyzer-plugin/plugin/SetDefTreeOff.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
package dotty.tools.dotc.transform
1+
package analyzer
22

33
import dotty.tools.dotc.ast.tpd
44
import dotty.tools.dotc.core.Contexts.Context
55
import dotty.tools.dotc.transform.MegaPhase._
6+
import dotty.tools.dotc.transform.{ReifyQuotes, FirstTransform}
7+
import dotty.tools.dotc.plugins._
68

79
/** Unset the `defTree` property of symbols. See the doc for `SetDefTree` */
8-
class SetDefTreeOff extends MiniPhase {
10+
class SetDefTreeOff extends PluginPhase {
911
import tpd._
1012

1113
override val phaseName: String = SetDefTreeOff.name
1214
override def runsAfter: Set[String] = Set(SetDefTree.name)
15+
override def runsBefore: Set[String] = Set(FirstTransform.name)
1316

1417
override def transformValDef(tree: ValDef)(implicit ctx: Context): Tree = {
1518
tree.symbol.defTree = EmptyTree
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pluginClass=analyzer.InitChecker
1+
pluginClass=analyzer.InitPlugin

tests/plugins/custom/analyzer/Analyzer_1.scala

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,27 @@ import Decorators._
1313
import Symbols.Symbol
1414
import Constants.Constant
1515
import Types._
16-
import transform.{SetDefTree, SetDefTreeOff}
16+
import transform.{ReifyQuotes, FirstTransform}
17+
18+
class SetDefTree extends PluginPhase {
19+
import tpd._
20+
21+
override val phaseName: String = SetDefTree.name
22+
override def runsAfter: Set[String] = Set(ReifyQuotes.name)
23+
override def runsBefore: Set[String] = Set(FirstTransform.name)
24+
// don't allow plugins to change tasty
25+
// research plugins can still change the phase plan at will
26+
27+
override def transformValDef(tree: ValDef)(implicit ctx: Context): Tree = tree.setDefTree
28+
29+
override def transformDefDef(tree: DefDef)(implicit ctx: Context): Tree = tree.setDefTree
30+
31+
override def transformTypeDef(tree: TypeDef)(implicit ctx: Context): Tree = tree.setDefTree
32+
}
33+
34+
object SetDefTree {
35+
val name: String = "SetDefTree"
36+
}
1737

1838
class InitChecker extends PluginPhase with StandardPlugin {
1939
import tpd._
@@ -24,9 +44,9 @@ class InitChecker extends PluginPhase with StandardPlugin {
2444
val phaseName = name
2545

2646
override val runsAfter = Set(SetDefTree.name)
27-
override val runsBefore = Set(SetDefTreeOff.name)
47+
override val runsBefore = Set(FirstTransform.name)
2848

29-
def init(options: List[String]): List[PluginPhase] = this :: Nil
49+
def init(options: List[String]): List[PluginPhase] = this :: (new SetDefTree) :: Nil
3050

3151
private def checkDef(tree: Tree)(implicit ctx: Context): Tree = {
3252
if (tree.symbol.defTree.isEmpty)

0 commit comments

Comments
 (0)