function overrides but is not covariant
John Colvin
john.loughran.colvin at gmail.com
Mon Apr 29 01:51:30 PDT 2013
On Sunday, 28 April 2013 at 19:45:41 UTC, Namespace wrote:
> That surprised me a bit. Is that expected?
>
> ----
> import std.stdio;
>
> struct A { }
>
> interface IFoo {
> void bar(ref const A);
> }
>
> class Foo : IFoo {
> void bar(ref const A a) {
>
> }
>
> void bar(const A a) {
> return this.bar(a);
> }
> }
> ----
> prints:
>
> Error: function c517.Foo.bar of type void(const(A) a) overrides
> but is not covariant with c517.IFoo.bar of type void(ref
> const(A))
Not surprising to me at all. Why would ref be covariant with
non-ref?
More information about the Digitalmars-d-learn
mailing list