[Issue 799] New: Array literal with covariant types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 6 08:16:36 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=799

           Summary: Array literal with covariant types
           Product: D
           Version: 1.00
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: aarti at interia.pl


class BaseClass {}
class Class1 : BaseClass {}
class Class2 : BaseClass {}

BaseClass[] array;

void main() {
    array=[new BaseClass, new Class1, new Class2];
    //Below gives compile time error
    //Error: cannot implicitly convert expression (new Class2) of type
    //array_literal_with_covariants.Class2 to
    //array_literal_with_covariants.Class1
    array=[new Class1, new Class2];
}


-- 



More information about the Digitalmars-d-bugs mailing list