diff --git a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php index 9e484ca32..4f89f5de1 100644 --- a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php @@ -680,16 +680,21 @@ final class StatementsAnalyzer extends SourceAnalyzer } else { try { $checked_type = $context->vars_in_scope[$checked_var_id]; + + $path = $statements_analyzer->getRootFilePath(); + $file_storage = $codebase->file_storage_provider->get($path); + $check_tokens = TypeTokenizer::getFullyQualifiedTokens( $check_type_string, $statements_analyzer->getAliases(), $statements_analyzer->getTemplateTypeMap(), + $file_storage->type_aliases, ); $check_type = TypeParser::parseTokens( $check_tokens, null, $statements_analyzer->getTemplateTypeMap() ?? [], - [], + $file_storage->type_aliases, true, ); /** @psalm-suppress InaccessibleProperty We just created this type */ diff --git a/tests/CheckTypeTest.php b/tests/CheckTypeTest.php index 457c496db..64b65e3fc 100644 --- a/tests/CheckTypeTest.php +++ b/tests/CheckTypeTest.php @@ -38,6 +38,15 @@ class CheckTypeTest extends TestCase $_a = new stdClass(); /** @psalm-check-type-exact $_a = \stdClass */', ]; + yield 'allowType' => [ + 'code' => '