File tree Expand file tree Collapse file tree 5 files changed +25
-5
lines changed
compiler/scala/reflect/reify
reflect/scala/reflect/internal Expand file tree Collapse file tree 5 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ trait GenTrees {
177
177
// then we can reify the scrutinee as a symless AST and that will definitely be hygienic
178
178
// why? because then typechecking of a scrutinee doesn't depend on the environment external to the quasiquote
179
179
// otherwise we need to reify the corresponding type
180
- if (sym.isLocalToReifee || tpe.isLocalToReifee)
180
+ if (sym.isLocalToReifee || tpe.isLocalToReifee || treeInfo.isWildcardStarType(tree) )
181
181
reifyProduct(tree)
182
182
else {
183
183
if (reifyDebug) println(" reifying bound type %s (underlying type is %s)" .format(sym, tpe))
Original file line number Diff line number Diff line change @@ -188,24 +188,28 @@ trait Reshape {
188
188
}
189
189
190
190
private def toPreTyperTypedOrAnnotated (tree : Tree ): Tree = tree match {
191
- case ty @ Typed (expr1, tt @ TypeTree () ) =>
191
+ case ty @ Typed (expr1, tpt ) =>
192
192
if (reifyDebug) println(" reify typed: " + tree)
193
+ val original = tpt match {
194
+ case tt @ TypeTree () => tt.original
195
+ case tpt => tpt
196
+ }
193
197
val annotatedArg = {
194
198
def loop (tree : Tree ): Tree = tree match {
195
199
case annotated1 @ Annotated (ann, annotated2 @ Annotated (_, _)) => loop(annotated2)
196
200
case annotated1 @ Annotated (ann, arg) => arg
197
201
case _ => EmptyTree
198
202
}
199
203
200
- loop(tt. original)
204
+ loop(original)
201
205
}
202
206
if (annotatedArg != EmptyTree ) {
203
207
if (annotatedArg.isType) {
204
208
if (reifyDebug) println(" verdict: was an annotated type, reify as usual" )
205
209
ty
206
210
} else {
207
- if (reifyDebug) println(" verdict: was an annotated value, equivalent is " + tt. original)
208
- toPreTyperTypedOrAnnotated(tt. original)
211
+ if (reifyDebug) println(" verdict: was an annotated value, equivalent is " + original)
212
+ toPreTyperTypedOrAnnotated(original)
209
213
}
210
214
} else {
211
215
if (reifyDebug) println(" verdict: wasn't annotated, reify as usual" )
Original file line number Diff line number Diff line change @@ -431,6 +431,13 @@ abstract class TreeInfo {
431
431
case _ => false
432
432
}
433
433
434
+ /** Is the argument a wildcard star type of the form `_*`?
435
+ */
436
+ def isWildcardStarType (tree : Tree ): Boolean = tree match {
437
+ case Ident (tpnme.WILDCARD_STAR ) => true
438
+ case _ => false
439
+ }
440
+
434
441
/** Is this pattern node a catch-all (wildcard or variable) pattern? */
435
442
def isDefaultCase (cdef : CaseDef ) = cdef match {
436
443
case CaseDef (pat, EmptyTree , _) => isWildcardArg(pat)
Original file line number Diff line number Diff line change
1
+ a b c
Original file line number Diff line number Diff line change
1
+ import scala .reflect .runtime .universe ._
2
+ import scala .tools .reflect .Eval
3
+
4
+ object Test extends App {
5
+ reify {
6
+ println(" %s %s %s" .format(List (" a" , " b" , " c" ): _* ))
7
+ }.eval
8
+ }
You can’t perform that action at this time.
0 commit comments