Skip to content

Commit

Permalink
Fix #5229 - new SomeTemplatedClass should expand out params even if n…
Browse files Browse the repository at this point in the history
…one passed
  • Loading branch information
muglug committed Feb 26, 2021
1 parent d484199 commit 474ebf9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,25 @@ function ($bound) {
)) {
// 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) {
Expand Down
12 changes: 12 additions & 0 deletions tests/Template/ClassTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3343,6 +3343,18 @@ public function getValue() {
}
}'
],
'newWithoutInferredTemplate' => [
'<?php
/**
* @psalm-template T2 of object
*/
final class Foo {}
$f = new Foo();',
[
'$f' => 'Foo<object>'
]
],
];
}

Expand Down

0 comments on commit 474ebf9

Please sign in to comment.