diff --git a/mypy/semanal.py b/mypy/semanal.py index f4df0f7748ab..ef0857f6bdce 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -3022,6 +3022,7 @@ def process_type_annotation(self, s: AssignmentStmt) -> None: analyzed = self.anal_type(s.type, allow_tuple_literal=allow_tuple_literal) # Don't store not ready types (including placeholders). if analyzed is None or has_placeholder(analyzed): + self.defer(s) return s.type = analyzed if ( diff --git a/test-data/unit/check-dataclasses.test b/test-data/unit/check-dataclasses.test index e4f2bfb44160..3f9fbb46a60b 100644 --- a/test-data/unit/check-dataclasses.test +++ b/test-data/unit/check-dataclasses.test @@ -1913,3 +1913,23 @@ class MyDataclass: takes_cp(MyDataclass) [builtins fixtures/dataclasses.pyi] + +[case testDataclassTypeAnnotationAliasUpdated] +# flags: --enable-recursive-aliases +import a +[file a.py] +from dataclasses import dataclass +from b import B + +@dataclass +class D: + x: B + +reveal_type(D) # N: Revealed type is "def (x: builtins.list[b.C]) -> a.D" +[file b.py] +from typing import List +import a +B = List[C] +class C(CC): ... +class CC: ... +[builtins fixtures/dataclasses.pyi]