| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/iconv_interface_array.d(48): Error: function `testA` is not callable using argument types `(C[4])` |
| 5 |
fail_compilation/iconv_interface_array.d(48): cannot pass argument `arr` of type `C[4]` to parameter `I1[4] arr` |
| 6 |
fail_compilation/iconv_interface_array.d(27): `iconv_interface_array.testA(I1[4] arr)` declared here |
| 7 |
fail_compilation/iconv_interface_array.d(49): Error: function `testB` is not callable using argument types `(C[4])` |
| 8 |
fail_compilation/iconv_interface_array.d(49): cannot pass argument `arr` of type `C[4]` to parameter `I2[4] arr` |
| 9 |
fail_compilation/iconv_interface_array.d(33): `iconv_interface_array.testB(I2[4] arr)` declared here |
| 10 |
fail_compilation/iconv_interface_array.d(50): Error: function `testC` is not callable using argument types `(C[4])` |
| 11 |
fail_compilation/iconv_interface_array.d(50): cannot pass argument `arr` of type `C[4]` to parameter `I3[4] arr` |
| 12 |
fail_compilation/iconv_interface_array.d(39): `iconv_interface_array.testC(I3[4] arr)` declared here |
| 13 |
--- |
| 14 |
*/ |
| 15 |
|
| 16 |
interface I1 { int a(int); } |
| 17 |
interface I2 { int b(int); } |
| 18 |
interface I3 { int c(int); } |
| 19 |
|
| 20 |
class C : I1, I2, I3 |
| 21 |
{ |
| 22 |
int a(int i) { return 1 * i; } |
| 23 |
int b(int i) { return 2 * i; } |
| 24 |
int c(int i) { return 3 * i; } |
| 25 |
} |
| 26 |
|
| 27 |
void testA(I1[4] arr) |
| 28 |
{ |
| 29 |
foreach (uint idx, obj; arr) |
| 30 |
assert(obj.a(idx) == 1 * idx); |
| 31 |
} |
| 32 |
|
| 33 |
void testB(I2[4] arr) |
| 34 |
{ |
| 35 |
foreach (idx, obj; arr) |
| 36 |
assert(obj.b(cast(int) idx) == 2 * idx); |
| 37 |
} |
| 38 |
|
| 39 |
void testC(I3[4] arr) |
| 40 |
{ |
| 41 |
foreach (idx, obj; arr) |
| 42 |
assert(obj.c(cast(int) idx) == 3 * idx); |
| 43 |
} |
| 44 |
|
| 45 |
void main() |
| 46 |
{ |
| 47 |
C[4] arr = [ new C, new C, new C, new C ]; |
| 48 |
testA(arr); |
| 49 |
testB(arr); |
| 50 |
testC(arr); |
| 51 |
} |