www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3265] New: Interface-typed function parameter does not return instance's ClassInfo

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3265

           Summary: Interface-typed function parameter does not return
                    instance's ClassInfo
           Product: D
           Version: 2.031
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: spec, wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: hskwk inter7.jp


If function parameter type is a interface, parameter.classinfo returns
inteface's ClassInfo instead of instance's ClassInfo.

interface I {}
class C : I {}
class D : C {}

void o(in Object obj) { writeln(obj.classinfo.name); }
void i(in I obj) { writeln(obj.classinfo.name); }
void c(in C obj) { writeln(obj.classinfo.name); }


void main()
{
    auto d = new D;
    o(d);    // -> D
    i(d);    // -> I, wrong
    c(d);    // -> D
}

I suppose this behavior is a bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 25 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3265





--- Comment #1 from HOSOKAWA Kenchi <hskwk inter7.jp>  2009-08-25 07:55:36 PDT
---
It is not related to function argument.
This bug occured by interface reference.

Sorry for rough information.


interface I {}
class C : I {}
class D : C {}

void main() {
    auto d = new D;

    C c = d;
    writeln(c.classinfo.name);
    I i = d;
    writeln(i.classinfo.name);
    Object o = d;
    writeln(o.classinfo.name);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 25 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3265


HOSOKAWA Kenchi <hskwk inter7.jp> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |
           Priority|P2                          |P4
           Severity|major                       |normal




--- Comment #2 from HOSOKAWA Kenchi <hskwk inter7.jp>  2009-08-25 08:45:59 PDT
---
My friend noted that it is reasonable that interface.classinfo returns
interface's classinfo for IUnknown or Interface to C++.
It sound true so that I changed the issue as not important.


I suggest that at least this spec should be documented.
This behavior is very confusing, I suppose it is better to replace classinfo
property from interface reference by other appropriate way.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 25 2009