Better error message when member does not implement interface. Fixes #15369
authorMarek Safar <marek.safar@gmail.com>
Tue, 29 Oct 2013 14:04:44 +0000 (15:04 +0100)
committerMarek Safar <marek.safar@gmail.com>
Tue, 29 Oct 2013 14:04:44 +0000 (15:04 +0100)
mcs/errors/cs0534-11.cs [new file with mode: 0644]
mcs/errors/cs0540-3.cs [new file with mode: 0644]
mcs/mcs/class.cs

diff --git a/mcs/errors/cs0534-11.cs b/mcs/errors/cs0534-11.cs
new file mode 100644 (file)
index 0000000..7d67ac6
--- /dev/null
@@ -0,0 +1,17 @@
+// CS0534: `Foo' does not implement inherited abstract member `SomeAbstract.SomeProperty.get'
+// Line: 13
+
+public class SomeProperty
+{
+}
+
+public abstract class SomeAbstract
+{
+       public abstract SomeProperty SomeProperty { get; }
+}
+
+public class Foo : SomeAbstract
+{
+       public static SomeProperty SomeProperty { get { return null; } }
+}
+
diff --git a/mcs/errors/cs0540-3.cs b/mcs/errors/cs0540-3.cs
new file mode 100644 (file)
index 0000000..99f5f5e
--- /dev/null
@@ -0,0 +1,27 @@
+// CS0540: `Foo.ISomeProp.SomeProperty': containing type does not implement interface `ISomeProp'
+// Line: 18
+
+public class SomeProperty
+{
+}
+
+public abstract class SomeAbstract : ISomeProp
+{
+       public abstract SomeProperty SomeProperty { get; }
+}
+
+interface ISomeProp
+{
+       SomeProperty SomeProperty { get; }
+}
+
+public class Foo : SomeAbstract
+{
+       SomeProperty ISomeProp.SomeProperty { get { return null; } }
+
+       public override SomeProperty SomeProperty { get { return null; } }
+
+       public static void Main ()
+       {
+       }
+}
index 69c39d5be7a721f0950c56cfced70fd0a3734a52..6382365f6fc8cb5a70debdad3496fb04c812f39a 100644 (file)
@@ -2307,11 +2307,20 @@ namespace Mono.CSharp
                /// </summary>
                public bool VerifyImplements (InterfaceMemberBase mb)
                {
-                       var ifaces = spec.Interfaces;
+                       var ifaces = PartialContainer.Interfaces;
                        if (ifaces != null) {
                                foreach (TypeSpec t in ifaces){
                                        if (t == mb.InterfaceType)
                                                return true;
+
+                                       var expanded_base = t.Interfaces;
+                                       if (expanded_base == null)
+                                               continue;
+
+                                       foreach (var bt in expanded_base) {
+                                               if (bt == mb.InterfaceType)
+                                                       return true;
+                                       }
                                }
                        }
                        
@@ -3259,7 +3268,7 @@ namespace Mono.CSharp
                                        }
                                }
 
-                               if (!IsInterface && base_member.IsAbstract && !overrides) {
+                               if (!IsInterface && base_member.IsAbstract && !overrides && !IsStatic) {
                                        Report.SymbolRelatedToPreviousError (base_member);
                                        Report.Error (533, Location, "`{0}' hides inherited abstract member `{1}'",
                                                GetSignatureForError (), base_member.GetSignatureForError ());