aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-08-17 20:38:57 -0700
committerGitHub <noreply@github.com>2016-08-17 20:38:57 -0700
commit5a5f9d7ed37ca6449ef61ee5e0f6fbf9731df795 (patch)
treebf3c9bc5760db020986aec535c4f5e086cbac4f4
parentaaa32f70da1df75e0571a080a1738634b8bad6c6 (diff)
parent0b2ddd0df33bf529b062dc6167b50a33fa5f84b7 (diff)
downloaddotty-5a5f9d7ed37ca6449ef61ee5e0f6fbf9731df795.tar.gz
dotty-5a5f9d7ed37ca6449ef61ee5e0f6fbf9731df795.tar.bz2
dotty-5a5f9d7ed37ca6449ef61ee5e0f6fbf9731df795.zip
Merge pull request #1452 from dotty-staging/fix-#1432
Fix desugaring of Bind(WILDCARD, _).
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala4
-rw-r--r--tests/pos/i1432.scala3
-rw-r--r--tests/run/i1432.check2
-rw-r--r--tests/run/i1432.scala11
4 files changed, 18 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala
index a9705e209..8a4b9cfe8 100644
--- a/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/src/dotty/tools/dotc/ast/Desugar.scala
@@ -1007,8 +1007,8 @@ object desugar {
def add(named: NameTree, t: Tree): Unit =
if (!seenName(named.name)) buf += ((named, t))
def collect(tree: Tree): Unit = tree match {
- case Bind(nme.WILDCARD, _) =>
- collect(tree)
+ case Bind(nme.WILDCARD, tree1) =>
+ collect(tree1)
case tree @ Bind(_, Typed(tree1, tpt)) if !mayBeTypePat(tpt) =>
add(tree, tpt)
collect(tree1)
diff --git a/tests/pos/i1432.scala b/tests/pos/i1432.scala
new file mode 100644
index 000000000..fb9d4c6ab
--- /dev/null
+++ b/tests/pos/i1432.scala
@@ -0,0 +1,3 @@
+object Foo {
+ val _@a = 1 // This entered in an infinite loop
+}
diff --git a/tests/run/i1432.check b/tests/run/i1432.check
new file mode 100644
index 000000000..ace7d40d3
--- /dev/null
+++ b/tests/run/i1432.check
@@ -0,0 +1,2 @@
+Some(foo)
+foo
diff --git a/tests/run/i1432.scala b/tests/run/i1432.scala
new file mode 100644
index 000000000..e71b76f8e
--- /dev/null
+++ b/tests/run/i1432.scala
@@ -0,0 +1,11 @@
+object Test {
+
+ def main(args: Array[String]): Unit = {
+ val someFoo = Some("foo")
+ val _ @ bar = someFoo
+ val _ @ Some(baz) = someFoo
+ println(bar)
+ println(baz)
+ }
+
+}