Skip to content

Commit bb75d40

Browse files
committed
Merge pull request #669 from dotty-staging/fix-patmat-seq
Fix sequence matching.
2 parents ad6c4ad + d3819ce commit bb75d40

File tree

7 files changed

+6
-4
lines changed

7 files changed

+6
-4
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/transform/PatternMatcher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
136136
def callDirect = tgt.select(nme.drop).appliedTo(Literal(Constant(n)))
137137
def callRuntime = ref(defn.traversableDropMethod).appliedTo(tgt, Literal(Constant(n)))
138138

139-
def needsRuntime = tgt.tpe derivesFrom defn.SeqClass /*typeOfMemberNamedDrop(tgt.tpe) == NoType*/
139+
def needsRuntime = !(tgt.tpe derivesFrom defn.SeqClass) /*typeOfMemberNamedDrop(tgt.tpe) == NoType*/
140140

141141
if (needsRuntime) callRuntime else callDirect
142142
}

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))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)