From 5da29955eeaa9b29b237b52cc1cfb3904afc7cae Mon Sep 17 00:00:00 2001 From: Brown Date: Fri, 3 Jul 2020 12:25:33 -0400 Subject: [PATCH] Use better replacement when analysing potentially-inherited templated type --- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 3 +- tests/Template/ClassTemplateExtendsTest.php | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index 48576a0d7..433419b63 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -1912,7 +1912,8 @@ class ClassAnalyzer extends ClassLikeAnalyzer $codebase, null, null, - null + null, + $original_fq_classlike_name ); } diff --git a/tests/Template/ClassTemplateExtendsTest.php b/tests/Template/ClassTemplateExtendsTest.php index 0fb3aed55..0bf93a777 100644 --- a/tests/Template/ClassTemplateExtendsTest.php +++ b/tests/Template/ClassTemplateExtendsTest.php @@ -1694,6 +1694,9 @@ class ClassTemplateExtendsTest extends TestCase $this->elements = $elements; } + /** + * @psalm-suppress InvalidReturnType + */ public function getIterator() { /** @@ -4181,6 +4184,38 @@ class ClassTemplateExtendsTest extends TestCase } }' ], + 'extendTemplateTypeInParamAsType' => [ + ' + */ + final class Apply implements Operation + { + /** + * @return \Closure(array): void + */ + public function i(): Closure + { + return + /** + * @psalm-param array $collection + */ + static function (array $collection): void{}; + } + } + + /** + * @template TKey as object + */ + interface Operation + { + /** + * @psalm-return \Closure(array): void + */ + public function i(): Closure; + }' + ], ]; }