From dac8c986134da54da5f630522b0dd9135c096693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Tomulik?= Date: Mon, 22 Nov 2021 23:32:05 +0100 Subject: [PATCH] attempt to fix #6973 --- .../Internal/Analyzer/MethodComparator.php | 4 +-- tests/ReturnTypeTest.php | 30 ++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/MethodComparator.php b/src/Psalm/Internal/Analyzer/MethodComparator.php index 15bc9f7cced..ff740bef303 100644 --- a/src/Psalm/Internal/Analyzer/MethodComparator.php +++ b/src/Psalm/Internal/Analyzer/MethodComparator.php @@ -980,9 +980,7 @@ private static function compareMethodDocblockReturnTypes( $implementer_called_class_name ); - if (isset( - $implementer_called_class_storage->template_extended_params[$implementer_classlike_storage->name] - )) { + if ($implementer_called_class_storage->template_extended_params) { self::transformTemplates( $implementer_called_class_storage->template_extended_params, $implementer_classlike_storage->name, diff --git a/tests/ReturnTypeTest.php b/tests/ReturnTypeTest.php index 4aa65c197e7..9cb96d4bbd6 100644 --- a/tests/ReturnTypeTest.php +++ b/tests/ReturnTypeTest.php @@ -1032,7 +1032,35 @@ public function __construct() { $this->value = 123; } }' - ] + ], + 'returnTypeOfAbstractMethodFromTemplatedTraitAndImplementationFromNonTemplatedTrait' => [ + 'value; + } + } + + /** @psalm-template T */ + trait GuideTrait { + /** @psalm-return T */ + abstract public function getValue(); + } + + class Test { + use ImplementerTrait; + + /** @template-use GuideTrait */ + use GuideTrait; + + public function __construct() { + $this->value = 123; + } + }' + ], ]; }