mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #2445 - only generalise param when it’s generic
This commit is contained in:
parent
40bdc219ff
commit
b78acf796f
@ -1227,7 +1227,7 @@ class ExpressionAnalyzer
|
||||
$return_type->value = $static_class_type;
|
||||
} else {
|
||||
if ($return_type instanceof Type\Atomic\TGenericObject
|
||||
&& $static_class_type instanceof Type\Atomic\TNamedObject
|
||||
&& $static_class_type instanceof Type\Atomic\TGenericObject
|
||||
) {
|
||||
$return_type->value = $static_class_type->value;
|
||||
} else {
|
||||
|
@ -2420,6 +2420,30 @@ class ClassTemplateExtendsTest extends TestCase
|
||||
}
|
||||
}'
|
||||
],
|
||||
'extendsWithMoreTemplateParams' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
class Container {
|
||||
/** @var T */
|
||||
private $t;
|
||||
|
||||
/** @param T $t */
|
||||
public function __construct($t) {
|
||||
$this->t = $t;
|
||||
}
|
||||
|
||||
/** @return static<T> */
|
||||
public function getAnother() {
|
||||
return clone $this;
|
||||
}
|
||||
}
|
||||
|
||||
class MyContainer extends Container {}
|
||||
|
||||
$a = (new MyContainer("hello"))->getAnother();',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user