Skip to content

Commit 0aa8685

Browse files
author
Oron Port
committed
fix dfhdl after scalac change scala/scala3#23373
1 parent 5213d92 commit 0aa8685

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

plugin/src/main/scala/plugin/CustomControlPhase.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,15 +865,22 @@ class CustomControlPhase(setting: Setting) extends CommonPhase:
865865
// skipping trivial tuple match replacement that should cause the match
866866
// to be discarded by scalac. one example is a foldLeft (see relevant under DFMatchSpec).
867867
private def skipTrivialTupleMatch(tree: Match)(using Context): Boolean =
868-
if (tree.selector.tpe <:< defn.TupleTypeRef) tree.cases match
869-
case CaseDef(UnApply(_, _, patterns), guard, _) :: Nil if guard.isEmpty =>
868+
object SkipPatterns:
869+
def unapply(patterns: List[Tree])(using Context): Boolean =
870870
patterns.forall {
871871
case Ident(_) => true
872872
case Bind(_, Ident(_)) => true
873873
case _ => false
874874
}
875-
case _ => false
875+
end SkipPatterns
876+
if (tree.selector.tpe <:< defn.TupleTypeRef)
877+
tree.cases match
878+
case CaseDef(Bind(_, UnApply(_, _, SkipPatterns())), guard, _) :: Nil if guard.isEmpty =>
879+
true
880+
case CaseDef(UnApply(_, _, SkipPatterns()), guard, _) :: Nil if guard.isEmpty => true
881+
case _ => false
876882
else false
883+
end skipTrivialTupleMatch
877884

878885
extension (tree: Match)
879886
def isExtractor(using Context): Boolean =

0 commit comments

Comments
 (0)