From 2ceb41b7bd3a1751f7b75cd16770fc587176c331 Mon Sep 17 00:00:00 2001 From: David Fisher Date: Thu, 16 Jun 2016 13:27:22 -0700 Subject: [PATCH 1/2] Check all blocks for overloads in the fast parser --- mypy/fastparse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mypy/fastparse.py b/mypy/fastparse.py index 6bcb12b60ce8..987fec5cd472 100644 --- a/mypy/fastparse.py +++ b/mypy/fastparse.py @@ -176,7 +176,7 @@ def from_comp_operator(self, op: ast35.cmpop) -> str: def as_block(self, stmts: List[ast35.stmt], lineno: int) -> Block: b = None if stmts: - b = Block(self.visit_list(stmts)) + b = Block(self.fix_function_overloads(self.visit_list(stmts))) b.set_line(lineno) return b @@ -353,7 +353,7 @@ def visit_ClassDef(self, n: ast35.ClassDef) -> Node: metaclass = self.stringify_name(metaclass_arg.value) cdef = ClassDef(n.name, - Block(self.fix_function_overloads(self.visit_list(n.body))), + self.as_block(n.body, n.lineno), None, self.visit_list(n.bases), metaclass=metaclass) From c574bf180e0f6f989499f008ed51ef746387237e Mon Sep 17 00:00:00 2001 From: David Fisher Date: Mon, 20 Jun 2016 17:05:50 -0700 Subject: [PATCH 2/2] Add tests --- test-data/unit/check-fastparse.test | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test-data/unit/check-fastparse.test b/test-data/unit/check-fastparse.test index 192fa5ee482e..ce7f716a4a2f 100644 --- a/test-data/unit/check-fastparse.test +++ b/test-data/unit/check-fastparse.test @@ -23,3 +23,22 @@ def f(): # E: syntax error in type comment def f(): # E: invalid type comment # type: (a + b) -> None pass + +[case testFastParseProperty] +# flags: fast-parser +class C: + @property + def x(self) -> str: pass + @x.setter + def x(self, value: str) -> None: pass +[builtins fixtures/property.py] + +[case testFastParseConditionalProperty] +# flags: fast-parser +class C: + if 1: + @property + def x(self) -> str: pass + @x.setter + def x(self, value: str) -> None: pass +[builtins fixtures/property.py]