diff options
author | Martin Odersky <odersky@gmail.com> | 2014-01-18 18:02:13 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-01-18 18:02:28 +0100 |
commit | 55c84fb40bccf7ab7c42f3544bd5f92e69b20ac4 (patch) | |
tree | 8560685b36a6ca3aa76bbf2bfb7d620d4d218280 | |
parent | 558c608daad156410dc2a854d53409eea1b979a1 (diff) | |
download | dotty-55c84fb40bccf7ab7c42f3544bd5f92e69b20ac4.tar.gz dotty-55c84fb40bccf7ab7c42f3544bd5f92e69b20ac4.tar.bz2 dotty-55c84fb40bccf7ab7c42f3544bd5f92e69b20ac4.zip |
Fix isWildcardStarArg test so that it works also for typed trees.
-rw-r--r-- | src/dotty/tools/dotc/ast/TreeInfo.scala | 5 | ||||
-rw-r--r-- | tests/pos/test.scala | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/ast/TreeInfo.scala b/src/dotty/tools/dotc/ast/TreeInfo.scala index 8957d8813..a36e2d600 100644 --- a/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -195,8 +195,9 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => /** Is this argument node of the form <expr> : _* ? */ - def isWildcardStarArg(tree: untpd.Tree): Boolean = unsplice(tree) match { + def isWildcardStarArg(tree: untpd.Tree)(implicit ctx: Context): Boolean = unsplice(tree) match { case Typed(_, Ident(tpnme.WILDCARD_STAR)) => true + case Typed(_, tpt: TypeTree) => tpt.hasType && tpt.tpe.isRepeatedParam case _ => false } @@ -209,7 +210,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => }*/ /** Does this argument list end with an argument of the form <expr> : _* ? */ - def isWildcardStarArgList(trees: List[Tree]) = + def isWildcardStarArgList(trees: List[Tree])(implicit ctx: Context) = trees.nonEmpty && isWildcardStarArg(trees.last) /** Is the argument a wildcard argument of the form `_` or `x @ _`? diff --git a/tests/pos/test.scala b/tests/pos/test.scala index 12af38e02..403ea9704 100644 --- a/tests/pos/test.scala +++ b/tests/pos/test.scala @@ -2,5 +2,11 @@ object test { val x = 2 val y: Int = math.abs(x) + + val xs = List((1, "a"), (2, "b")) + + def write(x: String) = ??? + def write(xs: (Int, String)*) = ??? + write(xs: _*) }
\ No newline at end of file |