From 586c70c8d39a2ebad3b1b17c4b050dc4e5e6f05f Mon Sep 17 00:00:00 2001 From: orklah Date: Sun, 13 Feb 2022 17:43:40 +0100 Subject: [PATCH] Reconcile IsNotType between EnumCase and NamedObject --- .../Internal/Type/NegatedAssertionReconciler.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php index e710a8c3c..74f4d1cf7 100644 --- a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php @@ -16,7 +16,6 @@ use Psalm\Type; 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; @@ -162,6 +161,14 @@ class NegatedAssertionReconciler extends Reconciler 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 @@ -291,7 +298,7 @@ class NegatedAssertionReconciler extends Reconciler $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return new Union([new TEmptyMixed]); + return Type::getNever(); } return $existing_var_type;