Skip to content

Commit a142f4c

Browse files
VLanvinfacebook-github-bot
authored andcommitted
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
1 parent aadbac1 commit a142f4c

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

eqwalizer/src/main/scala/com/whatsapp/eqwalizer/tc/Occurrence.scala

+1-20
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,7 @@ final class Occurrence(pipelineContext: PipelineContext) {
483483
.map(obj => (Pos(obj, tp), Neg(obj, tp)))
484484
.getOrElse(Unknown, Unknown)
485485
case TestUnOp("not", test) =>
486-
val (p1, p2) = testProps(test, aMap)
487-
(negateGuardProp(p1), negateGuardProp(p2))
486+
testProps(test, aMap).swap
488487
case TestBinOp("and" | "andalso", test1, test2) =>
489488
val (pos1, neg1) = testProps(test1, aMap)
490489
val (pos2, neg2) = testProps(test2, aMap)
@@ -507,24 +506,6 @@ final class Occurrence(pipelineContext: PipelineContext) {
507506
}
508507
}
509508

510-
private def negateGuardProp(prop: Prop): Prop =
511-
prop match {
512-
case True =>
513-
False
514-
case False =>
515-
True
516-
case Unknown =>
517-
Unknown
518-
case And(props) =>
519-
or(props.map(negateGuardProp))
520-
case Or(props) =>
521-
and(props.map(negateGuardProp))
522-
case Pos(obj, t) =>
523-
Neg(obj, t)
524-
case Neg(obj, t) =>
525-
Pos(obj, t)
526-
}
527-
528509
private def patProps(x: String, path: Path, pat: Pat, env: Env): Option[(Prop, Prop)] = {
529510
pat match {
530511
case PatWild() =>

0 commit comments

Comments
 (0)