Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit ffd9847

Browse files
author
Mikhail Arkhipov
authored
Merge pull request microsoft#277 from MikhailArkhipov/11
Fix overload merge with Typeshed
2 parents 6c92792 + f23bed1 commit ffd9847

8 files changed

+1147
-974
lines changed

src/Analysis/Engine/Impl/OverloadResult.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ public override string ToString() {
136136
var doc = string.IsNullOrEmpty(Documentation) ? "" : "'''{0}'''".FormatInvariant(Documentation);
137137
return "{0}({1}) -> {2}{3}".FormatInvariant(Name, parameters, returnType, doc);
138138
}
139+
140+
public override bool Equals(object obj) {
141+
if(obj is OverloadResult other) {
142+
return OverloadResultComparer.Instance.Equals(this, other);
143+
}
144+
return base.Equals(obj);
145+
}
146+
public override int GetHashCode() => OverloadResultComparer.Instance.GetHashCode(this);
139147
}
140148

141149
class AccumulatedOverloadResult {

src/Analysis/Engine/Impl/Values/BuiltinFunctionInfo.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Collections.Generic;
1919
using System.Collections.ObjectModel;
2020
using System.Linq;
21+
using Microsoft.PythonTools.Analysis.Infrastructure;
2122
using Microsoft.PythonTools.Interpreter;
2223
using Microsoft.PythonTools.Parsing.Ast;
2324

@@ -172,5 +173,14 @@ internal override AnalysisValue UnionMergeTypes(AnalysisValue ns, int strength)
172173
}
173174
return base.UnionMergeTypes(ns, strength);
174175
}
176+
177+
public override bool Equals(object obj) {
178+
if(obj is BuiltinFunctionInfo other && !other.Overloads.SetEquals(Overloads)) {
179+
return false;
180+
}
181+
return base.Equals(obj);
182+
}
183+
184+
public override int GetHashCode() => base.GetHashCode() ^ Overloads.GetHashCode();
175185
}
176186
}

src/Analysis/Engine/Impl/Values/ClassInfo.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -831,10 +831,6 @@ public static IAnalysisSet GetMemberFromMroNoReferences(IEnumerable<IAnalysisSet
831831
result = result.Union(ns.GetMember(node, unit, name));
832832
}
833833
}
834-
835-
if (result != null && result.Count > 0) {
836-
break;
837-
}
838834
}
839835
return result;
840836
}

src/Analysis/Engine/Test/AstAnalysisTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
using System.Threading;
2626
using System.Threading.Tasks;
2727
using FluentAssertions;
28-
using Microsoft.Python.LanguageServer;
2928
using Microsoft.Python.LanguageServer.Implementation;
3029
using Microsoft.Python.Tests.Utilities;
3130
using Microsoft.Python.Tests.Utilities.FluentAssertions;

0 commit comments

Comments
 (0)