Commit 52e3031
committed
Sema: Fancier handling of associated type defaults
Consider this code:
protocol P {
associatedtype A
...
}
protocol Q: P {
associatedtype A = Int
...
}
struct S: Q {
...
}
If we check the [S: Q] conformance first, we get the right type witness
assignment, but if we check [S: P] first, conformance checking fails.
Instead of looking at an associated type declaration and any associated
types that it overrides, we now look through all associated types with the
same name among the protocols the adoptee conforms to. This allows us to
find the default assignment 'A = Int' from Q regardless of request
evaluation order.
Fixes rdar://problem/119052782.1 parent 948417f commit 52e3031
File tree
5 files changed
+46
-19
lines changed- lib/Sema
- test/decl/protocol/req
5 files changed
+46
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7253 | 7253 | | |
7254 | 7254 | | |
7255 | 7255 | | |
7256 | | - | |
| 7256 | + | |
7257 | 7257 | | |
7258 | 7258 | | |
7259 | | - | |
| 7259 | + | |
| 7260 | + | |
7260 | 7261 | | |
7261 | 7262 | | |
7262 | 7263 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1271 | 1271 | | |
1272 | 1272 | | |
1273 | 1273 | | |
1274 | | - | |
| 1274 | + | |
| 1275 | + | |
1275 | 1276 | | |
1276 | 1277 | | |
1277 | 1278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
919 | 919 | | |
920 | 920 | | |
921 | 921 | | |
| 922 | + | |
| 923 | + | |
922 | 924 | | |
923 | 925 | | |
924 | 926 | | |
925 | 927 | | |
926 | 928 | | |
927 | | - | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
928 | 936 | | |
929 | 937 | | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
938 | 942 | | |
939 | | - | |
| 943 | + | |
940 | 944 | | |
941 | | - | |
| 945 | + | |
| 946 | + | |
942 | 947 | | |
943 | 948 | | |
944 | 949 | | |
| |||
999 | 1004 | | |
1000 | 1005 | | |
1001 | 1006 | | |
1002 | | - | |
| 1007 | + | |
| 1008 | + | |
1003 | 1009 | | |
1004 | 1010 | | |
1005 | 1011 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
0 commit comments