Commit 1cc41a9
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 a576984 commit 1cc41a9
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 | |
|---|---|---|---|
| |||
7172 | 7172 | | |
7173 | 7173 | | |
7174 | 7174 | | |
7175 | | - | |
| 7175 | + | |
7176 | 7176 | | |
7177 | 7177 | | |
7178 | | - | |
| 7178 | + | |
| 7179 | + | |
7179 | 7180 | | |
7180 | 7181 | | |
7181 | 7182 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
942 | 942 | | |
943 | 943 | | |
944 | 944 | | |
| 945 | + | |
| 946 | + | |
945 | 947 | | |
946 | 948 | | |
947 | 949 | | |
948 | 950 | | |
949 | 951 | | |
950 | | - | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
951 | 959 | | |
952 | 960 | | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
959 | | - | |
960 | | - | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
961 | 965 | | |
962 | | - | |
| 966 | + | |
963 | 967 | | |
964 | | - | |
| 968 | + | |
| 969 | + | |
965 | 970 | | |
966 | 971 | | |
967 | 972 | | |
| |||
1022 | 1027 | | |
1023 | 1028 | | |
1024 | 1029 | | |
1025 | | - | |
| 1030 | + | |
| 1031 | + | |
1026 | 1032 | | |
1027 | 1033 | | |
1028 | 1034 | | |
| |||
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 | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
0 commit comments