@@ -645,10 +645,14 @@ public function specifyTypesInCondition(
645645 $ rightTypes = $ this ->specifyTypesInCondition ($ rightScope , $ expr ->right , $ context )->setRootExpr ($ expr );
646646 $ types = $ context ->true () ? $ leftTypes ->unionWith ($ rightTypes ) : $ leftTypes ->normalize ($ scope )->intersectWith ($ rightTypes ->normalize ($ rightScope ));
647647 if ($ context ->false ()) {
648- return ( new SpecifiedTypes (
648+ $ result = new SpecifiedTypes (
649649 $ types ->getSureTypes (),
650650 $ types ->getSureNotTypes (),
651- ))->setNewConditionalExpressionHolders (array_merge (
651+ );
652+ if ($ types ->shouldOverwrite ()) {
653+ $ result = $ result ->setAlwaysOverwriteTypes ();
654+ }
655+ return $ result ->setNewConditionalExpressionHolders (array_merge (
652656 $ this ->processBooleanNotSureConditionalTypes ($ scope , $ leftTypes , $ rightTypes ),
653657 $ this ->processBooleanNotSureConditionalTypes ($ scope , $ rightTypes , $ leftTypes ),
654658 $ this ->processBooleanSureConditionalTypes ($ scope , $ leftTypes , $ rightTypes ),
@@ -683,10 +687,14 @@ public function specifyTypesInCondition(
683687 }
684688
685689 if ($ context ->true ()) {
686- return ( new SpecifiedTypes (
690+ $ result = new SpecifiedTypes (
687691 $ types ->getSureTypes (),
688692 $ types ->getSureNotTypes (),
689- ))->setNewConditionalExpressionHolders (array_merge (
693+ );
694+ if ($ types ->shouldOverwrite ()) {
695+ $ result = $ result ->setAlwaysOverwriteTypes ();
696+ }
697+ return $ result ->setNewConditionalExpressionHolders (array_merge (
690698 $ this ->processBooleanNotSureConditionalTypes ($ scope , $ leftTypes , $ rightTypes ),
691699 $ this ->processBooleanNotSureConditionalTypes ($ scope , $ rightTypes , $ leftTypes ),
692700 $ this ->processBooleanSureConditionalTypes ($ scope , $ leftTypes , $ rightTypes ),
0 commit comments