diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2016-08-09 16:50:15 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2016-08-09 16:50:15 +0200 |
commit | debc5fd624526747712114293a1e7b7b6bc3730a (patch) | |
tree | d9efb6d58736253010f94521cd7bad317ffac44c | |
parent | a1a35c92207c78bfefb95bb1265b3a2968d52d90 (diff) | |
download | dotty-debc5fd624526747712114293a1e7b7b6bc3730a.tar.gz dotty-debc5fd624526747712114293a1e7b7b6bc3730a.tar.bz2 dotty-debc5fd624526747712114293a1e7b7b6bc3730a.zip |
SelectStatic: do not create blocks that are qualifier of select\apply
Blocks are not denoting trees(why aren't they?)
For now, I'm fixing this using a quick fix.
For future, it may make sense to discuss this on dotty meeting and
make blocks be a Denoting tree and return denotation of expo.
Another option is to move regularisation logic into tree transformers.
-rw-r--r-- | src/dotty/tools/dotc/transform/SelectStatic.scala | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/dotty/tools/dotc/transform/SelectStatic.scala b/src/dotty/tools/dotc/transform/SelectStatic.scala index 5810d18ca..c6d47df16 100644 --- a/src/dotty/tools/dotc/transform/SelectStatic.scala +++ b/src/dotty/tools/dotc/transform/SelectStatic.scala @@ -1,6 +1,7 @@ package dotty.tools.dotc package transform +import dotty.tools.dotc.ast.Trees._ import dotty.tools.dotc.ast.tpd import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.DenotTransformers.IdentityDenotTransformer @@ -23,17 +24,32 @@ class SelectStatic extends MiniPhaseTransform with IdentityDenotTransformer { th override def transformSelect(tree: tpd.Select)(implicit ctx: Context, info: TransformerInfo): tpd.Tree = { val sym = tree.symbol - if (!sym.is(isPackage) && !sym.maybeOwner.is(isPackage) && - ( - ((sym is Flags.Module) && sym.maybeOwner.isStaticOwner) || - (sym is Flags.JavaStatic) || - (sym.maybeOwner is Flags.ImplClass) || - sym.hasAnnotation(ctx.definitions.ScalaStaticAnnot) - ) - ) - if (!tree.qualifier.symbol.is(JavaModule)) - Block(List(tree.qualifier), ref(sym)) + val r1 = + if (!sym.is(isPackage) && !sym.maybeOwner.is(isPackage) && + ( + ((sym is Flags.Module) && sym.maybeOwner.isStaticOwner) || + (sym is Flags.JavaStatic) || + (sym.maybeOwner is Flags.ImplClass) || + sym.hasAnnotation(ctx.definitions.ScalaStaticAnnot) + ) + ) + if (!tree.qualifier.symbol.is(JavaModule)) + Block(List(tree.qualifier), ref(sym)) + else tree else tree - else tree + + normalize(r1) + } + + private def normalize(t: Tree)(implicit ctx: Context) = t match { + case Select(Block(stats, qual), nm) => + Block(stats, Select(qual, nm)) + case Apply(Block(stats, qual), nm) => + Block(stats, Apply(qual, nm)) + case _ => t + } + + override def transformApply(tree: tpd.Apply)(implicit ctx: Context, info: TransformerInfo): tpd.Tree = { + normalize(tree) } } |