Bug 15141 – Object.factory allows the creation of derived abstract classes
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-10-03T11:15:00Z
Last change time
2016-01-03T14:02:07Z
Assigned to
nobody
Creator
atila.neves
Comments
Comment #0 by atila.neves — 2015-10-03T11:15:11Z
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
}
Comment #1 by andrej.mitrovich — 2015-10-11T13:44:52Z