| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/fail23151.d(30): Error: class `fail23151.makeDerivedObj.Derived` is nested within `makeDerivedObj`, but super class `Base` is nested within `makeBaseObj` |
| 5 |
--- |
| 6 |
*/ |
| 7 |
interface I |
| 8 |
{ |
| 9 |
void intfunc(int x); |
| 10 |
} |
| 11 |
|
| 12 |
auto makeBaseObj() |
| 13 |
{ |
| 14 |
int realPrivateX; |
| 15 |
class Base : I |
| 16 |
{ |
| 17 |
private int modulePrivateX; |
| 18 |
int publicX; |
| 19 |
override void intfunc(int x) |
| 20 |
{ |
| 21 |
realPrivateX++; // expected OK |
| 22 |
} |
| 23 |
} |
| 24 |
return new Base; |
| 25 |
} |
| 26 |
|
| 27 |
auto makeDerivedObj() |
| 28 |
{ |
| 29 |
int realPrivateY; |
| 30 |
class Derived : typeof(makeBaseObj()) |
| 31 |
{ |
| 32 |
private int modulePrivateY; |
| 33 |
int publicY; |
| 34 |
override void intfunc(int x) |
| 35 |
{ |
| 36 |
realPrivateX++; // expected NG |
| 37 |
modulePrivateX++; |
| 38 |
} |
| 39 |
} |
| 40 |
return new Derived; |
| 41 |
} |