Skip to content
Permalink
Browse files

Fix #2556 - don’t remap params if they’ve already been remapped once

  • Loading branch information
muglug committed Jan 6, 2020
1 parent 4888ae6 commit 137650fe6f7fd3f765462d1742f7cf6633812ab2
@@ -1885,7 +1885,10 @@ private static function isMatchingTypeContainedBy(
$container_class_storage = null;
}

if ($input_type_part->value !== $container_type_part->value && $input_class_storage) {
if ($input_type_part->value !== $container_type_part->value
&& $input_class_storage
&& !$container_type_part->remapped_params
) {
$input_template_types = $input_class_storage->template_types;
$i = 0;

@@ -1946,6 +1949,7 @@ private static function isMatchingTypeContainedBy(
}

if ($new_input_param) {
$new_input_param = clone $new_input_param;
$new_input_param->replaceTemplateTypesWithArgTypes(
$replacement_templates
);
@@ -217,6 +217,10 @@ public function replaceTemplateTypesWithArgTypes(array $template_types, ?Codebas
$type_param->replaceTemplateTypesWithArgTypes($template_types, $codebase);
}

if ($this instanceof TGenericObject) {
$this->remapped_params = true;
}

if ($this instanceof TGenericObject || $this instanceof TIterable) {
$this->replaceIntersectionTemplateTypesWithArgTypes($template_types, $codebase);
}
@@ -10,6 +10,9 @@ class TGenericObject extends TNamedObject
{
use GenericTrait;

/** @var bool if the parameters have been remapped to another class */
public $remapped_params = false;

/**
* @param string $value the name of the object
* @param non-empty-list<\Psalm\Type\Union> $type_params
@@ -2717,6 +2717,29 @@ protected function doNormalize($v): string
}
}'
],
'extendWithArrayTemplate' => [
'<?php
/**
* @template T1
*/
interface C {
/**
* @psalm-return C<array<int, T1>>
*/
public function zip(): C;
}
/**
* @template T2
* @extends C<T2>
*/
interface AC extends C {
/**
* @psalm-return AC<array<int, T2>>
*/
public function zip(): C;
}',
],
];
}

0 comments on commit 137650f

Please sign in to comment.
You can’t perform that action at this time.