ab6d17d9155ffb86fdcf939f5d7c889db7e7b9eb
[mono.git] / mcs / mcs / pending.cs
1 //
2 // pending.cs: Pending method implementation
3 //
4 // Authors:
5 //   Miguel de Icaza (miguel@gnu.org)
6 //   Marek Safar (marek.safar@gmail.com)
7 //
8 // Dual licensed under the terms of the MIT X11 or GNU GPL
9 //
10 // Copyright 2001, 2002 Ximian, Inc (http://www.ximian.com)
11 // Copyright 2003-2008 Novell, Inc.
12 //
13
14 using System;
15 using System.Collections.Generic;
16 using System.Linq;
17
18 #if STATIC
19 using IKVM.Reflection;
20 using IKVM.Reflection.Emit;
21 #else
22 using System.Reflection;
23 using System.Reflection.Emit;
24 #endif
25
26 namespace Mono.CSharp {
27
28         struct TypeAndMethods {
29                 public TypeSpec          type;
30                 public IList<MethodSpec> methods;
31
32                 // 
33                 // Whether it is optional, this is used to allow the explicit/implicit
34                 // implementation when a base class already implements an interface. 
35                 //
36                 // For example:
37                 //
38                 // class X : IA { }  class Y : X, IA { IA.Explicit (); }
39                 //
40                 public bool          optional;
41                                 
42                 //
43                 // This flag on the method says `We found a match, but
44                 // because it was private, we could not use the match
45                 //
46                 public MethodData [] found;
47
48                 // If a method is defined here, then we always need to
49                 // create a proxy for it.  This is used when implementing
50                 // an interface's indexer with a different IndexerName.
51                 public MethodSpec [] need_proxy;
52         }
53
54         struct ProxyMethodContext : IMemberContext
55         {
56                 readonly TypeContainer container;
57
58                 public ProxyMethodContext (TypeContainer container)
59                 {
60                         this.container = container;
61                 }
62
63                 public TypeSpec CurrentType {
64                         get {
65                                 throw new NotImplementedException ();
66                         }
67                 }
68
69                 public TypeParameter[] CurrentTypeParameters {
70                         get {
71                                 throw new NotImplementedException ();
72                         }
73                 }
74
75                 public MemberCore CurrentMemberDefinition {
76                         get {
77                                 throw new NotImplementedException ();
78                         }
79                 }
80
81                 public bool IsObsolete {
82                         get {
83                                 return false;
84                         }
85                 }
86
87                 public bool IsUnsafe {
88                         get {
89                                 throw new NotImplementedException ();
90                         }
91                 }
92
93                 public bool IsStatic {
94                         get {
95                                 return false;
96                         }
97                 }
98
99                 public ModuleContainer Module {
100                         get {
101                                 return container.Module;
102                         }
103                 }
104
105                 public string GetSignatureForError ()
106                 {
107                         throw new NotImplementedException ();
108                 }
109
110                 public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
111                 {
112                         throw new NotImplementedException ();
113                 }
114
115                 public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
116                 {
117                         throw new NotImplementedException ();
118                 }
119
120                 public FullNamedExpression LookupNamespaceAlias (string name)
121                 {
122                         throw new NotImplementedException ();
123                 }
124         }
125
126         public class PendingImplementation
127         {
128                 /// <summary>
129                 ///   The container for this PendingImplementation
130                 /// </summary>
131                 readonly TypeContainer container;
132                 
133                 /// <summary>
134                 ///   This is the array of TypeAndMethods that describes the pending implementations
135                 ///   (both interfaces and abstract methods in base class)
136                 /// </summary>
137                 TypeAndMethods [] pending_implementations;
138
139                 PendingImplementation (TypeContainer container, MissingInterfacesInfo[] missing_ifaces, MethodSpec[] abstract_methods, int total)
140                 {
141                         var type_builder = container.Definition;
142                         
143                         this.container = container;
144                         pending_implementations = new TypeAndMethods [total];
145
146                         int i = 0;
147                         if (abstract_methods != null) {
148                                 int count = abstract_methods.Length;
149                                 pending_implementations [i].methods = new MethodSpec [count];
150                                 pending_implementations [i].need_proxy = new MethodSpec [count];
151
152                                 pending_implementations [i].methods = abstract_methods;
153                                 pending_implementations [i].found = new MethodData [count];
154                                 pending_implementations [i].type = type_builder;
155                                 ++i;
156                         }
157
158                         foreach (MissingInterfacesInfo missing in missing_ifaces) {
159                                 var iface = missing.Type;
160                                 var mi = MemberCache.GetInterfaceMethods (iface);
161
162                                 int count = mi.Count;
163                                 pending_implementations [i].type = iface;
164                                 pending_implementations [i].optional = missing.Optional;
165                                 pending_implementations [i].methods = mi;
166                                 pending_implementations [i].found = new MethodData [count];
167                                 pending_implementations [i].need_proxy = new MethodSpec [count];
168                                 i++;
169                         }
170                 }
171
172                 Report Report {
173                         get {
174                                 return container.Module.Compiler.Report;
175                         }
176                 }
177
178                 struct MissingInterfacesInfo {
179                         public TypeSpec Type;
180                         public bool Optional;
181
182                         public MissingInterfacesInfo (TypeSpec t)
183                         {
184                                 Type = t;
185                                 Optional = false;
186                         }
187                 }
188
189                 static readonly MissingInterfacesInfo [] EmptyMissingInterfacesInfo = new MissingInterfacesInfo [0];
190                 
191                 static MissingInterfacesInfo [] GetMissingInterfaces (TypeContainer container)
192                 {
193                         //
194                         // Notice that Interfaces will only return the interfaces that the Type
195                         // is supposed to implement, not all the interfaces that the type implements.
196                         //
197                         var impl = container.Definition.Interfaces;
198
199                         if (impl == null || impl.Count == 0)
200                                 return EmptyMissingInterfacesInfo;
201
202                         MissingInterfacesInfo[] ret = new MissingInterfacesInfo[impl.Count];
203
204                         for (int i = 0; i < impl.Count; i++)
205                                 ret [i] = new MissingInterfacesInfo (impl [i]);
206
207                         // we really should not get here because Object doesnt implement any
208                         // interfaces. But it could implement something internal, so we have
209                         // to handle that case.
210                         if (container.BaseType == null)
211                                 return ret;
212                         
213                         var base_impls = container.BaseType.Interfaces;
214                         if (base_impls != null) {
215                                 foreach (TypeSpec t in base_impls) {
216                                         for (int i = 0; i < ret.Length; i++) {
217                                                 if (t == ret[i].Type) {
218                                                         ret[i].Optional = true;
219                                                         break;
220                                                 }
221                                         }
222                                 }
223                         }
224
225                         return ret;
226                 }
227                 
228                 //
229                 // Factory method: if there are pending implementation methods, we return a PendingImplementation
230                 // object, otherwise we return null.
231                 //
232                 // Register method implementations are either abstract methods
233                 // flagged as such on the base class or interface methods
234                 //
235                 static public PendingImplementation GetPendingImplementations (TypeContainer container)
236                 {
237                         TypeSpec b = container.BaseType;
238
239                         var missing_interfaces = GetMissingInterfaces (container);
240
241                         //
242                         // If we are implementing an abstract class, and we are not
243                         // ourselves abstract, and there are abstract methods (C# allows
244                         // abstract classes that have no abstract methods), then allocate
245                         // one slot.
246                         //
247                         // We also pre-compute the methods.
248                         //
249                         bool implementing_abstract = ((b != null) && b.IsAbstract && (container.ModFlags & Modifiers.ABSTRACT) == 0);
250                         MethodSpec[] abstract_methods = null;
251
252                         if (implementing_abstract){
253                                 var am = MemberCache.GetNotImplementedAbstractMethods (b);
254
255                                 if (am == null) {
256                                         implementing_abstract = false;
257                                 } else {
258                                         abstract_methods = new MethodSpec[am.Count];
259                                         am.CopyTo (abstract_methods, 0);
260                                 }
261                         }
262                         
263                         int total = missing_interfaces.Length +  (implementing_abstract ? 1 : 0);
264                         if (total == 0)
265                                 return null;
266
267                         var pending = new PendingImplementation (container, missing_interfaces, abstract_methods, total);
268
269                         //
270                         // check for inherited conflicting methods
271                         //
272                         foreach (var p in pending.pending_implementations) {
273                                 //
274                                 // It can happen for generic interfaces only
275                                 //
276                                 if (!p.type.IsGeneric)
277                                         continue;
278
279                                 //
280                                 // CLR does not distinguishes between ref and out
281                                 //
282                                 for (int i = 0; i < p.methods.Count; ++i) {
283                                         MethodSpec compared_method = p.methods[i];
284                                         if (compared_method.Parameters.IsEmpty)
285                                                 continue;
286
287                                         for (int ii = i + 1; ii < p.methods.Count; ++ii) {
288                                                 MethodSpec tested_method = p.methods[ii];
289                                                 if (compared_method.Name != tested_method.Name)
290                                                         continue;
291
292                                                 if (p.type != tested_method.DeclaringType)
293                                                         continue;
294
295                                                 if (!TypeSpecComparer.Override.IsSame (compared_method.Parameters.Types, tested_method.Parameters.Types))
296                                                         continue;
297
298                                                 bool exact_match = true;
299                                                 bool ref_only_difference = false;
300                                                 var cp = compared_method.Parameters.FixedParameters;
301                                                 var tp = tested_method.Parameters.FixedParameters;
302
303                                                 for (int pi = 0; pi < cp.Length; ++pi) {
304                                                         //
305                                                         // First check exact modifiers match
306                                                         //
307                                                         const Parameter.Modifier ref_out = Parameter.Modifier.REF | Parameter.Modifier.OUT;
308                                                         if ((cp[pi].ModFlags & ref_out) == (tp[pi].ModFlags & ref_out))
309                                                                 continue;
310
311                                                         if ((cp[pi].ModFlags & tp[pi].ModFlags & Parameter.Modifier.ISBYREF) != 0) {
312                                                                 ref_only_difference = true;
313                                                                 continue;
314                                                         }
315
316                                                         exact_match = false;
317                                                         break;
318                                                 }
319
320                                                 if (!exact_match || !ref_only_difference)
321                                                         continue;
322
323                                                 pending.Report.SymbolRelatedToPreviousError (compared_method);
324                                                 pending.Report.SymbolRelatedToPreviousError (tested_method);
325                                                 pending.Report.Error (767, container.Location,
326                                                         "Cannot implement interface `{0}' with the specified type parameters because it causes method `{1}' to differ on parameter modifiers only",
327                                                         p.type.GetDefinition().GetSignatureForError (), compared_method.GetSignatureForError ());
328
329                                                 break;
330                                         }
331                                 }
332                         }
333
334                         return pending;
335                 }
336
337                 public enum Operation {
338                         //
339                         // If you change this, review the whole InterfaceMethod routine as there
340                         // are a couple of assumptions on these three states
341                         //
342                         Lookup, ClearOne, ClearAll
343                 }
344
345                 /// <summary>
346                 ///   Whether the specified method is an interface method implementation
347                 /// </summary>
348                 public MethodSpec IsInterfaceMethod (MemberName name, TypeSpec ifaceType, MethodData method, out MethodSpec ambiguousCandidate, ref bool optional)
349                 {
350                         return InterfaceMethod (name, ifaceType, method, Operation.Lookup, out ambiguousCandidate, ref optional);
351                 }
352
353                 public void ImplementMethod (MemberName name, TypeSpec ifaceType, MethodData method, bool clear_one, out MethodSpec ambiguousCandidate, ref bool optional)
354                 {
355                         InterfaceMethod (name, ifaceType, method, clear_one ? Operation.ClearOne : Operation.ClearAll, out ambiguousCandidate, ref optional);
356                 }
357
358                 /// <remarks>
359                 ///   If a method in Type `t' (or null to look in all interfaces
360                 ///   and the base abstract class) with name `Name', return type `ret_type' and
361                 ///   arguments `args' implements an interface, this method will
362                 ///   return the MethodInfo that this method implements.
363                 ///
364                 ///   If `name' is null, we operate solely on the method's signature.  This is for
365                 ///   instance used when implementing indexers.
366                 ///
367                 ///   The `Operation op' controls whether to lookup, clear the pending bit, or clear
368                 ///   all the methods with the given signature.
369                 ///
370                 ///   The `MethodInfo need_proxy' is used when we're implementing an interface's
371                 ///   indexer in a class.  If the new indexer's IndexerName does not match the one
372                 ///   that was used in the interface, then we always need to create a proxy for it.
373                 ///
374                 /// </remarks>
375                 public MethodSpec InterfaceMethod (MemberName name, TypeSpec iType, MethodData method, Operation op, out MethodSpec ambiguousCandidate, ref bool optional)
376                 {
377                         ambiguousCandidate = null;
378
379                         if (pending_implementations == null)
380                                 return null;
381
382                         TypeSpec ret_type = method.method.ReturnType;
383                         ParametersCompiled args = method.method.ParameterInfo;
384                         bool is_indexer = method.method is Indexer.SetIndexerMethod || method.method is Indexer.GetIndexerMethod;
385                         MethodSpec m;
386
387                         foreach (TypeAndMethods tm in pending_implementations){
388                                 if (!(iType == null || tm.type == iType))
389                                         continue;
390
391                                 int method_count = tm.methods.Count;
392                                 for (int i = 0; i < method_count; i++){
393                                         m = tm.methods [i];
394
395                                         if (m == null)
396                                                 continue;
397
398                                         if (is_indexer) {
399                                                 if (!m.IsAccessor || m.Parameters.IsEmpty)
400                                                         continue;
401                                         } else {
402                                                 if (name.Name != m.Name)
403                                                         continue;
404
405                                                 if (m.Arity != name.Arity)
406                                                         continue;
407                                         }
408
409                                         if (!TypeSpecComparer.Override.IsEqual (m.Parameters, args))
410                                                 continue;
411
412                                         if (!TypeSpecComparer.Override.IsEqual (m.ReturnType, ret_type)) {
413                                                 tm.found[i] = method;
414                                                 continue;
415                                         }
416
417                                         //
418                                         // `need_proxy' is not null when we're implementing an
419                                         // interface indexer and this is Clear(One/All) operation.
420                                         //
421                                         // If `name' is null, then we do a match solely based on the
422                                         // signature and not on the name (this is done in the Lookup
423                                         // for an interface indexer).
424                                         //
425                                         if (op != Operation.Lookup) {
426                                                 if (m.IsAccessor != method.method.IsAccessor)
427                                                         continue;
428
429                                                 // If `t != null', then this is an explicitly interface
430                                                 // implementation and we can always clear the method.
431                                                 // `need_proxy' is not null if we're implementing an
432                                                 // interface indexer.  In this case, we need to create
433                                                 // a proxy if the implementation's IndexerName doesn't
434                                                 // match the IndexerName in the interface.
435                                                 if (m.DeclaringType.IsInterface && iType == null && name.Name != m.Name) {      // TODO: This is very expensive comparison
436                                                         tm.need_proxy[i] = method.method.Spec;
437                                                 } else {
438                                                         tm.methods[i] = null;
439                                                 }
440                                         } else {
441                                                 tm.found [i] = method;
442                                                 optional = tm.optional;
443                                         }
444
445                                         if (op == Operation.Lookup && name.Left != null && ambiguousCandidate == null) {
446                                                 ambiguousCandidate = m;
447                                                 continue;
448                                         }
449
450                                         //
451                                         // Lookups and ClearOne return
452                                         //
453                                         if (op != Operation.ClearAll)
454                                                 return m;
455                                 }
456
457                                 // If a specific type was requested, we can stop now.
458                                 if (tm.type == iType)
459                                         break;
460                         }
461
462                         m = ambiguousCandidate;
463                         ambiguousCandidate = null;
464                         return m;
465                 }
466
467                 /// <summary>
468                 ///   C# allows this kind of scenarios:
469                 ///   interface I { void M (); }
470                 ///   class X { public void M (); }
471                 ///   class Y : X, I { }
472                 ///
473                 ///   For that case, we create an explicit implementation function
474                 ///   I.M in Y.
475                 /// </summary>
476                 void DefineProxy (TypeSpec iface, MethodSpec base_method, MethodSpec iface_method)
477                 {
478                         // TODO: Handle nested iface names
479                         string proxy_name;
480                         var ns = iface.MemberDefinition.Namespace;
481                         if (string.IsNullOrEmpty (ns))
482                                 proxy_name = iface.MemberDefinition.Name + "." + iface_method.Name;
483                         else
484                                 proxy_name = ns + "." + iface.MemberDefinition.Name + "." + iface_method.Name;
485
486                         var param = iface_method.Parameters;
487
488                         MethodBuilder proxy = container.TypeBuilder.DefineMethod (
489                                 proxy_name,
490                                 MethodAttributes.Private |
491                                 MethodAttributes.HideBySig |
492                                 MethodAttributes.NewSlot |
493                                 MethodAttributes.CheckAccessOnOverride |
494                                 MethodAttributes.Virtual | MethodAttributes.Final,
495                                 CallingConventions.Standard | CallingConventions.HasThis,
496                                 base_method.ReturnType.GetMetaInfo (), param.GetMetaInfo ());
497
498                         if (iface_method.IsGeneric) {
499                                 var gnames = iface_method.GenericDefinition.TypeParameters.Select (l => l.Name).ToArray ();
500                                 proxy.DefineGenericParameters (gnames);
501                         }
502
503                         for (int i = 0; i < param.Count; i++) {
504                                 string name = param.FixedParameters [i].Name;
505                                 ParameterAttributes attr = ParametersCompiled.GetParameterAttribute (param.FixedParameters [i].ModFlags);
506                                 proxy.DefineParameter (i + 1, attr, name);
507                         }
508
509                         int top = param.Count;
510                         var ec = new EmitContext (new ProxyMethodContext (container), proxy.GetILGenerator (), null);
511                         ec.EmitThis ();
512                         // TODO: GetAllParametersArguments
513                         for (int i = 0; i < top; i++)
514                                 ec.EmitArgumentLoad (i);
515
516                         ec.Emit (OpCodes.Call, base_method);
517                         ec.Emit (OpCodes.Ret);
518
519                         container.TypeBuilder.DefineMethodOverride (proxy, (MethodInfo) iface_method.GetMetaInfo ());
520                 }
521                 
522                 /// <summary>
523                 ///   This function tells whether one of our base classes implements
524                 ///   the given method (which turns out, it is valid to have an interface
525                 ///   implementation in a base
526                 /// </summary>
527                 bool BaseImplements (TypeSpec iface_type, MethodSpec mi, out MethodSpec base_method)
528                 {
529                         base_method = null;
530                         var base_type = container.BaseType;
531
532                         //
533                         // Setup filter with no return type to give better error message
534                         // about mismatch at return type when the check bellow rejects them
535                         //
536                         var parameters = mi.Parameters;
537                         while (true) {
538                                 var candidates = MemberCache.FindMembers (base_type, mi.Name, false);
539                                 if (candidates == null)
540                                         return false;
541
542                                 MethodSpec similar_candidate = null;
543                                 foreach (var candidate in candidates) {
544                                         if (candidate.Kind != MemberKind.Method)
545                                                 continue;
546
547                                         if (candidate.Arity != mi.Arity)
548                                                 continue;
549
550                                         var candidate_param = ((MethodSpec) candidate).Parameters;
551                                         if (!TypeSpecComparer.Override.IsSame (parameters.Types, candidate_param.Types))
552                                                 continue;
553
554                                         bool modifiers_match = true;
555                                         for (int i = 0; i < parameters.Count; ++i) {
556                                                 //
557                                                 // First check exact ref/out match
558                                                 //
559                                                 const Parameter.Modifier ref_out = Parameter.Modifier.REF | Parameter.Modifier.OUT;
560                                                 if ((parameters.FixedParameters[i].ModFlags & ref_out) == (candidate_param.FixedParameters[i].ModFlags & ref_out))
561                                                         continue;
562
563                                                 modifiers_match = false;
564
565                                                 //
566                                                 // Different in ref/out only
567                                                 //
568                                                 if ((parameters.FixedParameters[i].ModFlags & candidate_param.FixedParameters[i].ModFlags & Parameter.Modifier.ISBYREF) != 0) {
569                                                         if (similar_candidate == null) {
570                                                                 if (!candidate.IsPublic)
571                                                                         break;
572
573                                                                 if (!TypeSpecComparer.Override.IsEqual (mi.ReturnType, ((MethodSpec) candidate).ReturnType))
574                                                                         break;
575
576                                                                 // It's used for ref/out ambiguity overload check
577                                                                 similar_candidate = (MethodSpec) candidate;
578                                                         }
579
580                                                         continue;
581                                                 }
582
583                                                 similar_candidate = null;
584                                                 break;
585                                         }
586
587                                         if (!modifiers_match)
588                                                 continue;
589
590                                         //
591                                         // From this point on the candidate is used for detailed error reporting
592                                         // because it's very close match to what we are looking for
593                                         //
594                                         base_method = (MethodSpec) candidate;
595
596                                         if (!candidate.IsPublic)
597                                                 return false;
598
599                                         if (!TypeSpecComparer.Override.IsEqual (mi.ReturnType, base_method.ReturnType))
600                                                 return false;
601
602                                         if (mi.IsGeneric && !Method.CheckImplementingMethodConstraints (container, base_method, mi)) {
603                                                 return true;
604                                         }
605                                 }
606
607                                 if (base_method != null) {
608                                         if (similar_candidate != null) {
609                                                 Report.SymbolRelatedToPreviousError (similar_candidate);
610                                                 Report.SymbolRelatedToPreviousError (mi);
611                                                 Report.SymbolRelatedToPreviousError (container);
612                                                 Report.Warning (1956, 1, ((MemberCore) base_method.MemberDefinition).Location,
613                                                         "The interface method `{0}' implementation is ambiguous between following methods: `{1}' and `{2}' in type `{3}'",
614                                                         mi.GetSignatureForError (), base_method.GetSignatureForError (), similar_candidate.GetSignatureForError (), container.GetSignatureForError ());
615                                         }
616
617                                         break;
618                                 }
619
620                                 base_type = candidates[0].DeclaringType.BaseType;
621                                 if (base_type == null)
622                                         return false;
623                         }
624
625                         if (!base_method.IsVirtual) {
626 #if STATIC
627                                 var base_builder = base_method.GetMetaInfo () as MethodBuilder;
628                                 if (base_builder != null) {
629                                         //
630                                         // We can avoid creating a proxy if base_method can be marked 'final virtual'. This can
631                                         // be done for all methods from compiled assembly
632                                         //
633                                         base_builder.__SetAttributes (base_builder.Attributes | MethodAttributes.Virtual | MethodAttributes.Final | MethodAttributes.NewSlot);
634                                         return true;
635                                 }
636 #endif
637                                 DefineProxy (iface_type, base_method, mi);
638                         }
639
640                         return true;
641                 }
642
643                 /// <summary>
644                 ///   Verifies that any pending abstract methods or interface methods
645                 ///   were implemented.
646                 /// </summary>
647                 public bool VerifyPendingMethods ()
648                 {
649                         int top = pending_implementations.Length;
650                         bool errors = false;
651                         int i;
652                         
653                         for (i = 0; i < top; i++){
654                                 TypeSpec type = pending_implementations [i].type;
655
656                                 bool base_implements_type = type.IsInterface &&
657                                         container.BaseType != null &&
658                                         container.BaseType.ImplementsInterface (type, false);
659
660                                 for (int j = 0; j < pending_implementations [i].methods.Count; ++j) {
661                                         var mi = pending_implementations[i].methods[j];
662                                         if (mi == null)
663                                                 continue;
664
665                                         if (type.IsInterface){
666                                                 var need_proxy =
667                                                         pending_implementations [i].need_proxy [j];
668
669                                                 if (need_proxy != null) {
670                                                         DefineProxy (type, need_proxy, mi);
671                                                         continue;
672                                                 }
673
674                                                 if (pending_implementations [i].optional)
675                                                         continue;
676
677                                                 MethodSpec candidate = null;
678                                                 if (base_implements_type || BaseImplements (type, mi, out candidate))
679                                                         continue;
680
681                                                 if (candidate == null) {
682                                                         MethodData md = pending_implementations [i].found [j];
683                                                         if (md != null)
684                                                                 candidate = md.method.Spec;
685                                                 }
686
687                                                 Report.SymbolRelatedToPreviousError (mi);
688                                                 if (candidate != null) {
689                                                         Report.SymbolRelatedToPreviousError (candidate);
690                                                         if (candidate.IsStatic) {
691                                                                 Report.Error (736, container.Location,
692                                                                         "`{0}' does not implement interface member `{1}' and the best implementing candidate `{2}' is static",
693                                                                         container.GetSignatureForError (), mi.GetSignatureForError (), candidate.GetSignatureForError ());
694                                                         } else if ((candidate.Modifiers & Modifiers.PUBLIC) == 0) {
695                                                                 Report.Error (737, container.Location,
696                                                                         "`{0}' does not implement interface member `{1}' and the best implementing candidate `{2}' in not public",
697                                                                         container.GetSignatureForError (), mi.GetSignatureForError (), candidate.GetSignatureForError ());
698                                                         } else {
699                                                                 Report.Error (738, container.Location,
700                                                                         "`{0}' does not implement interface member `{1}' and the best implementing candidate `{2}' return type `{3}' does not match interface member return type `{4}'",
701                                                                         container.GetSignatureForError (), mi.GetSignatureForError (), candidate.GetSignatureForError (),
702                                                                         candidate.ReturnType.GetSignatureForError (), mi.ReturnType.GetSignatureForError ());
703                                                         }
704                                                 } else {
705                                                         Report.Error (535, container.Location, "`{0}' does not implement interface member `{1}'",
706                                                                 container.GetSignatureForError (), mi.GetSignatureForError ());
707                                                 }
708                                         } else {
709                                                 Report.SymbolRelatedToPreviousError (mi);
710                                                 Report.Error (534, container.Location, "`{0}' does not implement inherited abstract member `{1}'",
711                                                         container.GetSignatureForError (), mi.GetSignatureForError ());
712                                         }
713                                         errors = true;
714                                 }
715                         }
716                         return errors;
717                 }
718         }
719 }