Skip to content
Snippets Groups Projects
Commit 1ae8d9ec authored by Etienne Kneuss's avatar Etienne Kneuss
Browse files

Do not decompose in case there is no hope for pattern matching reconstruction

parent 22aebcd0
No related branches found
No related tags found
No related merge requests found
...@@ -1078,18 +1078,22 @@ object TreeOps { ...@@ -1078,18 +1078,22 @@ object TreeOps {
case IfExpr(cond, then, elze) => case IfExpr(cond, then, elze) =>
val TopLevelOrs(orcases) = toDNF(cond) val TopLevelOrs(orcases) = toDNF(cond)
if (!orcases.tail.isEmpty) { if (orcases.exists{ case TopLevelAnds(ands) => ands.exists(_.isInstanceOf[CaseClassInstanceOf]) } ) {
pre(IfExpr(orcases.head, then, IfExpr(Or(orcases.tail), then, elze))) if (!orcases.tail.isEmpty) {
} else { pre(IfExpr(orcases.head, then, IfExpr(Or(orcases.tail), then, elze)))
val TopLevelAnds(andcases) = orcases.head } else {
val TopLevelAnds(andcases) = orcases.head
val (andis, andnotis) = andcases.partition(_.isInstanceOf[CaseClassInstanceOf]) val (andis, andnotis) = andcases.partition(_.isInstanceOf[CaseClassInstanceOf])
if (andis.isEmpty || andnotis.isEmpty) { if (andis.isEmpty || andnotis.isEmpty) {
e e
} else { } else {
IfExpr(And(andis), IfExpr(And(andnotis), then, elze), elze) IfExpr(And(andis), IfExpr(And(andnotis), then, elze), elze)
}
} }
} else {
e
} }
case _ => case _ =>
e e
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment