aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2015-06-19 18:44:41 +0200
committerodersky <odersky@gmail.com>2015-06-19 18:44:41 +0200
commitbb75d4039ee127dfee2630609924f7f3c9132ff6 (patch)
tree2cfb328fd518fe70fc9d025f33bdbe0e5ea229ad
parentad6c4ad920bfed6c7c9a87850f51433260a2acf5 (diff)
parentd3819ce631310baab00c44a0d1845b267d60bcdd (diff)
downloaddotty-bb75d4039ee127dfee2630609924f7f3c9132ff6.tar.gz
dotty-bb75d4039ee127dfee2630609924f7f3c9132ff6.tar.bz2
dotty-bb75d4039ee127dfee2630609924f7f3c9132ff6.zip
Merge pull request #669 from dotty-staging/fix-patmat-seq
Fix sequence matching.
-rw-r--r--src/dotty/tools/dotc/ast/TreeInfo.scala3
-rw-r--r--src/dotty/tools/dotc/transform/PatternMatcher.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala5
-rw-r--r--tests/run/t5629b.check (renamed from tests/pending/run/t5629b.check)0
-rw-r--r--tests/run/t5629b.scala (renamed from tests/pending/run/t5629b.scala)0
-rw-r--r--tests/run/t889.check (renamed from tests/pending/run/t889.check)0
-rw-r--r--tests/run/t889.scala (renamed from tests/pending/run/t889.scala)0
7 files changed, 6 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/ast/TreeInfo.scala b/src/dotty/tools/dotc/ast/TreeInfo.scala
index c9a22f09e..82c8c9d60 100644
--- a/src/dotty/tools/dotc/ast/TreeInfo.scala
+++ b/src/dotty/tools/dotc/ast/TreeInfo.scala
@@ -189,7 +189,8 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
/** Is this argument node of the form <expr> : _* ?
*/
- def isWildcardStarArg(tree: untpd.Tree)(implicit ctx: Context): Boolean = unsplice(tree) match {
+ def isWildcardStarArg(tree: Tree)(implicit ctx: Context): Boolean = unbind(tree) match {
+ case Typed(Ident(nme.WILDCARD_STAR), _) => true
case Typed(_, Ident(tpnme.WILDCARD_STAR)) => true
case Typed(_, tpt: TypeTree) => tpt.hasType && tpt.tpe.isRepeatedParam
case _ => false
diff --git a/src/dotty/tools/dotc/transform/PatternMatcher.scala b/src/dotty/tools/dotc/transform/PatternMatcher.scala
index 5fa17921f..af8da01ff 100644
--- a/src/dotty/tools/dotc/transform/PatternMatcher.scala
+++ b/src/dotty/tools/dotc/transform/PatternMatcher.scala
@@ -136,7 +136,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
def callDirect = tgt.select(nme.drop).appliedTo(Literal(Constant(n)))
def callRuntime = ref(defn.traversableDropMethod).appliedTo(tgt, Literal(Constant(n)))
- def needsRuntime = tgt.tpe derivesFrom defn.SeqClass /*typeOfMemberNamedDrop(tgt.tpe) == NoType*/
+ def needsRuntime = !(tgt.tpe derivesFrom defn.SeqClass) /*typeOfMemberNamedDrop(tgt.tpe) == NoType*/
if (needsRuntime) callRuntime else callDirect
}
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 2bdd0d197..f8a33cc85 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -377,10 +377,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}
tree.expr match {
case id: untpd.Ident if (ctx.mode is Mode.Pattern) && isVarPattern(id) =>
- if (id.name == nme.WILDCARD) regularTyped(isWildcard = true)
+ if (id.name == nme.WILDCARD || id.name == nme.WILDCARD_STAR) regularTyped(isWildcard = true)
else {
import untpd._
- typed(Bind(id.name, Typed(Ident(nme.WILDCARD), tree.tpt)).withPos(id.pos), pt)
+ val name = if (untpd.isWildcardStarArg(tree)) nme.WILDCARD_STAR else nme.WILDCARD
+ typed(Bind(id.name, Typed(Ident(name), tree.tpt)).withPos(id.pos), pt)
}
case _ =>
if (untpd.isWildcardStarArg(tree))
diff --git a/tests/pending/run/t5629b.check b/tests/run/t5629b.check
index e0f25f0b0..e0f25f0b0 100644
--- a/tests/pending/run/t5629b.check
+++ b/tests/run/t5629b.check
diff --git a/tests/pending/run/t5629b.scala b/tests/run/t5629b.scala
index 9cee18893..9cee18893 100644
--- a/tests/pending/run/t5629b.scala
+++ b/tests/run/t5629b.scala
diff --git a/tests/pending/run/t889.check b/tests/run/t889.check
index 67ca2bf46..67ca2bf46 100644
--- a/tests/pending/run/t889.check
+++ b/tests/run/t889.check
diff --git a/tests/pending/run/t889.scala b/tests/run/t889.scala
index 8e5d82412..8e5d82412 100644
--- a/tests/pending/run/t889.scala
+++ b/tests/run/t889.scala