From 86b894eca53d9159da410ccb9db2bc745e3720bf Mon Sep 17 00:00:00 2001 From: Brown Date: Sun, 31 May 2020 00:55:45 -0400 Subject: [PATCH] Treat iterables as traversable when comparing to named object --- src/Psalm/Internal/Analyzer/TypeAnalyzer.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Psalm/Internal/Analyzer/TypeAnalyzer.php b/src/Psalm/Internal/Analyzer/TypeAnalyzer.php index 248e997b5..3c4670fbf 100644 --- a/src/Psalm/Internal/Analyzer/TypeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/TypeAnalyzer.php @@ -514,6 +514,16 @@ class TypeAnalyzer $allow_interface_equality, ?TypeComparisonResult $atomic_comparison_result ) { + if ($container_type_part instanceof TIterable + && !$container_type_part->extra_types + && !$input_type_part instanceof TIterable + ) { + $container_type_part = new TGenericObject( + 'Traversable', + $container_type_part->type_params + ); + } + $intersection_input_types = $input_type_part->extra_types ?: []; $intersection_input_types[$input_type_part->getKey(false)] = $input_type_part;