diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2014-10-30 14:20:02 +0300 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2014-10-30 14:20:02 +0300 |
commit | 170c85174d1548870b95962752d371254436004a (patch) | |
tree | 92a35356c2ccbfb098e80fbe8e009e4898c99088 /ICSharpCode.NRefactory.CSharp | |
parent | a1ef6cbc329d5bd8b58e99419a8e4036cd3868be (diff) |
Fixed extension method lookup.
Extension methods from inaccessible classes were incuded. I needed to
filter them out.
Diffstat (limited to 'ICSharpCode.NRefactory.CSharp')
-rw-r--r-- | ICSharpCode.NRefactory.CSharp/Resolver/CSharpResolver.cs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ICSharpCode.NRefactory.CSharp/Resolver/CSharpResolver.cs b/ICSharpCode.NRefactory.CSharp/Resolver/CSharpResolver.cs index 8578ec68..6852a06a 100644 --- a/ICSharpCode.NRefactory.CSharp/Resolver/CSharpResolver.cs +++ b/ICSharpCode.NRefactory.CSharp/Resolver/CSharpResolver.cs @@ -1833,7 +1833,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver { var lookup = CreateMemberLookup(); List<List<IMethod>> extensionMethodGroups = new List<List<IMethod>>(); - foreach (var inputGroup in GetAllExtensionMethods()) { + foreach (var inputGroup in GetAllExtensionMethods(lookup)) { List<IMethod> outputGroup = new List<IMethod>(); foreach (var method in inputGroup) { if (name != null && method.Name != name) @@ -1927,7 +1927,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver /// Gets all extension methods available in the current using scope. /// This list includes inaccessible methods. /// </summary> - IList<List<IMethod>> GetAllExtensionMethods() + IList<List<IMethod>> GetAllExtensionMethods(MemberLookup lookup) { var currentUsingScope = context.CurrentUsingScope; if (currentUsingScope == null) @@ -1941,14 +1941,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver for (ResolvedUsingScope scope = currentUsingScope; scope != null; scope = scope.Parent) { INamespace ns = scope.Namespace; if (ns != null) { - m = GetExtensionMethods(ns).ToList(); + m = GetExtensionMethods(lookup, ns).ToList(); if (m.Count > 0) extensionMethodGroups.Add(m); } m = scope.Usings .Distinct() - .SelectMany(importedNamespace => GetExtensionMethods(importedNamespace)) + .SelectMany(importedNamespace => GetExtensionMethods(lookup, importedNamespace)) .ToList(); if (m.Count > 0) extensionMethodGroups.Add(m); @@ -1956,12 +1956,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver return LazyInit.GetOrSet(ref currentUsingScope.AllExtensionMethods, extensionMethodGroups); } - IEnumerable<IMethod> GetExtensionMethods(INamespace ns) + IEnumerable<IMethod> GetExtensionMethods(MemberLookup lookup, INamespace ns) { // TODO: maybe make this a property on INamespace? return from c in ns.Types - where c.IsStatic && c.HasExtensionMethods && c.TypeParameters.Count == 0 + where c.IsStatic && c.HasExtensionMethods && c.TypeParameters.Count == 0 && lookup.IsAccessible(c, false) from m in c.Methods where m.IsExtensionMethod select m; |