Skip to content
Draft
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
7 changes: 4 additions & 3 deletions compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,13 @@ object PatternMatcher {

private def caseDefPlan(scrutinee: Symbol, cdef: CaseDef): Plan =
val CaseDef(pat, guard, body) = cdef
val caseDefBodyPlan: Plan = body match
def caseDefBodyPlan(body: Tree = body): Plan = body match
case Typed(t, _) => caseDefBodyPlan(t)
case t: SubMatch => subMatchPlan(t)
case _ => ResultPlan(body)
val onSuccess: Plan =
if guard.isEmpty then caseDefBodyPlan
else TestPlan(GuardTest, guard, guard.span, caseDefBodyPlan)
if guard.isEmpty then caseDefBodyPlan()
else TestPlan(GuardTest, guard, guard.span, caseDefBodyPlan())
patternPlan(scrutinee, pat, onSuccess)
end caseDefPlan

Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotc/scoverage-ignore.excludelist
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ tailrec.scala
traitParams.scala
i25460.scala
matrix.scala
i25746.scala
9 changes: 9 additions & 0 deletions tests/pos/i25746.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import scala.language.experimental.subCases

@main def test =
val r1 = "^foo".r.unanchored
val r2 = "bar$".r.unanchored

val result1 = "foo bar" match
case s @ r1() if s match { case r2() => s }
case _ => "no"
Loading