1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix union argument types check against templated param

This commit is contained in:
andrew 2023-05-06 16:01:16 +03:00
parent 8d15fa1d79
commit cfd0f062f7
2 changed files with 24 additions and 1 deletions

View File

@ -585,7 +585,7 @@ class TemplateStandinTypeReplacer
if (!empty($classlike_storage->template_extended_params[$base_type->value])) {
$atomic_input_type = new TGenericObject(
$atomic_input_type->value,
$base_type->value,
array_values($classlike_storage->template_extended_params[$base_type->value]),
);

View File

@ -17,6 +17,29 @@ class FunctionCallTest extends TestCase
public function providerValidCodeParse(): iterable
{
return [
'callTemplatedFunctionWithUnionArgument' => [
'code' => '<?php
/** @template T */
interface Message {}
/** @implements Message<int> */
final class FirstMessage implements Message {}
/** @implements Message<int> */
final class SecondMessage implements Message {}
/**
* @template T
* @param Message<T> $msg
*/
function test(Message $msg): void {}
/** @var FirstMessage|SecondMessage $message */;
test($message);',
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.0',
],
'callFunctionWithTemplateClassStringWillNotFail' => [
'code' => '<?php
/** @param class-string<SplFixedArray<string>> $classString */