diff --git a/src/Type/IterableType.php b/src/Type/IterableType.php index 9c0e26050a..ce7a01c916 100644 --- a/src/Type/IterableType.php +++ b/src/Type/IterableType.php @@ -358,9 +358,11 @@ public function inferTemplateTypes(Type $receivedType): TemplateTypeMap public function getReferencedTemplateTypes(TemplateTypeVariance $positionVariance): array { + $variance = $positionVariance->compose(TemplateTypeVariance::createCovariant()); + return array_merge( - $this->getIterableKeyType()->getReferencedTemplateTypes($positionVariance), - $this->getIterableValueType()->getReferencedTemplateTypes($positionVariance), + $this->getIterableKeyType()->getReferencedTemplateTypes($variance), + $this->getIterableValueType()->getReferencedTemplateTypes($variance), ); }