mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Expand template param before comparison
This commit is contained in:
parent
be847472a2
commit
109920be88
@ -246,6 +246,15 @@ class TypeChecker extends NodeVisitor
|
||||
|
||||
if (isset(\array_values($expected_type_params)[$i])) {
|
||||
$expected_type_param = \reset(\array_values($expected_type_params)[$i])[0];
|
||||
|
||||
$expected_type_param = \Psalm\Internal\Type\TypeExpander::expandUnion(
|
||||
$codebase,
|
||||
$expected_type_param,
|
||||
$this->source->getFQCLN(),
|
||||
$this->source->getFQCLN(),
|
||||
$this->source->getParentFQCLN()
|
||||
);
|
||||
|
||||
$template_name = \array_keys($expected_type_params)[$i];
|
||||
|
||||
$type_param = \Psalm\Internal\Type\TypeExpander::expandUnion(
|
||||
|
@ -2741,6 +2741,22 @@ class ClassTemplateTest extends TestCase
|
||||
if (is_int($ret)) {}
|
||||
}'
|
||||
],
|
||||
'templateWithLateResolvedType' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template A of Enum::TYPE_*
|
||||
*/
|
||||
class Foo {}
|
||||
|
||||
class Enum
|
||||
{
|
||||
const TYPE_ONE = 1;
|
||||
const TYPE_TWO = 2;
|
||||
}
|
||||
|
||||
/** @var Foo<Enum::TYPE_ONE> $foo */
|
||||
$foo = new Foo();'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user