Skip to content

Fix #167 #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ object desugar {
case tree @ Bind(_, tree1) =>
add(tree, TypeTree())
collect(tree1)
case Typed(id: Ident, t) if isVarPattern(id) && id.name != nme.WILDCARD =>
case Typed(id: Ident, t) if isVarPattern(id) && id.name != nme.WILDCARD && !isWildcardStarArg(tree) =>
add(id, t)
case id: Ident if isVarPattern(id) && id.name != nme.WILDCARD =>
add(id, TypeTree())
Expand Down
8 changes: 6 additions & 2 deletions src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit

def typedTyped(tree: untpd.Typed, pt: Type)(implicit ctx: Context): Tree = track("typedTyped") {
def regularTyped(isWildcard: Boolean) = {
val tpt1 = typedType(tree.tpt)
val tpt1 =
if (untpd.isWildcardStarArg(tree))
TypeTree(defn.SeqClass.typeRef.appliedTo(pt :: Nil))
else
typedType(tree.tpt)
val expr1 =
if (isWildcard) tree.expr withType tpt1.tpe
else typed(tree.expr, tpt1.tpe)
Expand All @@ -336,7 +340,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
if (id.name == nme.WILDCARD) regularTyped(isWildcard = true)
else {
import untpd._
typed(Bind(id.name, Typed(Ident(nme.WILDCARD), tree.tpt)).withPos(id.pos))
typed(Bind(id.name, Typed(Ident(nme.WILDCARD), tree.tpt)).withPos(id.pos), pt)
}
case _ =>
if (untpd.isWildcardStarArg(tree))
Expand Down
12 changes: 12 additions & 0 deletions tests/pos/vararg-pattern.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
object Test {

List(1, 2, 3, 4) match {
case List(1, 2, xs: _*) =>
val ys: Seq[Int] = xs
println(ys)
}
val List(1, 2, x: _*) = List(1, 2, 3, 4)

}