Skip to content

Commit

Permalink
Fix #3353 - allow extending nested when nested as type is mixed
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed May 12, 2020
1 parent 3e58163 commit 8c236f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Psalm/Internal/Analyzer/ClassAnalyzer.php
Expand Up @@ -2038,7 +2038,7 @@ private function checkTemplateParams(
if (IssueBuffer::accepts(
new InvalidTemplateParam(
'Extended template param ' . $template_name
. ' expects type ' . $template_type[0]->getId()
. ' expects type ' . $template_type_copy->getId()
. ', type ' . $extended_type->getId() . ' given',
$code_location
),
Expand All @@ -2051,6 +2051,10 @@ private function checkTemplateParams(
$declaring_class => [$extended_type]
];
}
} else {
$previous_extended[$template_name] = [
$declaring_class => [$extended_type]
];
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions tests/Template/ClassTemplateExtendsTest.php
Expand Up @@ -4079,6 +4079,19 @@ public function foo(int $i): Container
}
}'
],
'extendIteratorIterator' => [
'<?php
/**
* @template-covariant TKey
* @template-covariant TValue
*
* @template-extends IteratorIterator<TKey, TValue, Traversable<TKey, TValue>>
*/
abstract class MyFilterIterator extends IteratorIterator {
/** @return bool */
public abstract function accept () {}
}'
],
];
}

Expand Down

0 comments on commit 8c236f4

Please sign in to comment.