From a142f4c05f5eb151630133c777dcc55c1cadf697 Mon Sep 17 00:00:00 2001 From: Victor Lanvin Date: Mon, 29 Jul 2024 08:33:01 -0700 Subject: [PATCH] Swap props to negate tests Summary: `negateGuardProp` is not the correct way to negate a test: since we already have both the positive and the negated prop on hand, reversing the two is enough and correct. Reviewed By: ilya-klyuchnikov Differential Revision: D60386301 fbshipit-source-id: a761c205f9c76b7fa2f89f3a4ac21ee451045a98 --- .../whatsapp/eqwalizer/tc/Occurrence.scala | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/eqwalizer/src/main/scala/com/whatsapp/eqwalizer/tc/Occurrence.scala b/eqwalizer/src/main/scala/com/whatsapp/eqwalizer/tc/Occurrence.scala index 523e043..5fff8ff 100644 --- a/eqwalizer/src/main/scala/com/whatsapp/eqwalizer/tc/Occurrence.scala +++ b/eqwalizer/src/main/scala/com/whatsapp/eqwalizer/tc/Occurrence.scala @@ -483,8 +483,7 @@ final class Occurrence(pipelineContext: PipelineContext) { .map(obj => (Pos(obj, tp), Neg(obj, tp))) .getOrElse(Unknown, Unknown) case TestUnOp("not", test) => - val (p1, p2) = testProps(test, aMap) - (negateGuardProp(p1), negateGuardProp(p2)) + testProps(test, aMap).swap case TestBinOp("and" | "andalso", test1, test2) => val (pos1, neg1) = testProps(test1, aMap) val (pos2, neg2) = testProps(test2, aMap) @@ -507,24 +506,6 @@ final class Occurrence(pipelineContext: PipelineContext) { } } - private def negateGuardProp(prop: Prop): Prop = - prop match { - case True => - False - case False => - True - case Unknown => - Unknown - case And(props) => - or(props.map(negateGuardProp)) - case Or(props) => - and(props.map(negateGuardProp)) - case Pos(obj, t) => - Neg(obj, t) - case Neg(obj, t) => - Pos(obj, t) - } - private def patProps(x: String, path: Path, pat: Pat, env: Env): Option[(Prop, Prop)] = { pat match { case PatWild() =>