Skip to content

Commit

Permalink
Reconcile IsNotType between EnumCase and NamedObject
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Feb 13, 2022
1 parent 59d3d2a commit 586c70c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Psalm/Internal/Type/NegatedAssertionReconciler.php
Expand Up @@ -16,7 +16,6 @@
use Psalm\Type\Atomic;
use Psalm\Type\Atomic\TArray;
use Psalm\Type\Atomic\TClassString;
use Psalm\Type\Atomic\TEmptyMixed;
use Psalm\Type\Atomic\TEnumCase;
use Psalm\Type\Atomic\TFalse;
use Psalm\Type\Atomic\TFloat;
Expand Down Expand Up @@ -162,6 +161,14 @@ public static function reconcile(
return $existing_var_type;
}

if (!$is_equality && $assertion_type instanceof TNamedObject) {
foreach ($existing_var_type->getAtomicTypes() as $key => $type) {
if ($type instanceof TEnumCase && $type->value === $assertion_type->value) {
$existing_var_type->removeType($key);
}
}
}

$codebase = $statements_analyzer->getCodebase();

if ($assertion_type instanceof TNamedObject
Expand Down Expand Up @@ -291,7 +298,7 @@ public static function reconcile(

$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;

return new Union([new TEmptyMixed]);
return Type::getNever();
}

return $existing_var_type;
Expand Down

0 comments on commit 586c70c

Please sign in to comment.