diff --git a/src/Psalm/Internal/Codebase/Analyzer.php b/src/Psalm/Internal/Codebase/Analyzer.php
index <HASH>..<HASH> 100644
--- a/src/Psalm/Internal/Codebase/Analyzer.php
+++ b/src/Psalm/Internal/Codebase/Analyzer.php
@@ -411,7 +411,9 @@ class Analyzer
 
                     $file_reference_provider = $codebase->file_reference_provider;
 
-                    $codebase->taint = new \Psalm\Internal\Codebase\Taint();
+                    if ($codebase->taint) {
+                        $codebase->taint = new \Psalm\Internal\Codebase\Taint();
+                    }
 
                     $file_reference_provider->setNonMethodReferencesToClasses([]);
                     $file_reference_provider->setCallingMethodReferencesToClassMembers([]);
Only recreate taints if non-null