// // Does extension methods look up to find a method which matches name and extensionType. // Search starts from this namespace and continues hierarchically up to top level. // public IList <MethodSpec> LookupExtensionMethod(TypeSpec extensionType, string name, int arity, ref NamespaceContainer scope) { List <MethodSpec> candidates = null; foreach (Namespace n in GetUsingTable()) { var a = n.LookupExtensionMethod(this, extensionType, name, arity); if (a == null) { continue; } if (candidates == null) { candidates = a; } else { candidates.AddRange(a); } } scope = parent; if (candidates != null) { return(candidates); } if (parent == null) { return(null); } // // Inspect parent namespaces in namespace expression // Namespace parent_ns = ns.Parent; do { candidates = parent_ns.LookupExtensionMethod(this, extensionType, name, arity); if (candidates != null) { return(candidates); } parent_ns = parent_ns.Parent; } while (parent_ns != null); // // Continue in parent scope // return(parent.LookupExtensionMethod(extensionType, name, arity, ref scope)); }
// // Does extension methods look up to find a method which matches name and extensionType. // Search starts from this namespace and continues hierarchically up to top level. // public ExtensionMethodCandidates LookupExtensionMethod(TypeSpec extensionType, string name, int arity) { List <MethodSpec> candidates = null; foreach (Namespace n in GetUsingTable()) { var a = n.LookupExtensionMethod(this, extensionType, name, arity); if (a == null) { continue; } if (candidates == null) { candidates = a; } else { candidates.AddRange(a); } } if (candidates != null) { return(new ExtensionMethodCandidates(candidates, this)); } if (parent == null) { return(null); } Namespace ns_scope; var ns_candidates = ns.Parent.LookupExtensionMethod(this, extensionType, name, arity, out ns_scope); if (ns_candidates != null) { return(new ExtensionMethodCandidates(ns_candidates, this, ns_scope)); } // // Continue in parent container // return(parent.LookupExtensionMethod(extensionType, name, arity)); }