Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion mypyc/irbuild/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,13 @@ def load_type_map(mapper: Mapper, modules: list[MypyFile], deser_ctx: DeserMaps)
"""Populate a Mapper with deserialized IR from a list of modules."""
for module in modules:
for node in module.names.values():
if isinstance(node.node, TypeInfo) and is_from_module(node.node, module):
if (
isinstance(node.node, TypeInfo)
and is_from_module(node.node, module)
and not node.node.is_newtype
and not node.node.is_named_tuple
and node.node.typeddict_type is None
):
ir = deser_ctx.classes[node.node.fullname]
mapper.type_to_ir[node.node] = ir
mapper.symbol_fullnames.add(node.node.fullname)
Expand Down
48 changes: 48 additions & 0 deletions mypyc/test-data/run-multimodule.test
Original file line number Diff line number Diff line change
Expand Up @@ -902,3 +902,51 @@ import native
[out2]
0
None

[case testIncrementalCompilationWithNonClassTypeDef]
import other_a
[file other_a.py]
from other_b import MyInt
[file other_a.py.2]
from other_b import MyInt, NT, TD
i = MyInt(42)

def f(x: MyInt) -> int:
return x + 1

def g(x: int) -> MyInt:
return MyInt(x + 2)

print(i)
print(f(i))
print(g(13))

def make_nt(x: int) -> NT:
return NT(x=MyInt(x))

print(make_nt(4))

def make_td(x: int) -> TD:
return {"x": MyInt(x)}

print(make_td(5))

[file other_b.py]
from typing import NewType, NamedTuple, TypedDict
from enum import Enum

MyInt = NewType("MyInt", int)
NT = NamedTuple("NT", [("x", MyInt)])
TD = TypedDict("TD", {"x": MyInt})

[file driver.py]
import native

[typing fixtures/typing-full.pyi]
[out]
[out2]
42
43
15
NT(x=4)
{'x': 5}
Loading