Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Tawfik <OmarTawfik@users.noreply.github.com>2017-08-22 21:42:06 +0300
committerGitHub <noreply@github.com>2017-08-22 21:42:06 +0300
commit158b600e764c7dcc1e7117609c4d9709d62f1755 (patch)
treec0e79464942954fb441f2c56d7f208282df75f26 /src/Microsoft.CSharp
parent61bd711c3e977ee789831855b96618a7200b5b8f (diff)
Fix duplicate types exception on WinRT interfaces (#23402)
* Fix duplicate types exception on WinRT interfaces * Maintaining order
Diffstat (limited to 'src/Microsoft.CSharp')
-rw-r--r--src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinder.cs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinder.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinder.cs
index 8580cbadb3..8a65a132db 100644
--- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinder.cs
+++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinder.cs
@@ -635,15 +635,18 @@ namespace Microsoft.CSharp.RuntimeBinder
callingType = (AggregateType)callingObjectType;
}
- List<CType> callingTypes = new List<CType>();
-
// The C# binder expects that only the base virtual method is inserted
// into the list of candidates, and only the type containing the base
// virtual method is inserted into the list of types. However, since we
// don't want to do all the logic, we're just going to insert every type
// that has a member of the given name, and allow the C# binder to filter
// out all overrides.
- //
+
+ // CONSIDER: using a hashset to filter out duplicate interface types.
+ // Adopt a smarter algorithm to filter types before creating the exception.
+ HashSet<CType> distinctCallingTypes = new HashSet<CType>();
+ List<CType> callingTypes = new List<CType>();
+
// Find that set of types now.
symbmask_t mask = symbmask_t.MASK_MethodSymbol;
switch (kind)
@@ -664,7 +667,7 @@ namespace Microsoft.CSharp.RuntimeBinder
bool bIsConstructor = name == NameManager.GetPredefinedName(PredefinedName.PN_CTOR);
foreach(AggregateType t in callingType.TypeHierarchy)
{
- if (_symbolTable.AggregateContainsMethod(t.GetOwningAggregate(), Name, mask))
+ if (_symbolTable.AggregateContainsMethod(t.GetOwningAggregate(), Name, mask) && distinctCallingTypes.Add(t))
{
callingTypes.Add(t);
}
@@ -684,7 +687,7 @@ namespace Microsoft.CSharp.RuntimeBinder
foreach (AggregateType t in callingType.GetWinRTCollectionIfacesAll(SymbolLoader).Items)
{
- if (_symbolTable.AggregateContainsMethod(t.GetOwningAggregate(), Name, mask))
+ if (_symbolTable.AggregateContainsMethod(t.GetOwningAggregate(), Name, mask) && distinctCallingTypes.Add(t))
{
callingTypes.Add(t);
}