Bug 210 – Strange results when covariantly implementing an interface method defined with an interface return type

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-06-19T10:14:00Z
Last change time
2014-02-15T13:18:38Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
smjg
Blocks
179

Comments

Comment #0 by smjg — 2006-06-19T10:14:31Z
This bug carries on where issue 65 left off. That issue covered the case where the interface-to-class covariance is in a class-to-class override. This one covers interface-to-class covariance in an interface-to-class override. This was originally intended to be part of issue 65, but I figured that it might make more sense to break it off as a separate issue. Testcases, based on issue 179 comment 1: ---------- import std.stdio; interface Father { Father test(); void showData(); } class Child : Father { int data; this(int d) { data = d; } Child test() { writefln("in CovFunc Test"); return new Child(69); } void showData() { writefln("Child: %d", data); } } void icov2test() { Child aChild = new Child(42); aChild.showData(); Father childsDad = aChild; childsDad.showData(); Father dadTest = childsDad.test; writefln("FCALL dadTest.showData"); dadTest.showData(); writefln("FCALL dadTest.test"); dadTest.test(); writefln("FCALL (cast(Child) dadTest).showData"); (cast(Child) dadTest).showData(); } ---------- import std.stdio; interface IFoo { } interface ICov { IFoo covfunc(); } class Child : ICov, IFoo { Child covfunc() { writefln("in CovFunc Test"); return new Child(); } } void icov3() { ICov icov = new Child(); IFoo ifoo = icov.covfunc(); writefln(ifoo.classinfo.name); // Segfault or prints garbage writefln((cast(Object) ifoo)); // Segfault or prints garbage } ---------- import std.stdio; interface IFoo { IFoo covfunc(); } class Child : IFoo { Child covfunc() { writefln("in CovFunc Test"); return new Child(); } } void icov3() { IFoo icov = new Child(); IFoo ifoo = icov.covfunc(); writefln(ifoo.classinfo.name); writefln((cast(Object) ifoo)); } ---------- There are other cases to test, namely those involving interface-to-interface covariance || an interface-to-interface override. But getting the above tests working would be a start.
Comment #1 by bugzilla — 2006-06-30T20:31:46Z
Fixed DMD 0.162