dmd/compiler/test/compilable/test5973.d
Dennis 307be0b328
Merge stable (#15429)
* druntime: Restrict some `pragma(inline, false)` kludges to DMD only

They appear related to DMD's inlining at the AST level; LDC at least
doesn't need them, so let the optimizer decide for non-DMD backends.

* Fix little C++ header regression

* Expose VarArg.KRvariadic to C++ headers

* Revert "Deprecate alias this for classes v2 (#14812)" (#15326)

This reverts commit af7817b4ae.

* Add changelog for catch qualifier deprecation & update release no

---------

Co-authored-by: Martin Kinkelin <noone@nowhere.com>
Co-authored-by: Walter Bright <WalterBright@users.noreply.github.com>
Co-authored-by: Nick Treleaven <ntrel002@gmail.com>
2023-07-18 10:55:05 +02:00

41 lines
573 B
D

// https://issues.dlang.org/show_bug.cgi?id=5973
class A { int a = 1; }
class B { int b = 2; }
class C : A
{
B obj;
alias obj this;
this(){ obj = new B(); }
}
class X : C {}
class D
{
int i;
}
class E
{
D x;
alias x this;
}
class F : E
{
void test()
{
i = 5;
}
}
void main()
{
auto c = new C();
assert(c.a == 1); // lookup C -> A, OK
assert(c.b == 2); // lookup C => B, OK
auto x = new X();
assert(x.a == 1); // lookup X -> C -> A, OK
assert(x.b == 2); // lookup X -> C => B, NG (Line 17)
}