http://d.puremagic.com/issues/show_bug.cgi?id=6856
Summary: Preconditions are not inherited Product: D Version: D2 Platform: Other OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: timon.g...@gmx.ch --- Comment #0 from timon.g...@gmx.ch 2011-10-26 13:58:18 PDT --- Precondition inheritance does not work in a satisfying way: import std.stdio; class A{ void foo()in{writeln("in!");}out{writeln("out!");}body{} } class B:A{ override void foo(){} // add in{assert(false);}body to get it working } void main(){ A x = new A; x.foo(); // in! \ out! B y = new B; y.foo(); // out! } If the child class does not specify an in contract on an overriding method, the in contract of the parent should be inherited, without adding a contract that always passes. The current behavior makes it too easy to inadvertently widen the interface and have undetected bugs. Chapter 10.9 in TDPL does not explicitly mention the fact that it is supposed to work that way, but it seems to assume it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------