| 1 |
/+ |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/testOpApply.d(27): Error: `testOpApply.SameAttr.opApply` called with argument types `(int delegate(int i) pure nothrow @nogc @safe)` matches multiple overloads after qualifier conversion: |
| 5 |
fail_compilation/testOpApply.d(13): `testOpApply.SameAttr.opApply(int delegate(int) @system dg)` |
| 6 |
and: |
| 7 |
fail_compilation/testOpApply.d(18): `testOpApply.SameAttr.opApply(int delegate(int) @system dg)` |
| 8 |
--- |
| 9 |
+/ |
| 10 |
|
| 11 |
struct SameAttr |
| 12 |
{ |
| 13 |
int opApply(int delegate(int) @system dg) @system |
| 14 |
{ |
| 15 |
return 0; |
| 16 |
} |
| 17 |
|
| 18 |
int opApply(int delegate(int) @system dg) @safe |
| 19 |
{ |
| 20 |
return 0; |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
void testSameAttr() @safe |
| 25 |
{ |
| 26 |
SameAttr sa; |
| 27 |
foreach (int i; sa) {} |
| 28 |
} |
| 29 |
|
| 30 |
/+ |
| 31 |
TEST_OUTPUT: |
| 32 |
--- |
| 33 |
fail_compilation/testOpApply.d(104): Error: `testOpApply.SameAttr.opApply` called with argument types `(int delegate(int i) pure nothrow @nogc @system)` matches multiple overloads after qualifier conversion: |
| 34 |
fail_compilation/testOpApply.d(13): `testOpApply.SameAttr.opApply(int delegate(int) @system dg)` |
| 35 |
and: |
| 36 |
fail_compilation/testOpApply.d(18): `testOpApply.SameAttr.opApply(int delegate(int) @system dg)` |
| 37 |
--- |
| 38 |
+/ |
| 39 |
#line 100 |
| 40 |
|
| 41 |
void testSameAttr() @system |
| 42 |
{ |
| 43 |
SameAttr sa; |
| 44 |
foreach (int i; sa) {} |
| 45 |
} |
| 46 |
|
| 47 |
/+ |
| 48 |
TEST_OUTPUT: |
| 49 |
--- |
| 50 |
fail_compilation/testOpApply.d(217): Error: `sa.opApply` matches more than one declaration: |
| 51 |
fail_compilation/testOpApply.d(203): `int(int delegate(int) dg)` |
| 52 |
and: |
| 53 |
fail_compilation/testOpApply.d(208): `int(int delegate(string) dg)` |
| 54 |
fail_compilation/testOpApply.d(217): Error: cannot uniquely infer `foreach` argument types |
| 55 |
--- |
| 56 |
+/ |
| 57 |
#line 200 |
| 58 |
|
| 59 |
struct DifferentTypes |
| 60 |
{ |
| 61 |
int opApply(int delegate(int) dg) |
| 62 |
{ |
| 63 |
return 0; |
| 64 |
} |
| 65 |
|
| 66 |
int opApply(int delegate(string) dg) |
| 67 |
{ |
| 68 |
return 0; |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
void testDifferentTypes() |
| 73 |
{ |
| 74 |
DifferentTypes sa; |
| 75 |
foreach (i; sa) {} |
| 76 |
} |
| 77 |
|
| 78 |
/+ |
| 79 |
TEST_OUTPUT: |
| 80 |
--- |
| 81 |
fail_compilation/testOpApply.d(317): Error: `sa.opApply` matches more than one declaration: |
| 82 |
fail_compilation/testOpApply.d(303): `int(int delegate(int) dg)` |
| 83 |
and: |
| 84 |
fail_compilation/testOpApply.d(308): `int(int delegate(long) dg)` |
| 85 |
fail_compilation/testOpApply.d(317): Error: cannot uniquely infer `foreach` argument types |
| 86 |
--- |
| 87 |
+/ |
| 88 |
#line 300 |
| 89 |
|
| 90 |
struct CovariantTypes |
| 91 |
{ |
| 92 |
int opApply(int delegate(int) dg) |
| 93 |
{ |
| 94 |
return 0; |
| 95 |
} |
| 96 |
|
| 97 |
int opApply(int delegate(long) dg) |
| 98 |
{ |
| 99 |
return 0; |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
void testCovariantTypes() |
| 104 |
{ |
| 105 |
CovariantTypes sa; |
| 106 |
foreach (i; sa) {} |
| 107 |
} |
| 108 |
|
| 109 |
/+ |
| 110 |
See https://issues.dlang.org/show_bug.cgi?id=21683 |
| 111 |
|
| 112 |
TEST_OUTPUT: |
| 113 |
--- |
| 114 |
fail_compilation/testOpApply.d(420): Error: `sa.opApply` matches more than one declaration: |
| 115 |
fail_compilation/testOpApply.d(404): `int(int delegate(int) dg)` |
| 116 |
and: |
| 117 |
fail_compilation/testOpApply.d(410): `int(int delegate(ref int) dg)` |
| 118 |
fail_compilation/testOpApply.d(420): Error: cannot uniquely infer `foreach` argument types |
| 119 |
--- |
| 120 |
+/ |
| 121 |
#line 400 |
| 122 |
|
| 123 |
struct DifferentQualifiers |
| 124 |
{ |
| 125 |
int x; |
| 126 |
int opApply(int delegate(int) dg) |
| 127 |
{ |
| 128 |
x = 1; |
| 129 |
return 0; |
| 130 |
} |
| 131 |
|
| 132 |
int opApply(int delegate(ref int) dg) |
| 133 |
{ |
| 134 |
x = 2; |
| 135 |
return 0; |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
void testDifferentQualifiers() |
| 140 |
{ |
| 141 |
DifferentQualifiers sa; |
| 142 |
foreach (i; sa) {} |
| 143 |
} |
| 144 |
|
| 145 |
/+ |
| 146 |
TEST_OUTPUT: |
| 147 |
--- |
| 148 |
fail_compilation/testOpApply.d(504): Error: `sa.opApply` matches more than one declaration: |
| 149 |
fail_compilation/testOpApply.d(404): `int(int delegate(int) dg)` |
| 150 |
and: |
| 151 |
fail_compilation/testOpApply.d(410): `int(int delegate(ref int) dg)` |
| 152 |
fail_compilation/testOpApply.d(504): Error: cannot uniquely infer `foreach` argument types |
| 153 |
--- |
| 154 |
+/ |
| 155 |
#line 500 |
| 156 |
|
| 157 |
void testDifferentQualifiersRef() |
| 158 |
{ |
| 159 |
DifferentQualifiers sa; |
| 160 |
foreach (ref i; sa) {} |
| 161 |
} |