Skip to content

Commit

Permalink
Avoid AmbigMember in lookup of interfaces with nullability difference…
Browse files Browse the repository at this point in the history
…s only (#49338)
  • Loading branch information
jcouv authored Dec 18, 2020
1 parent 9c1151a commit 932e0f1
Show file tree
Hide file tree
Showing 4 changed files with 855 additions and 43 deletions.
17 changes: 13 additions & 4 deletions src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,11 +1058,20 @@ private static void LookupMembersInInterfacesWithoutInheritance(
if (interfaces.Length > 0)
{
var tmp = LookupResult.GetInstance();
foreach (TypeSymbol baseInterface in interfaces)
HashSet<NamedTypeSymbol> seenInterfaces = null;
if (interfaces.Length > 1)
{
LookupMembersWithoutInheritance(tmp, baseInterface, name, arity, options, originalBinder, accessThroughType, diagnose, ref useSiteDiagnostics, basesBeingResolved);
MergeHidingLookupResults(current, tmp, basesBeingResolved, ref useSiteDiagnostics);
tmp.Clear();
seenInterfaces = new HashSet<NamedTypeSymbol>(Symbols.SymbolEqualityComparer.IgnoringNullable);
}

foreach (NamedTypeSymbol baseInterface in interfaces)
{
if (seenInterfaces is null || seenInterfaces.Add(baseInterface))
{
LookupMembersWithoutInheritance(tmp, baseInterface, name, arity, options, originalBinder, accessThroughType, diagnose, ref useSiteDiagnostics, basesBeingResolved);
MergeHidingLookupResults(current, tmp, basesBeingResolved, ref useSiteDiagnostics);
tmp.Clear();
}
}
tmp.Free();
}
Expand Down
Loading

0 comments on commit 932e0f1

Please sign in to comment.