Bug 419 – Anonymous classes are not working.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2006-10-09T16:27:00Z
Last change time
2014-02-15T13:18:41Z
Assigned to
bugzilla
Creator
benoit

Comments

Comment #0 by benoit — 2006-10-09T16:27:31Z
interface I { void get( char[] s ); } class C{ void init(){ I i = new class() I { void get( char[] s ){ func(); // line 8 } }; } void func( ){ } } void main(){ } an.d(8): this for func needs to be type C not type void* See also: http://www.digitalmars.com/d/class.html#anonymous Doing that line I i = new class() { // without the "I" gives this nice message: an.d(8): this for func needs to be type C not type void* an.d(6): cannot implicitly convert expression ((class __anonclass1 : Object { void get(char[] s) { assert(this,"null this"); ((this.this).func)(); } void* this; } ) , new __anonclass1) of type an.C.init.__anonclass1 to an.I
Comment #1 by bugzilla — 2006-10-18T13:27:53Z
Fixed DMD 0.170
Comment #2 by thomas-dloop — 2006-10-21T08:40:35Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-10-09: > http://d.puremagic.com/issues/show_bug.cgi?id=419 > interface I { > void get( char[] s ); > } > class C{ > void init(){ > I i = new class() I { > void get( char[] s ){ > func(); // line 8 > } > }; > } > void func( ){ } > } > void main(){ > } > > an.d(8): this for func needs to be type C not type void* <snip> Added to DStress as http://dstress.kuehne.cn/run/t/this_13_A.d http://dstress.kuehne.cn/run/t/this_13_B.d http://dstress.kuehne.cn/run/t/this_13_C.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFOilNLK5blCcjpWoRAlSHAJ9JX/gND++RZtDGNNHFr19Cspo89ACfUAN1 wihuTFjMM92bs4sN6xviX50= =VZf2 -----END PGP SIGNATURE-----