Commit 82c43a8
authored
[Dynamic Casting] Allow casts to "more optional" types (swiftlang#33684)
Generally, casting consistency demands that we be able
to extract anything from an existential that can be put
into that existential. (Which is why the casting spec
requires that casting permit arbitrary injection and
projection of optionals.)
This particular diagnostic prevented optionals from being
projected back out of existentials:
let i: Int?
let a: Any = i // Inject Int? into Any
// Error prevents projecting Int? back out of Any
a as? Int?
This also broke certain uses of Mirror (weak variables get reflected as
optionals stored in Any existentials).1 parent 8d5ff75 commit 82c43a8
File tree
6 files changed
+21
-30
lines changed- include/swift/AST
- lib/Sema
- test
- Constraints
- expr/cast
6 files changed
+21
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1045 | 1045 | | |
1046 | 1046 | | |
1047 | 1047 | | |
1048 | | - | |
1049 | | - | |
1050 | | - | |
1051 | 1048 | | |
1052 | 1049 | | |
1053 | 1050 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3790 | 3790 | | |
3791 | 3791 | | |
3792 | 3792 | | |
3793 | | - | |
3794 | | - | |
| 3793 | + | |
| 3794 | + | |
| 3795 | + | |
3795 | 3796 | | |
3796 | 3797 | | |
3797 | 3798 | | |
3798 | 3799 | | |
3799 | 3800 | | |
3800 | | - | |
3801 | | - | |
3802 | | - | |
3803 | | - | |
3804 | 3801 | | |
3805 | 3802 | | |
3806 | 3803 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3167 | 3167 | | |
3168 | 3168 | | |
3169 | 3169 | | |
3170 | | - | |
3171 | | - | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
| 3173 | + | |
3172 | 3174 | | |
3173 | | - | |
3174 | | - | |
3175 | | - | |
3176 | 3175 | | |
3177 | 3176 | | |
3178 | | - | |
3179 | | - | |
3180 | | - | |
3181 | | - | |
3182 | | - | |
3183 | | - | |
3184 | | - | |
| 3177 | + | |
3185 | 3178 | | |
3186 | 3179 | | |
3187 | 3180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
| 67 | + | |
70 | 68 | | |
71 | 69 | | |
72 | 70 | | |
73 | 71 | | |
74 | 72 | | |
75 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
72 | 73 | | |
73 | | - | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
0 commit comments