@@ -6,25 +6,34 @@ import ast.Trees._
6
6
import core ._
7
7
import Contexts ._ , Types ._ , Decorators ._ , Denotations ._ , Symbols ._ , SymDenotations ._ , Names ._
8
8
9
- /** This transform makes sure every identifier and select node
10
- * carries a symbol. To do this, certain qualifiers with a union type
11
- * have to be "splitted" with a type test.
12
- *
13
- * For now, only self references are treated.
9
+ /** Distribute applications into Block and If nodes
14
10
*/
15
11
class Splitter extends MiniPhaseTransform { thisTransform =>
16
12
import ast .tpd ._
17
13
18
14
override def phaseName : String = " splitter"
19
15
20
- /** Replace self referencing idents with ThisTypes. */
21
- override def transformIdent (tree : Ident )(implicit ctx : Context , info : TransformerInfo ) = tree.tpe match {
22
- case tp : ThisType =>
23
- ctx.debuglog(s " owner = ${ctx.owner}, context = ${ctx}" )
24
- This (tp.cls) withPos tree.pos
25
- case _ => tree
16
+ /** Distribute arguments among splitted branches */
17
+ def distribute (tree : GenericApply [Type ], rebuild : (Tree , List [Tree ]) => Context => Tree )(implicit ctx : Context ) = {
18
+ def recur (fn : Tree ): Tree = fn match {
19
+ case Block (stats, expr) => Block (stats, recur(expr))
20
+ case If (cond, thenp, elsep) => If (cond, recur(thenp), recur(elsep))
21
+ case _ => rebuild(fn, tree.args)(ctx) withPos tree.pos
22
+ }
23
+ recur(tree.fun)
26
24
}
27
25
26
+ override def transformTypeApply (tree : TypeApply )(implicit ctx : Context , info : TransformerInfo ) =
27
+ distribute(tree, typeApply)
28
+
29
+ override def transformApply (tree : Apply )(implicit ctx : Context , info : TransformerInfo ) =
30
+ distribute(tree, apply)
31
+
32
+ private val typeApply = (fn : Tree , args : List [Tree ]) => (ctx : Context ) => TypeApply (fn, args)(ctx)
33
+ private val apply = (fn : Tree , args : List [Tree ]) => (ctx : Context ) => Apply (fn, args)(ctx)
34
+
35
+ /* The following is no longer necessary, since we select members on the join of an or type:
36
+ *
28
37
/** If we select a name, make sure the node has a symbol.
29
38
* If necessary, split the qualifier with type tests.
30
39
* Example: Assume:
@@ -108,23 +117,5 @@ class Splitter extends MiniPhaseTransform { thisTransform =>
108
117
evalOnce(qual)(qual => choose(qual, candidates(qual.tpe)))
109
118
}
110
119
}
111
-
112
- /** Distribute arguments among splitted branches */
113
- def distribute (tree : GenericApply [Type ], rebuild : (Tree , List [Tree ]) => Context => Tree )(implicit ctx : Context ) = {
114
- def recur (fn : Tree ): Tree = fn match {
115
- case Block (stats, expr) => Block (stats, recur(expr))
116
- case If (cond, thenp, elsep) => If (cond, recur(thenp), recur(elsep))
117
- case _ => rebuild(fn, tree.args)(ctx) withPos tree.pos
118
- }
119
- recur(tree.fun)
120
- }
121
-
122
- override def transformTypeApply (tree : TypeApply )(implicit ctx : Context , info : TransformerInfo ) =
123
- distribute(tree, typeApply)
124
-
125
- override def transformApply (tree : Apply )(implicit ctx : Context , info : TransformerInfo ) =
126
- distribute(tree, apply)
127
-
128
- private val typeApply = (fn : Tree , args : List [Tree ]) => (ctx : Context ) => TypeApply (fn, args)(ctx)
129
- private val apply = (fn : Tree , args : List [Tree ]) => (ctx : Context ) => Apply (fn, args)(ctx)
120
+ */
130
121
}
0 commit comments