| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/ctor_attr.d(26): Error: none of the overloads of `this` can construct a mutable object with argument types `(int)` |
| 5 |
fail_compilation/ctor_attr.d(16): Candidates are: `ctor_attr.S.this(int x) const` |
| 6 |
fail_compilation/ctor_attr.d(18): `ctor_attr.S.this(string x)` |
| 7 |
fail_compilation/ctor_attr.d(17): `this()(int x) shared` |
| 8 |
fail_compilation/ctor_attr.d(28): Error: none of the overloads of `foo` are callable using a mutable object with argument types `(int)` |
| 9 |
fail_compilation/ctor_attr.d(20): Candidates are: `ctor_attr.S.foo(int x) immutable` |
| 10 |
fail_compilation/ctor_attr.d(21): `ctor_attr.S.foo(string x)` |
| 11 |
--- |
| 12 |
*/ |
| 13 |
|
| 14 |
struct S |
| 15 |
{ |
| 16 |
this(int x) const {} |
| 17 |
this()(int x) shared {} |
| 18 |
this(string x) {} |
| 19 |
|
| 20 |
void foo(int x) immutable {} |
| 21 |
void foo(string x) {} |
| 22 |
} |
| 23 |
|
| 24 |
void f() |
| 25 |
{ |
| 26 |
auto s = S(1); |
| 27 |
S t; |
| 28 |
t.foo(1); |
| 29 |
} |