1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix generic destruction in assertion (#5888)

This commit is contained in:
Andrey Klimenko 2021-06-04 22:33:37 +03:00 committed by GitHub
parent a4871c1ef8
commit 3ad3375777
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 1 deletions

View File

@ -135,7 +135,7 @@ class AndAnalyzer
$changed_var_ids,
$left_referenced_var_ids,
$statements_analyzer,
[],
$statements_analyzer->getTemplateTypeMap() ?: [],
$context->inside_loop,
new CodeLocation($statements_analyzer->getSource(), $stmt->left),
$context->inside_negation

View File

@ -2626,6 +2626,46 @@ class ConditionalTest extends \Psalm\Tests\TestCase
isValid($val) ? $takesValid($val) : $takesInvalid($val);
}'
],
'reconcileMoreThanOneGenericObject' => [
'<?php
final class Invalid {}
/**
* @template T
*/
final class Valid {}
/**
* @template T
*
* @param Invalid|Valid<T> $val
* @psalm-assert-if-true Valid<T> $val
*/
function isValid($val): bool
{
return $val instanceof Valid;
}
/**
* @template T
* @param Valid<T>|Invalid $val1
* @param Valid<T>|Invalid $val2
* @param Valid<T>|Invalid $val3
*/
function inGenericContext($val1, $val2, $val3): void
{
$takesValid =
/** @param Valid<T> $_valid */
function ($_valid): void {};
if (isValid($val1) && isValid($val2) && isValid($val3)) {
$takesValid($val1);
$takesValid($val2);
$takesValid($val3);
}
}'
]
];
}