Summary: Preconditions are not inherited
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from 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;; // in! \ out!
    B y = new B;; // 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:
------- You are receiving this mail because: -------

Reply via email to