Skip to content

Commit

Permalink
Basic inference for anonymous functions 1
Browse files Browse the repository at this point in the history
  • Loading branch information
klimick committed Dec 4, 2023
1 parent 414147e commit 9097f15
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ private static function getProvisionalTemplateResultForFunctionLike(
array $function_params,
?FunctionLikeParameter $last_param
): ?TemplateResult {
$template_types = CallAnalyzer::getTemplateTypesForCall(
$templates_for_call = CallAnalyzer::getTemplateTypesForCall(
$codebase,
$class_storage,
$self_fq_class_name,
Expand All @@ -1334,16 +1334,14 @@ private static function getProvisionalTemplateResultForFunctionLike(
$class_generic_params,
);

if (!$template_types) {
if ($templates_for_call === []) {
return null;
}

if (!$template_result) {
return new TemplateResult($template_types, []);
if ($template_result === null) {
return new TemplateResult($templates_for_call, []);
}

$template_result->template_types = array_merge($template_result->template_types, $template_types);

$template_result->contextual_template_result = $context->contextual_type_resolver !== null
? $context->contextual_type_resolver->getTemplateResult()
: null;
Expand Down

0 comments on commit 9097f15

Please sign in to comment.