[mono/mono] da82237d: Better error message when member does not implement interface. Fixes #15369

"Marek Safar ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <0000014204936fba-cd840d70-3034-40ae-8822-66799ddeca5c-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/dd1826124a41...da82237da061

   Commit: da82237da061cf3334ac52d42781b09e9574ed9a
   Author: Marek Safar <[email protected]> (marek-safar)
     Date: 2013-10-29 14:04:44 GMT
      URL: https://github.com/mono/mono/commit/da82237da061cf3334ac52d42781b09e9574ed9a

Better error message when member does not implement interface. Fixes #15369

Changed paths:
  M mcs/mcs/class.cs
Added paths:
  A mcs/errors/cs0534-11.cs
  A mcs/errors/cs0540-3.cs

Added: mcs/errors/cs0534-11.cs
===================================================================
@@ -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; } }
+}
+

Added: mcs/errors/cs0540-3.cs
===================================================================
@@ -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 ()
+	{
+	}
+}

Modified: mcs/mcs/class.cs
===================================================================
@@ -2307,11 +2307,20 @@ protected override bool VerifyClsCompliance ()
 		/// </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 @@ protected override bool CheckBase ()
 					}
 				}
 
-				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 ());


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.