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

           Summary: Contravariance problem
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-07-26 13:35:11 PDT ---
A problem found by Jesse Phillips. This is Java program:


class Base {}

class Derived extends Base {}

abstract class Abstract {
    abstract Base foo();
}

class Concrete extends Abstract {
     @Override Derived foo() {
        return new Base();
    }
}

class Test {}



The javac compiler prints:


Test.java:11: incompatible types
        return new Base();
               ^
  required: Derived
  found:    Base
1 error



But dmd 2.047 compiles this D2 program with no errors:

class Base {}

class Derived : Base {}

abstract class Abstract {
    abstract Base foo();
}

class Concrete : Abstract {
    override Derived foo() {
        return new Base;
    }
}

void main() {}

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

Reply via email to