mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Fixed a bug that led to a false positive "reportOverlappingOverload" error when the return type of two overlapping overloads both used a generic return type.
This commit is contained in:
parent
73a7bca0ba
commit
f749e2b0a7
@ -1787,7 +1787,7 @@ export class Checker extends ParseTreeWalker {
|
||||
prevReturnType,
|
||||
/* diag */ undefined,
|
||||
new TypeVarContext(),
|
||||
CanAssignFlags.SkipSolveTypeVars
|
||||
CanAssignFlags.SkipSolveTypeVars | CanAssignFlags.IgnoreTypeVarScope
|
||||
)
|
||||
) {
|
||||
const altNode = this._findNodeForOverload(node, prevOverload);
|
||||
|
@ -7,6 +7,7 @@ from typing import (
|
||||
List,
|
||||
Literal,
|
||||
Optional,
|
||||
Sequence,
|
||||
Tuple,
|
||||
Type,
|
||||
TypeVar,
|
||||
@ -279,7 +280,6 @@ class ClassA(Generic[_T1]):
|
||||
|
||||
|
||||
class ClassB:
|
||||
# This should generate an error because the overload is overlapping.
|
||||
@overload
|
||||
def __call__(self, f: _T1) -> _T1:
|
||||
...
|
||||
@ -317,3 +317,17 @@ class ClassD:
|
||||
|
||||
def method1(self, x: Any) -> Any:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def func18(s: Sequence[_T1], extra: Literal[False]) -> list[_T1]: ...
|
||||
|
||||
@overload
|
||||
def func18(s: Sequence[_T1], extra: Literal[True]) -> list[_T1] | tuple[_T1]: ...
|
||||
|
||||
@overload
|
||||
def func18(s: Sequence[_T1], extra: bool) -> list[_T1] | tuple[_T1]: ...
|
||||
|
||||
def func18(s: Sequence[_T1], extra: bool) -> list[_T1] | tuple[_T1]:
|
||||
...
|
||||
|
||||
|
@ -262,7 +262,7 @@ test('Overload5', () => {
|
||||
|
||||
configOptions.diagnosticRuleSet.reportOverlappingOverload = 'error';
|
||||
analysisResults = TestUtils.typeAnalyzeSampleFiles(['overload5.py'], configOptions);
|
||||
TestUtils.validateResults(analysisResults, 12);
|
||||
TestUtils.validateResults(analysisResults, 11);
|
||||
});
|
||||
|
||||
test('Overload6', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user