From 31116c98c9ff79640a7400627d92192a150fde5c Mon Sep 17 00:00:00 2001 From: Simon Bentgsson Date: Fri, 8 Dec 2023 17:14:18 +0100 Subject: [PATCH] Don't list extension methods multiple times. (#836) * Don't list extension methods multiple times. * Removed changes made to ExtensionMethodSet as the issue was fixed in the PythonExtensionBinder instead --- Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs b/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs index 19546f2ea..9096f0574 100644 --- a/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs +++ b/Src/IronPython/Runtime/Binding/PythonExtensionBinder.cs @@ -24,7 +24,7 @@ public PythonExtensionBinder(PythonBinder binder, ExtensionMethodSet extensionMe public override MemberGroup GetMember(MemberRequestKind actionKind, Type type, string name) { var res = base.GetMember(actionKind, type, name); if (res.Count == 0) { - List trackers = new List(); + HashSet trackers = new HashSet(); foreach (var method in _extMethodSet.GetExtensionMethods(name)) { var parameters = method.GetParameters(); @@ -35,11 +35,11 @@ public override MemberGroup GetMember(MemberRequestKind actionKind, Type type, s var paramType = parameters[0].ParameterType; if (IsApplicableExtensionMethod(type, paramType)) { - trackers.Add(MemberTracker.FromMemberInfo(method, paramType)); + (trackers ??= new HashSet()).Add(MemberTracker.FromMemberInfo(method, paramType)); } } - if (trackers.Count > 0) { + if (trackers is not null) { return new MemberGroup(trackers.ToArray()); } }