throw new NotImplementedException ();
}
- public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
+ public ExtensionMethodCandidates LookupExtensionMethod (string name, int arity)
{
throw new NotImplementedException ();
}
int i = 0;
if (abstract_methods != null) {
int count = abstract_methods.Length;
- pending_implementations [i].methods = new MethodSpec [count];
pending_implementations [i].need_proxy = new MethodSpec [count];
pending_implementations [i].methods = abstract_methods;
static MissingInterfacesInfo [] GetMissingInterfaces (TypeDefinition container)
{
//
- // Notice that Interfaces will only return the interfaces that the Type
- // is supposed to implement, not all the interfaces that the type implements.
+ // Interfaces will return all interfaces that the container
+ // implements including any inherited interfaces
//
var impl = container.Definition.Interfaces;
if (impl == null || impl.Count == 0)
return EmptyMissingInterfacesInfo;
- MissingInterfacesInfo[] ret = new MissingInterfacesInfo[impl.Count];
+ var ret = new MissingInterfacesInfo[impl.Count];
- for (int i = 0; i < impl.Count; i++)
+ for (int i = 0; i < ret.Length; i++)
ret [i] = new MissingInterfacesInfo (impl [i]);
// we really should not get here because Object doesnt implement any
bool BaseImplements (TypeSpec iface_type, MethodSpec mi, out MethodSpec base_method)
{
base_method = null;
- var base_type = container.BaseType;
+ bool base_can_implement = true;
+ TypeSpec lookup_type;
+
+ //
+ // Special handling for properties/indexers which cannot have accessors
+ // implementing an interface found in different types (e.g. current and base)
+ //
+ if (mi.IsAccessor && container.Interfaces != null) {
+
+ bool new_implementation = false;
+ foreach (var iface in container.Interfaces) {
+ if (TypeSpecComparer.IsEqual (iface, iface_type)) {
+ new_implementation = true;
+ break;
+ }
+ }
+
+ if (new_implementation) {
+ MemberFilter filter;
+ if (mi.Parameters.Count > 1) {
+ var indexer_params = mi.Name [0] == 'g' ? mi.Parameters : IndexerSpec.CreateParametersFromSetter (mi, mi.Parameters.Count - 1);
+ filter = new MemberFilter (MemberCache.IndexerNameAlias, 0, MemberKind.Indexer, indexer_params, null);
+ } else {
+ var pname = mi.Name.Substring (4);
+ filter = MemberFilter.Property (pname, null);
+ }
+
+ var prop = MemberCache.FindMember (container.CurrentType, filter, BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly);
+ if (prop != null && (prop.Modifiers & Modifiers.NEW) != 0)
+ base_can_implement = false;
+ }
+ }
+
+ if (base_can_implement) {
+ lookup_type = container.BaseType;
+
+ if (lookup_type.ImplementsInterface (iface_type, false))
+ return true;
+ } else {
+ lookup_type = container.CurrentType;
+ }
//
// Setup filter with no return type to give better error message
// about mismatch at return type when the check bellow rejects them
//
var parameters = mi.Parameters;
+ MethodSpec close_match = null;
+
while (true) {
- var candidates = MemberCache.FindMembers (base_type, mi.Name, false);
- if (candidates == null)
+ var candidates = MemberCache.FindMembers (lookup_type, mi.Name, !base_can_implement);
+ if (candidates == null) {
+ base_method = close_match;
return false;
+ }
MethodSpec similar_candidate = null;
foreach (var candidate in candidates) {
// From this point the candidate is used for detailed error reporting
// because it's very close match to what we are looking for
//
- base_method = (MethodSpec) candidate;
+ var m = (MethodSpec) candidate;
+
+ if (!m.IsPublic) {
+ if (close_match == null)
+ close_match = m;
+
+ continue;
+ }
- if (!candidate.IsPublic)
- return false;
+ if (!TypeSpecComparer.Override.IsEqual (mi.ReturnType, m.ReturnType)) {
+ if (close_match == null)
+ close_match = m;
- if (!TypeSpecComparer.Override.IsEqual (mi.ReturnType, base_method.ReturnType))
- return false;
+ continue;
+ }
+
+ base_method = m;
- if (mi.IsGeneric && !Method.CheckImplementingMethodConstraints (container, base_method, mi)) {
+ if (mi.IsGeneric && !Method.CheckImplementingMethodConstraints (container, m, mi)) {
return true;
}
}
-
+
if (base_method != null) {
if (similar_candidate != null) {
Report.SymbolRelatedToPreviousError (similar_candidate);
break;
}
- base_type = candidates[0].DeclaringType.BaseType;
- if (base_type == null)
+ if (!base_can_implement)
+ return false;
+
+ lookup_type = candidates[0].DeclaringType.BaseType;
+ if (lookup_type == null) {
+ base_method = close_match;
return false;
+ }
}
if (!base_method.IsVirtual) {
for (i = 0; i < top; i++){
TypeSpec type = pending_implementations [i].type;
- bool base_implements_type = type.IsInterface &&
- container.BaseType != null &&
- container.BaseType.ImplementsInterface (type, false);
-
for (int j = 0; j < pending_implementations [i].methods.Count; ++j) {
var mi = pending_implementations[i].methods[j];
if (mi == null)
continue;
}
- if (pending_implementations [i].optional)
- continue;
-
- MethodSpec candidate = null;
- if (base_implements_type || BaseImplements (type, mi, out candidate))
+ MethodSpec candidate;
+ if (BaseImplements (type, mi, out candidate))
continue;
if (candidate == null) {