Skip to content

Commit 81d4572

Browse files
authored
Add regression test for deferral with new redefinition (#20907)
This should already pass on master, but this is an important corner case that is currently not covered. We need to check that function argument widening is re-set when we recheck deferred function (currently this is done with the binder).
1 parent 653610f commit 81d4572

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test-data/unit/check-redefine2.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,3 +1339,19 @@ def process3(items: list[str]) -> None:
13391339
reveal_type(items) # N: Revealed type is "builtins.list[builtins.str]"
13401340
reveal_type(items) # N: Revealed type is "builtins.list[builtins.str]"
13411341
[builtins fixtures/primitives.pyi]
1342+
1343+
[case testNewRedefineWidenedArgumentDeferral]
1344+
# flags: --allow-redefinition-new --local-partial-types
1345+
def foo(x: int) -> None:
1346+
reveal_type(x) # N: Revealed type is "builtins.int"
1347+
if bool():
1348+
x = "no"
1349+
c: C
1350+
c.x
1351+
reveal_type(x) # N: Revealed type is "builtins.int | builtins.str"
1352+
1353+
class C:
1354+
def __init__(self) -> None:
1355+
self.x = defer()
1356+
1357+
def defer() -> int: ...

0 commit comments

Comments
 (0)