mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Only extend covariant flag to vars without template param
This commit is contained in:
parent
4f9cf54005
commit
4bf632bc23
@ -488,7 +488,10 @@ class Populator
|
||||
$storage->template_type_extends[$parent_storage->name][$mapped_name] = $type;
|
||||
}
|
||||
|
||||
if (is_int($i) && ($parent_storage->template_covariants[$i] ?? false)) {
|
||||
if (is_int($i)
|
||||
&& ($parent_storage->template_covariants[$i] ?? false)
|
||||
&& !$type->hasTemplate()
|
||||
) {
|
||||
$storage->template_covariants[$i] = true;
|
||||
}
|
||||
}
|
||||
@ -623,7 +626,10 @@ class Populator
|
||||
$storage->template_type_extends[$parent_interface_storage->name][$mapped_name] = $type;
|
||||
}
|
||||
|
||||
if (is_int($i) && ($parent_interface_storage->template_covariants[$i] ?? false)) {
|
||||
if (is_int($i)
|
||||
&& ($parent_interface_storage->template_covariants[$i] ?? false)
|
||||
&& !$type->hasTemplate()
|
||||
) {
|
||||
$storage->template_covariants[$i] = true;
|
||||
}
|
||||
}
|
||||
@ -719,7 +725,10 @@ class Populator
|
||||
$storage->template_type_extends[$implemented_interface_storage->name][$mapped_name] = $type;
|
||||
}
|
||||
|
||||
if (is_int($i) && ($implemented_interface_storage->template_covariants[$i] ?? false)) {
|
||||
if (is_int($i)
|
||||
&& ($implemented_interface_storage->template_covariants[$i] ?? false)
|
||||
&& !$type->hasTemplate()
|
||||
) {
|
||||
$storage->template_covariants[$i] = true;
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,10 @@ class UnionTemplateHandler
|
||||
}
|
||||
|
||||
if ($replace) {
|
||||
if (array_values($original_atomic_types) === $atomic_types) {
|
||||
return $union_type;
|
||||
}
|
||||
|
||||
if (!$atomic_types) {
|
||||
throw new \UnexpectedValueException('Cannot remove all keys');
|
||||
}
|
||||
|
@ -1637,7 +1637,6 @@ class ClassTemplateExtendsTest extends TestCase
|
||||
|
||||
/**
|
||||
* @psalm-suppress MissingTemplateParam
|
||||
* @psalm-suppress InvalidTemplateParam
|
||||
*
|
||||
* @psalm-param array<T> $elements
|
||||
* @psalm-return ArrayCollection<T>
|
||||
|
Loading…
Reference in New Issue
Block a user