1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Fix #3327 - convert void to null when comparing conditional type with nullable

This commit is contained in:
Brown 2020-05-19 19:48:11 -04:00
parent 742282bbb5
commit a4141a7581
2 changed files with 15 additions and 6 deletions

View File

@ -609,16 +609,21 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
true
);
if ($closure_return_types) {
$closure_return_type = \Psalm\Internal\Type\TypeCombination::combineTypes(
$closure_return_type = $closure_return_types
? \Psalm\Internal\Type\TypeCombination::combineTypes(
$closure_return_types,
$codebase
);
)
: null;
$closure_yield_type = $closure_yield_types
? \Psalm\Internal\Type\TypeCombination::combineTypes($closure_yield_types)
: null;
$closure_yield_type = $closure_yield_types
? \Psalm\Internal\Type\TypeCombination::combineTypes(
$closure_yield_types,
$codebase
)
: null;
if ($closure_return_type || $closure_yield_type) {
if ($closure_yield_type) {
$closure_return_type = $closure_yield_type;
}

View File

@ -1378,6 +1378,10 @@ class Union implements TypeNode
$codebase
);
if ($atomic_type->as_type->isNullable() && $template_type->isVoid()) {
$template_type = Type::getNull();
}
if (TypeAnalyzer::isContainedBy(
$codebase,
$template_type,