mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #5229 - new SomeTemplatedClass should expand out params even if none passed
This commit is contained in:
parent
d4841993b2
commit
474ebf912e
@ -472,6 +472,25 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna
|
||||
)) {
|
||||
// fall through
|
||||
}
|
||||
} elseif ($storage->template_types) {
|
||||
$result_atomic_type = new Type\Atomic\TGenericObject(
|
||||
$fq_class_name,
|
||||
array_values(
|
||||
array_map(
|
||||
function($map) {
|
||||
return clone reset($map);
|
||||
},
|
||||
$storage->template_types
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$result_atomic_type->was_static = $from_static;
|
||||
|
||||
$statements_analyzer->node_data->setType(
|
||||
$stmt,
|
||||
new Type\Union([$result_atomic_type])
|
||||
);
|
||||
}
|
||||
|
||||
if ($storage->external_mutation_free) {
|
||||
|
@ -3343,6 +3343,18 @@ class ClassTemplateTest extends TestCase
|
||||
}
|
||||
}'
|
||||
],
|
||||
'newWithoutInferredTemplate' => [
|
||||
'<?php
|
||||
/**
|
||||
* @psalm-template T2 of object
|
||||
*/
|
||||
final class Foo {}
|
||||
|
||||
$f = new Foo();',
|
||||
[
|
||||
'$f' => 'Foo<object>'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user