[Issue 10912] New: property overridding requires both accessors to be overridden
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Aug 27 11:37:06 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10912
Summary: property overridding requires both accessors to be
overridden
Product: D
Version: D2
Platform: All
URL: http://dpaste.dzfl.pl/7bd529ae
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: burg.basile at yahoo.com
--- Comment #0 from burg.basile at yahoo.com 2013-08-27 11:37:05 PDT ---
When overriding a property setter in a descendant class, the getter must also
be overridden (or explicitly called with super), otherwise the compiler doesnt
understand we want to call the getter.
example:
---
import std.stdio;
class foo
{
private int fMyField;
public:
@property
{
void MyField(int aValue){fMyField = aValue;}
int MyField(){return fMyField;}
}
}
class bar: foo
{
public:
@property
{
override void MyField(int aValue){fMyField = 0;}
}
this()
{
writeln(MyField());// dmd should detect that the getter exists in foo.
writeln(super.MyField());//super. would be superfluous
}
}
void main(string[] args)
{
auto Bar = new bar;
}
---
result: compile-time error,
"Error: function f337.bar.MyField (int aValue) is not callable using argument
types ()"
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list