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
Seems fixed in v2.068.2. Can you confirm?
Comment #2 by k.hara.pg — 2015-10-14T02:09:50Z
(In reply to Andrej Mitrovic from comment #1) > Seems fixed in v2.068.2. Can you confirm? Still happens with git-head. https://github.com/D-Programming-Language/dmd/pull/5193
Comment #3 by github-bugzilla — 2015-10-14T16:28:37Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/72fa908c520ae7f4a6886b03161117c48257c0e0 fix Issue 15141 - Object.factory allows the creation of derived abstract classes `ClassDeclaration.isAbstract()` should be used to emit `ClassFlags::isAbstract` so it's considering abstract member functions. https://github.com/D-Programming-Language/dmd/commit/6e137f59fca49ebb7e6ea453681ee1f3ba6a3b36 Merge pull request #5193 from 9rnsr/fix15141 Issue 15141 - Object.factory allows the creation of derived abstract classes
Comment #4 by github-bugzilla — 2016-01-03T14:02:07Z
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/72fa908c520ae7f4a6886b03161117c48257c0e0 fix Issue 15141 - Object.factory allows the creation of derived abstract classes https://github.com/D-Programming-Language/dmd/commit/6e137f59fca49ebb7e6ea453681ee1f3ba6a3b36 Merge pull request #5193 from 9rnsr/fix15141