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

Commit

Permalink
Merge pull request microsoft#277 from MikhailArkhipov/11
Browse files Browse the repository at this point in the history
Fix overload merge with Typeshed
  • Loading branch information
Mikhail Arkhipov authored Oct 18, 2018
2 parents 6c92792 + f23bed1 commit ffd9847
Show file tree
Hide file tree
Showing 8 changed files with 1,147 additions and 974 deletions.
8 changes: 8 additions & 0 deletions src/Analysis/Engine/Impl/OverloadResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ public override string ToString() {
var doc = string.IsNullOrEmpty(Documentation) ? "" : "'''{0}'''".FormatInvariant(Documentation);
return "{0}({1}) -> {2}{3}".FormatInvariant(Name, parameters, returnType, doc);
}

public override bool Equals(object obj) {
if(obj is OverloadResult other) {
return OverloadResultComparer.Instance.Equals(this, other);
}
return base.Equals(obj);
}
public override int GetHashCode() => OverloadResultComparer.Instance.GetHashCode(this);
}

class AccumulatedOverloadResult {
Expand Down
10 changes: 10 additions & 0 deletions src/Analysis/Engine/Impl/Values/BuiltinFunctionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Microsoft.PythonTools.Analysis.Infrastructure;
using Microsoft.PythonTools.Interpreter;
using Microsoft.PythonTools.Parsing.Ast;

Expand Down Expand Up @@ -172,5 +173,14 @@ internal override AnalysisValue UnionMergeTypes(AnalysisValue ns, int strength)
}
return base.UnionMergeTypes(ns, strength);
}

public override bool Equals(object obj) {
if(obj is BuiltinFunctionInfo other && !other.Overloads.SetEquals(Overloads)) {
return false;
}
return base.Equals(obj);
}

public override int GetHashCode() => base.GetHashCode() ^ Overloads.GetHashCode();
}
}
4 changes: 0 additions & 4 deletions src/Analysis/Engine/Impl/Values/ClassInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,6 @@ public static IAnalysisSet GetMemberFromMroNoReferences(IEnumerable<IAnalysisSet
result = result.Union(ns.GetMember(node, unit, name));
}
}

if (result != null && result.Count > 0) {
break;
}
}
return result;
}
Expand Down
1 change: 0 additions & 1 deletion src/Analysis/Engine/Test/AstAnalysisTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Python.LanguageServer;
using Microsoft.Python.LanguageServer.Implementation;
using Microsoft.Python.Tests.Utilities;
using Microsoft.Python.Tests.Utilities.FluentAssertions;
Expand Down
Loading

0 comments on commit ffd9847

Please sign in to comment.