diff --git a/src/Psalm/Internal/Type/Comparator/ObjectComparator.php b/src/Psalm/Internal/Type/Comparator/ObjectComparator.php index 53d823a10..a0ae71166 100644 --- a/src/Psalm/Internal/Type/Comparator/ObjectComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ObjectComparator.php @@ -239,7 +239,7 @@ class ObjectComparator $input_type_is_interface = $codebase->interfaceExists($intersection_input_type_lower); $container_type_is_interface = $codebase->interfaceExists($intersection_container_type_lower); - if ($allow_interface_equality && $input_type_is_interface && $container_type_is_interface) { + if ($allow_interface_equality && $container_type_is_interface) { continue 2; } diff --git a/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php b/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php index 9d777452c..8477e4823 100644 --- a/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php @@ -428,7 +428,8 @@ class UnionTypeComparator $type2_part, true, false, - $first_comparison_result + $first_comparison_result, + true ) && !$first_comparison_result->to_string_cast ) || (AtomicTypeComparator::isContainedBy( @@ -437,7 +438,8 @@ class UnionTypeComparator $type1_part, true, false, - $second_comparison_result + $second_comparison_result, + true ) && !$second_comparison_result->to_string_cast ) || ($first_comparison_result->type_coerced diff --git a/tests/TypeReconciliation/ConditionalTest.php b/tests/TypeReconciliation/ConditionalTest.php index e67f93feb..0a36b2535 100644 --- a/tests/TypeReconciliation/ConditionalTest.php +++ b/tests/TypeReconciliation/ConditionalTest.php @@ -2818,6 +2818,16 @@ class ConditionalTest extends \Psalm\Tests\TestCase } }' ], + 'getClassInterfaceCanBeClass' => [ + '