diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php index c33d4cfe2..01348384c 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php @@ -91,15 +91,13 @@ class ClassTemplateParamCollector $e = $static_class_storage->template_extended_params; if ($lhs_type_part instanceof TGenericObject) { - if ($class_storage === $static_class_storage && $static_class_storage->template_types) { + if ($class_storage === $static_class_storage && $class_storage->template_types) { $i = 0; - foreach ($static_class_storage->template_types as $type_name => $_) { + foreach ($class_storage->template_types as $type_name => $_) { if (isset($lhs_type_part->type_params[$i])) { - if (!$self_call || $static_fq_class_name !== $static_class_storage->name) { - $class_template_params[$type_name][$static_class_storage->name] - = $lhs_type_part->type_params[$i]; - } + $class_template_params[$type_name][$class_storage->name] + = $lhs_type_part->type_params[$i]; } $i++; diff --git a/tests/Template/ClassTemplateTest.php b/tests/Template/ClassTemplateTest.php index 96b97e12f..4e2c00d73 100644 --- a/tests/Template/ClassTemplateTest.php +++ b/tests/Template/ClassTemplateTest.php @@ -3255,6 +3255,29 @@ class ClassTemplateTest extends TestCase return new Foo(Foo::A); }' ], + 'callTemplatedMethodOnSameClass' => [ + 'foo($e); + } + }' + ], ]; }