From 49e386416c28e7777866b92374d43db214f84df0 Mon Sep 17 00:00:00 2001 From: rwbarton Date: Tue, 19 Apr 2016 10:36:46 -0700 Subject: [PATCH] Count overloaded functions signatures correctly in error message (#1407) --- mypy/checker.py | 2 +- mypy/test/data/check-overloading.test | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mypy/checker.py b/mypy/checker.py index bcbffd9add11..8f46c3890a67 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -498,7 +498,7 @@ def check_overlapping_overloads(self, defn: OverloadedFuncDef) -> None: sig1 = self.function_type(item.func) sig2 = self.function_type(item2.func) if is_unsafe_overlapping_signatures(sig1, sig2): - self.msg.overloaded_signatures_overlap(i + 1, j + 2, + self.msg.overloaded_signatures_overlap(i + 1, i + j + 2, item.func) def is_generator_return_type(self, typ: Type) -> bool: diff --git a/mypy/test/data/check-overloading.test b/mypy/test/data/check-overloading.test index f4b480f8d7c1..ba3a2edc4b78 100644 --- a/mypy/test/data/check-overloading.test +++ b/mypy/test/data/check-overloading.test @@ -630,3 +630,14 @@ def f(x: Sequence[int]) -> int: pass # These are considered overlapping despite the bound on T due to runtime type erasure. [out] main:4: error: Overloaded function signatures 1 and 2 overlap with incompatible return types + +[case testOverlappingOverloadCounting] +from typing import overload +class A: pass +class B(A): pass +@overload +def f(x: int) -> None: pass +@overload +def f(x: B) -> str: pass # E: Overloaded function signatures 2 and 3 overlap with incompatible return types +@overload +def f(x: A) -> int: pass