Skip to content

Commit

Permalink
Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Apr 29, 2024
1 parent 91cfbff commit 69ecec6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Psalm\Type\Atomic;
use Psalm\Type\Atomic\TClassString;
use Psalm\Type\Atomic\TConditional;
use Psalm\Type\Atomic\TFloat;
use Psalm\Type\Atomic\TInt;
use Psalm\Type\Atomic\TIterable;
use Psalm\Type\Atomic\TKeyOf;
Expand Down Expand Up @@ -451,12 +452,17 @@ private static function replaceConditional(
null,
false,
false,
) && null === Type::intersectUnionTypes(
new Union([$candidate_atomic_type]),
$conditional_type,
$codebase,
)) {
$matching_else_types[] = $candidate_atomic_type;
$intersection = Type::intersectUnionTypes(
new Union([$candidate_atomic_type]),
$conditional_type,
$codebase,
);
if (null === $intersection
|| ($candidate_atomic_type instanceof TFloat
&& $intersection->getKey() === 'int')) {
$matching_else_types[] = $candidate_atomic_type;
}
}
}

Expand Down

0 comments on commit 69ecec6

Please sign in to comment.