Skip to content

Fix desugaring of Bind(WILDCARD, _). #1452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/i1432.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Foo {
val _@a = 1 // This entered in an infinite loop
}
2 changes: 2 additions & 0 deletions tests/run/i1432.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Some(foo)
foo
11 changes: 11 additions & 0 deletions tests/run/i1432.scala
Original file line number Diff line number Diff line change
@@ -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)
}

}