diff options
author | Martin Odersky <odersky@gmail.com> | 2014-08-30 12:50:29 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-08-30 12:50:29 +0200 |
commit | 5362969b55cc73c22ea959d1960e3696a801c469 (patch) | |
tree | 0fa99693e4fe58f40fa0786a973eb6f20f4cad10 | |
parent | cc687b406d1f3a6f0f6d47a9d364c3eba46792e1 (diff) | |
download | dotty-5362969b55cc73c22ea959d1960e3696a801c469.tar.gz dotty-5362969b55cc73c22ea959d1960e3696a801c469.tar.bz2 dotty-5362969b55cc73c22ea959d1960e3696a801c469.zip |
Eliminate Ident/Select types in FirstTransform
Ident, Select, SelectFromTypeTrees denoting types should be eliminated
at some point. FirstTransform seems to be the logical place because
it already eliminates other forms of type trees.
-rw-r--r-- | src/dotty/tools/dotc/transform/FirstTransform.scala | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/transform/FirstTransform.scala b/src/dotty/tools/dotc/transform/FirstTransform.scala index 3eaa26843..8d0c2ef1d 100644 --- a/src/dotty/tools/dotc/transform/FirstTransform.scala +++ b/src/dotty/tools/dotc/transform/FirstTransform.scala @@ -20,6 +20,7 @@ import NameOps._ /** The first tree transform * - ensures there are companion objects for all classes except module classes * - eliminates some kinds of trees: Imports, NamedArgs, all TypTrees other than TypeTree + * - converts Select/Ident/SelectFromTypeTree nodes that refer to types to TypeTrees. * - checks the bounds of AppliedTypeTrees * - stubs out native methods */ @@ -80,6 +81,18 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer { override def transformStats(trees: List[Tree])(implicit ctx: Context, info: TransformerInfo): List[Tree] = ast.Trees.flatten(reorderAndComplete(trees)(ctx.withPhase(thisTransformer.next))) + private def normalizeType(tree: Tree)(implicit ctx: Context) = + if (tree.isType) TypeTree(tree.tpe).withPos(tree.pos) else tree + + override def transformIdent(tree: Ident)(implicit ctx: Context, info: TransformerInfo) = + normalizeType(tree) + + override def transformSelect(tree: Select)(implicit ctx: Context, info: TransformerInfo) = + normalizeType(tree) + + override def transformSelectFromTypeTree(tree: SelectFromTypeTree)(implicit ctx: Context, info: TransformerInfo) = + normalizeType(tree) + override def transformOther(tree: Tree)(implicit ctx: Context, info: TransformerInfo) = tree match { case tree: Import => EmptyTree case tree: NamedArg => tree.arg @@ -87,9 +100,8 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer { val tparams = tycon.tpe.typeSymbol.typeParams Checking.checkBounds( args, tparams.map(_.info.bounds), (tp, argTypes) => tp.substDealias(tparams, argTypes)) - TypeTree(tree.tpe).withPos(tree.pos) + normalizeType(tree) case tree => - if (tree.isType) TypeTree(tree.tpe, tree).withPos(tree.pos) - else tree + normalizeType(tree) } } |