diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-02-08 02:32:32 -0800 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-02-08 02:32:32 -0800 |
commit | 3d75d217b2cc9199c2698ed8da100fe92b1db2be (patch) | |
tree | 67f1eddbed73b00ebde93ce1dee3670e245b9a64 /src | |
parent | 62b9e494115cb7a0c4461dbef348c58dd69d7c2b (diff) | |
parent | 96b0eff51e18a1abd9761451e08e63c9a3eb9ea6 (diff) | |
download | scala-3d75d217b2cc9199c2698ed8da100fe92b1db2be.tar.gz scala-3d75d217b2cc9199c2698ed8da100fe92b1db2be.tar.bz2 scala-3d75d217b2cc9199c2698ed8da100fe92b1db2be.zip |
Merge pull request #2085 from scalamacros/ticket/5824
SI-5824 Fix crashes in reify with _*
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/reflect/reify/codegen/GenTrees.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/reflect/reify/phases/Reshape.scala | 12 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/TreeInfo.scala | 7 |
3 files changed, 16 insertions, 5 deletions
diff --git a/src/compiler/scala/reflect/reify/codegen/GenTrees.scala b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala index 949f7f1799..06e287f62f 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTrees.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala @@ -175,7 +175,7 @@ trait GenTrees { // then we can reify the scrutinee as a symless AST and that will definitely be hygienic // why? because then typechecking of a scrutinee doesn't depend on the environment external to the quasiquote // otherwise we need to reify the corresponding type - if (sym.isLocalToReifee || tpe.isLocalToReifee) + if (sym.isLocalToReifee || tpe.isLocalToReifee || treeInfo.isWildcardStarType(tree)) reifyProduct(tree) else { if (reifyDebug) println("reifying bound type %s (underlying type is %s)".format(sym, tpe)) diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index 1b7509fdbe..7406f5d02d 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -188,8 +188,12 @@ trait Reshape { } private def toPreTyperTypedOrAnnotated(tree: Tree): Tree = tree match { - case ty @ Typed(expr1, tt @ TypeTree()) => + case ty @ Typed(expr1, tpt) => if (reifyDebug) println("reify typed: " + tree) + val original = tpt match { + case tt @ TypeTree() => tt.original + case tpt => tpt + } val annotatedArg = { def loop(tree: Tree): Tree = tree match { case annotated1 @ Annotated(ann, annotated2 @ Annotated(_, _)) => loop(annotated2) @@ -197,15 +201,15 @@ trait Reshape { case _ => EmptyTree } - loop(tt.original) + loop(original) } if (annotatedArg != EmptyTree) { if (annotatedArg.isType) { if (reifyDebug) println("verdict: was an annotated type, reify as usual") ty } else { - if (reifyDebug) println("verdict: was an annotated value, equivalent is " + tt.original) - toPreTyperTypedOrAnnotated(tt.original) + if (reifyDebug) println("verdict: was an annotated value, equivalent is " + original) + toPreTyperTypedOrAnnotated(original) } } else { if (reifyDebug) println("verdict: wasn't annotated, reify as usual") diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index bccad69638..8b5dc80c83 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -428,6 +428,13 @@ abstract class TreeInfo { case _ => false } + /** Is the argument a wildcard star type of the form `_*`? + */ + def isWildcardStarType(tree: Tree): Boolean = tree match { + case Ident(tpnme.WILDCARD_STAR) => true + case _ => false + } + /** Is this pattern node a catch-all (wildcard or variable) pattern? */ def isDefaultCase(cdef: CaseDef) = cdef match { case CaseDef(pat, EmptyTree, _) => isWildcardArg(pat) |