Commit b037b1e
Allow final class returns for
Summary:
Returning a concrete class instance from a method annotated with `Self` is normally unsafe because `Self` can represent a subclass. Final classes are the sound exception: there can be no subclass for `Self` to stand for.
This allows an exact final class instance to satisfy Self while keeping non-final concrete class returns rejected. The rule is intentionally narrow so the removed `ClassType` <: `SelfType` behavior does not come back for subclassable classes.
Reviewed By: yangdanny97
Differential Revision: D104711160
fbshipit-source-id: cfa0eabd89fa117419db4380c20637f278774d87Self
1 parent b69c0ac commit b037b1e
3 files changed
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2026 | 2026 | | |
2027 | 2027 | | |
2028 | 2028 | | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
2029 | 2034 | | |
2030 | 2035 | | |
2031 | 2036 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
212 | 228 | | |
213 | 229 | | |
214 | 230 | | |
| |||
0 commit comments