www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15141] New: Object.factory allows the creation of derived


          Issue ID: 15141
           Summary: Object.factory allows the creation of derived abstract
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: atila.neves gmail.com

Object.factory returns null for abstract classes, unless they're a child class.
Trying to use this class and calling .method on it causes a crash.

The second assertion fails, it shouldn't:

module factory_test;

class Abstract {
    abstract void method();

class Middle: Abstract { }

void main() {
    auto abs = Object.factory("factory_test.Abtract");
    assert(abs is null);
    auto mid = Object.factory("factory_test.Middle");
    assert(mid is null); //oops
    //auto mid2 = new Middle; //doesn't compile

Oct 03 2015