Commit a17c88a
Kotlin: exclude the
For `class C : Intf by <expr>` the compiler synthesises a `$$delegate_0` field
that stores the delegate `<expr>`, so its natural location is that expression.
The two frontends disagreed on the field's own location:
- K1 records it at the delegate expression (`intfDelegate.kt:7:26:9:1`, the
`object : Intf { ... }`); while
- K2 records it from the delegated supertype, so it includes the `Intf by `
glue (`7:18:9:1`).
This is the interface-delegation analogue of the delegated-property `$delegate`
field, where we already adopted the delegate-expression span and excluded the
`by` keyword (it is syntactic glue, not part of the stored expression). We apply
the same principle here and converge K2 onto K1's narrower span.
`getClassDelegateFieldLocation` anchors a class-delegation field
(`IrDeclarationOrigin.DELEGATE`, which has no corresponding property and would
otherwise fall through to the raw IR offset) on its own initialiser expression.
It uses the initialiser's raw offsets, which are available under both frontends
(`7:26:9:1` in each), so it is frontend-stable: under K1 it reproduces the offset
already recorded (no change) and under K2 it trims the leading `Intf by `.
Relearn (both suites, CPUS=5): all 3333 tests pass. Only test-kotlin2 changes;
interface-delegate/test is now byte-identical across suites (2 -> 0 divergent
rows). No other file changes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>by keyword from an interface-delegation field location1 parent dc81b51 commit a17c88a
2 files changed
Lines changed: 26 additions & 1 deletion
File tree
- java
- kotlin-extractor/src/main/kotlin
- ql/test-kotlin2/library-tests/interface-delegate
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2679 | 2679 | | |
2680 | 2680 | | |
2681 | 2681 | | |
| 2682 | + | |
2682 | 2683 | | |
2683 | 2684 | | |
2684 | 2685 | | |
| |||
3559 | 3560 | | |
3560 | 3561 | | |
3561 | 3562 | | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
| 3571 | + | |
| 3572 | + | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
3562 | 3587 | | |
3563 | 3588 | | |
3564 | 3589 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
0 commit comments