Bug 3346 – classinfo behaves like no other D entity
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2009-09-26T12:23:00Z
Last change time
2015-06-09T05:14:46Z
Assigned to
nobody
Creator
andrei
Comments
Comment #0 by andrei — 2009-09-26T12:23:47Z
Comment #1 by andrei — 2009-09-26T12:24:59Z
This code does not compile:
class A {
void fun() {
auto ci = classinfo;
}
}
But this does:
class A {
void fun() {
auto ci = this.classinfo;
}
}
And this does too:
class A {
void fun() {
auto ci = A.classinfo;
}
}
No other entity in D has these weird lookup rules.
Comment #2 by samukha — 2009-09-26T14:55:29Z
Also, 'outer':
class Outer
{
class Inner
{
this()
{
auto a = this.outer; //compiles
auto b = outer; //doesn't
}
}
}
Comment #3 by tomas — 2009-09-27T05:10:26Z
Should:
struct S
{
size_t foo()
{
return sizeof;
}
}
work too then?
As I see it .classinfo is a built in *property*, it's not a member!
Comment #4 by samukha — 2009-09-27T05:56:16Z
> work too then?
I think, yes.
Comment #5 by andrei — 2009-09-27T06:04:26Z
One additional thing about classinfo is that it is at the same time a static and a nonstatic property.
Comment #6 by samukha — 2009-09-27T08:48:56Z
Really. That explains why we cannot use 'classinfo' alone.
I think there should be 'classInfo' and 'staticClassInfo' (Qt's analogues are 'metaObject' and 'staticMetaObject'). Then no need to fix bug 3345. Also, we could avoid some extra pain when introspecting identically named methods.
Comment #7 by bugzilla — 2009-11-20T17:59:16Z
With the changes to typeid(), perhaps we can simply deprecate .classinfo
Comment #8 by bugzilla — 2009-12-06T01:18:22Z
exp.classinfo is deprecated now, use typeid(exp) instead. TypeInfo replaces ClassInfo.