Skip to content

Commit 7269b37

Browse files
committed
Make named repeated parameters discoverable during PatMat.
They used to be discoverable using repeatedType, but ElimRepeated eliminates it. Instead I'm using internal synthetic Typed nodes name, similar to how it's done for non-star Wildcards. This makes handling Wildcards and Wildacard_Star more symmetric in patmat.
1 parent 25304a0 commit 7269b37

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
189189

190190
/** Is this argument node of the form <expr> : _* ?
191191
*/
192-
def isWildcardStarArg(tree: untpd.Tree)(implicit ctx: Context): Boolean = unsplice(tree) match {
192+
def isWildcardStarArg(tree: Tree)(implicit ctx: Context): Boolean = unbind(tree) match {
193+
case Typed(Ident(nme.WILDCARD_STAR), _) => true
193194
case Typed(_, Ident(tpnme.WILDCARD_STAR)) => true
194195
case Typed(_, tpt: TypeTree) => tpt.hasType && tpt.tpe.isRepeatedParam
195196
case _ => false

src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
377377
}
378378
tree.expr match {
379379
case id: untpd.Ident if (ctx.mode is Mode.Pattern) && isVarPattern(id) =>
380-
if (id.name == nme.WILDCARD) regularTyped(isWildcard = true)
380+
if (id.name == nme.WILDCARD || id.name == nme.WILDCARD_STAR) regularTyped(isWildcard = true)
381381
else {
382382
import untpd._
383-
typed(Bind(id.name, Typed(Ident(nme.WILDCARD), tree.tpt)).withPos(id.pos), pt)
383+
val name = if (untpd.isWildcardStarArg(tree)) nme.WILDCARD_STAR else nme.WILDCARD
384+
typed(Bind(id.name, Typed(Ident(name), tree.tpt)).withPos(id.pos), pt)
384385
}
385386
case _ =>
386387
if (untpd.isWildcardStarArg(tree))

0 commit comments

Comments
 (0)