Inheritance and in-contracts

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Dec 5 14:45:07 PST 2014


On 12/05/2014 02:39 PM, Joseph Rushton Wakeling via Digitalmars-d-learn 
wrote:

 > In other words, the lack of explicit in-contract on Deriv.foo is being
 > taken as an _empty_ in-contract, which is being interpreted as per the
 > rule that a derived class can have a less restrictive contract than its
 > base (cf. TDPL pp.329-331).

This is a known problem with contract inheritance. The following bug 
report mentions the ugly hack of defining assert(0) as the derived's 
'in' contract:

   https://issues.dlang.org/show_bug.cgi?id=6856

Ali



More information about the Digitalmars-d-learn mailing list