diff --git a/src/Psalm/Internal/Type/TypeCombination.php b/src/Psalm/Internal/Type/TypeCombination.php index b50038a86..4af1c1678 100644 --- a/src/Psalm/Internal/Type/TypeCombination.php +++ b/src/Psalm/Internal/Type/TypeCombination.php @@ -371,13 +371,16 @@ class TypeCombination $overwrite_empty_array, $allow_mixed_union ); - $generic_type_params[1] = Type::combineUnionTypes( - $generic_type_params[1], - $objectlike_generic_type, - $codebase, - $overwrite_empty_array, - $allow_mixed_union - ); + + if (!$generic_type_params[1]->isMixed()) { + $generic_type_params[1] = Type::combineUnionTypes( + $generic_type_params[1], + $objectlike_generic_type, + $codebase, + $overwrite_empty_array, + $allow_mixed_union + ); + } } if ($combination->array_always_filled diff --git a/tests/ArrayAccessTest.php b/tests/ArrayAccessTest.php index 970e88849..3fa528668 100644 --- a/tests/ArrayAccessTest.php +++ b/tests/ArrayAccessTest.php @@ -672,17 +672,6 @@ class ArrayAccessTest extends TestCase }', 'error_message' => 'PossiblyInvalidArrayOffset', ], - 'possiblyInvalidMixedUnionArrayOffset' => [ - ' 'PossiblyInvalidArrayOffset', - 'error_level' => ['MixedArrayAssignment'], - ], 'arrayAccessOnIterable' => [ ' [ + 'array', + [ + 'array{a: int}', + 'array', + ], + ], 'traversableAorB' => [ 'Traversable', [