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

This commit is contained in:
Marek Safar committed 2013-10-29 15:04:44 +01:00
1 parent dd1826124a
commit da82237da0
3 files changed
+55 -2

No files matched your search

+17
View File
@@ -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; } }
}
+27
View File
@@ -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 ()
{
}
}
+11 -2
View 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 ());