Skip to content

Commit d7c201b

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 ae8a246 commit d7c201b

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
@@ -184,7 +184,8 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
184184

185185
/** Is this argument node of the form <expr> : _* ?
186186
*/
187-
def isWildcardStarArg(tree: untpd.Tree)(implicit ctx: Context): Boolean = unsplice(tree) match {
187+
def isWildcardStarArg(tree: Tree)(implicit ctx: Context): Boolean = unbind(tree) match {
188+
case Typed(Ident(nme.WILDCARD_STAR), _) => true
188189
case Typed(_, Ident(tpnme.WILDCARD_STAR)) => true
189190
case Typed(_, tpt: TypeTree) => tpt.hasType && tpt.tpe.isRepeatedParam
190191
case _ => false

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

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

0 commit comments

Comments
 (0)