Commit 3ae11ab
authored
Fix issue with static
Previously, inherited methods, even if accessed via static objects, were
not able to be used in quotations, unless explicitly pointed to with a
non-`this` prefix. This was due to the fact that during the cross-stage
safety check, first the method itself was checked for if it was static
(which for the inherited method, it was not), and if not, the prefix was
checked further, erroring on any `this` tree found along the way.
This was fixed by allowing `this` trees if they point to static objects.
This way not only is the initial issue fixed, but also we are able to
freely reference static methods with `this`, like `'{this.objectMethod}`
(whereas previously, only `'{Object.objectMethod}` or `'{objectMethod}`
were allowed, despite them all pointing to the same static method).
Fixes #22592this references erroring in quoted code (#22618)File tree
3 files changed
+38
-1
lines changed- compiler/src/dotty/tools/dotc/staging
- tests
- neg
- pos
3 files changed
+38
-1
lines changedLines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
206 | 212 | | |
207 | 213 | | |
208 | 214 | | |
209 | 215 | | |
210 | 216 | | |
| 217 | + | |
| 218 | + | |
211 | 219 | | |
212 | 220 | | |
213 | 221 | | |
214 | 222 | | |
215 | 223 | | |
216 | 224 | | |
217 | 225 | | |
218 | | - | |
| 226 | + | |
219 | 227 | | |
220 | 228 | | |
221 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 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 | + | |
0 commit comments