Strengthening contract

Kagamin via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 11 07:31:06 PST 2014


http://forum.dlang.org/post/jftnpqyahnwacgkmslej@forum.dlang.org

c:\D\import\dfl\button.d(381): Error: function
dfl.button.Button.text cannot have
e an in contract when overriden function dfl.control.Control.text
does not have an in contract

This is the line 381:

override void text(Dstring txt) // setter
in
{
	if(txt.length)
		assert(!this.image, "Button image with text not supported");
}
body
{
	super.text = txt;
}

But if a button can't display image with text by design, it's its 
contract, that text can't be set with image, while the base class 
has no such restriction. What does it mean, DbC is incompatible 
with inheritance?


More information about the Digitalmars-d mailing list