mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix #2569 - improve template return type checks
This commit is contained in:
parent
adfb488986
commit
146dd461ef
@ -1877,10 +1877,6 @@ class TypeAnalyzer
|
||||
$input_type_part->value,
|
||||
$generic_params
|
||||
);
|
||||
|
||||
if ($container_type_part instanceof TGenericObject) {
|
||||
$container_type_part->remapped_params = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1913,15 +1909,15 @@ class TypeAnalyzer
|
||||
|
||||
if ($input_type_part->value !== $container_type_part->value
|
||||
&& $input_class_storage
|
||||
&& (!$container_type_part instanceof TGenericObject
|
||||
|| !$container_type_part->remapped_params)
|
||||
) {
|
||||
$input_template_types = $input_class_storage->template_types;
|
||||
$i = 0;
|
||||
|
||||
$replacement_templates = [];
|
||||
|
||||
if ($input_template_types) {
|
||||
if ($input_template_types
|
||||
&& (!$input_type_part instanceof TGenericObject || !$input_type_part->remapped_params)
|
||||
) {
|
||||
foreach ($input_template_types as $template_name => $_) {
|
||||
if (!isset($input_type_params[$i])) {
|
||||
break;
|
||||
|
@ -2760,6 +2760,31 @@ class ClassTemplateExtendsTest extends TestCase
|
||||
{
|
||||
}'
|
||||
],
|
||||
'extendWithExtraParam' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template Tk of array-key
|
||||
* @template Tv
|
||||
*/
|
||||
interface ICollection {
|
||||
/**
|
||||
* @psalm-return ICollection<Tk, Tv>
|
||||
*/
|
||||
public function slice(int $start, int $length): ICollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @extends ICollection<int, T>
|
||||
*/
|
||||
interface IVector extends ICollection {
|
||||
/**
|
||||
* @psalm-return IVector<T>
|
||||
*/
|
||||
public function slice(int $start, int $length): ICollection;
|
||||
}'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user