diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php index 106273e86..492dcc842 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php @@ -288,7 +288,6 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna $stmt->inferredType = new Type\Union([new TNamedObject($fq_class_name)]); if (strtolower($fq_class_name) !== 'stdclass' && - $context->check_classes && $codebase->classlikes->classExists($fq_class_name) ) { $storage = $codebase->classlike_storage_provider->get($fq_class_name); diff --git a/tests/UnusedCodeTest.php b/tests/UnusedCodeTest.php index 686cd0950..26a7220ab 100644 --- a/tests/UnusedCodeTest.php +++ b/tests/UnusedCodeTest.php @@ -387,6 +387,16 @@ class UnusedCodeTest extends TestCase (new D)->bar();' ], + 'usedClassAfterExtensionLoaded' => [ + '