[Issue 14865] Elide calling invariant for classes with no invariant defined

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Aug 4 00:55:50 PDT 2015


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

--- Comment #2 from Dmitry Olshansky <dmitry.olsh at gmail.com> ---
(In reply to Kenji Hara from comment #1)
> For virtual class methods, their invariant call should be virtual. For
> example:
> 
> class C
> {
>     void foo() {}
> }
> 
> class D : C
> {
>     invariant {}
> }
> 
> void main()
> {
>     C c = new D;
>     c.foo();    // should check D.invariant
> }

Could it do a test on invariant v-table slot to see if it's a default
invariant?
Then if it's the default - just test for null inline, if not - call that slot.

--


More information about the Digitalmars-d-bugs mailing list