Bug 15185 – [REG2.069.0-b1] Not possible to create instance of TypeInfo

Status
RESOLVED
Resolution
WONTFIX
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-10-11T12:11:00Z
Last change time
2015-10-15T07:58:27Z
Assigned to
nobody
Creator
doob

Comments

Comment #0 by doob — 2015-10-11T12:11:21Z
The following code results in the error below: void main () { auto a = new TypeInfo; } main.d(8): Error: cannot create instance of abstract class TypeInfo main.d(8): function 'const(void)[] init() const pure nothrow @nogc @safe' is not implemented I guess the change is intentional but it's a breaking change.
Comment #1 by doob — 2015-10-11T12:12:05Z
I might add that "init" is declared as "abstract" so there's no compiler bug here.
Comment #2 by k.hara.pg — 2015-10-11T13:10:18Z
Comment #3 by code — 2015-10-12T15:24:27Z
Why do you need to instantiate TypeInfo?
Comment #4 by doob — 2015-10-12T17:12:30Z
(In reply to Martin Nowak from comment #3) > Why do you need to instantiate TypeInfo? https://github.com/d-widget-toolkit/base/blob/master/src/java/nonstandard/RuntimeTraits.d#L13-L21
Comment #5 by schveiguy — 2015-10-13T14:01:07Z
Why not "typeid(const(Object))" and "(const(Object)).classinfo" ?
Comment #6 by doob — 2015-10-13T16:43:43Z
(In reply to Steven Schveighoffer from comment #5) > Why not "typeid(const(Object))" and "(const(Object)).classinfo" ? The existing code will evaluate to "const(TypeInfo)". Your suggestion evaluates to "TypeInfo_Const". I guess I could hard code "const(TypeInfo)", but then I need put the whole alias declaration in a string mixin. It's not like I don't know how work around the change. It broke my code so I reported an issue.
Comment #7 by schveiguy — 2015-10-13T17:11:53Z
(In reply to Jacob Carlborg from comment #6) > > The existing code will evaluate to "const(TypeInfo)". Your suggestion > evaluates to "TypeInfo_Const". I guess I could hard code "const(TypeInfo)", > but then I need put the whole alias declaration in a string mixin. OK, I see now. Honestly, I don't see this as a regression. TypeInfo was not meant to be instantiated by user code. The fact that it worked I don't think was intended, just an accident (The runtime obviously never instantiates a direct TypeInfo, it's always a subclass). I recommend employing a workaround and closing this bug.