January 24, 2006 mixin virtual function bug | ||||
---|---|---|---|---|
| ||||
In the spec on mixins (http://www.digitalmars.com/d/mixin.html) it states "Mixins can add virtual functions to a class". The following shows this to be true: template Virtuals { void test() { printf("Virtuals.test"); } class Target { mixin Virtuals; void test() { printf("Target.test"); } Target t = new Target; t.test(); // prints "Target.test" However, it the virtual mechanism breaks down when using interfaces: interface ITarget { void test(); } class Target : ITarget { mixin Virtuals; void test() { printf("Target.test"); } ITarget t = new Target; t.test(); // prints "Virtuals.test" I would expect the above line to print "Target.test" as in the first examples. John. |
January 25, 2006 Re: mixin virtual function bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C Attachments: | John C schrieb am 2006-01-24: > In the spec on mixins (http://www.digitalmars.com/d/mixin.html) it states "Mixins can add virtual functions to a class". The following shows this to be true: > > template Virtuals { > void test() { printf("Virtuals.test"); > } > > class Target { > mixin Virtuals; > void test() { printf("Target.test"); > } > > Target t = new Target; > t.test(); // prints "Target.test" > > However, it the virtual mechanism breaks down when using interfaces: > > interface ITarget { > void test(); > } > > class Target : ITarget { > mixin Virtuals; > void test() { printf("Target.test"); > } > > ITarget t = new Target; > t.test(); // prints "Virtuals.test" > > I would expect the above line to print "Target.test" as in the first examples. > > John. Added to DStress as http://dstress.kuehne.cn/run/m/mixin_15_A.d http://dstress.kuehne.cn/run/m/mixin_15_B.d http://dstress.kuehne.cn/run/m/mixin_15_C.d Thomas |
Copyright © 1999-2021 by the D Language Foundation