Skip to content
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
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,12 @@ object PatternMatcher {
if (scrutinee.info.isNotNull || nonNull(scrutinee)) unappPlan
else TestPlan(NonNullTest, scrutinee, tree.pos, unappPlan, onFailure)
case Bind(name, body) =>
val body1 = patternPlan(scrutinee, body, onSuccess, onFailure)
if (name == nme.WILDCARD) body1
if (name == nme.WILDCARD) patternPlan(scrutinee, body, onSuccess, onFailure)
else {
// The type of `name` may refer to val in `body`, therefore should come after `body`
val bound = tree.symbol.asTerm
initializer(bound) = ref(scrutinee)
LetPlan(bound, body1)
patternPlan(scrutinee, body, LetPlan(bound, onSuccess), onFailure)
}
case Alternative(alts) =>
labelAbstract(onSuccess) { ons =>
Expand Down
8 changes: 8 additions & 0 deletions tests/run/3179.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
object Test {
def main(args: Array[String]): Unit = {
("": Any) match {
case a @ Test => 1
case _ => 2
}
}
}