mirror of
https://github.com/github/codeql.git
synced 2026-07-15 00:08:14 +02:00
The synthesised body of a delegated-property accessor (`get`/`getValue`/
`setValue`/`invoke` calls, the `<prop>$delegate` access, associated type
accesses and property-reference classes) carries the source range of the
whole `KtPropertyDelegate` node. The K1 frontend's range starts at the
`by` keyword; K2 starts at the delegate expression itself
(e.g. `lazy { ... }`), three columns later. The `by` keyword is syntactic
glue in the property declaration, not part of the expression being
evaluated, so K2's narrower range is the more intuitive one. Adopt it for
both frontends. Example:
get / getValue / invoke ... 6:24:9:9 -> 6:27:9:9
Add a scoped offset remap on `FileTrapWriter`: while extracting a
`DELEGATED_PROPERTY_ACCESSOR` body, any location whose offsets exactly
equal the `by`-inclusive delegate range is emitted with the delegate
expression's range instead. The range is recovered from the enclosing
`KtProperty`'s PSI (`delegate.expression`), which is available under K1;
under K2 there is no PSI so the remap is inactive and the raw offsets
already exclude `by`. Matching the full delegate range exactly means only
these synthesised body expressions are affected.
Updates test-kotlin1 expected only (test-kotlin2 unchanged).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
19 lines
1.8 KiB
Plaintext
19 lines
1.8 KiB
Plaintext
| dataClass.kt:1:21:1:47 | DataClass | dataClass.kt:1:1:1:47 | DataClass | file://:0:0:0:0 | void |
|
|
| delegates.kt:3:1:12:1 | MyClass | delegates.kt:3:1:12:1 | MyClass | file://:0:0:0:0 | void |
|
|
| delegates.kt:4:21:6:5 | | delegates.kt:4:21:6:5 | new KProperty1<MyClass,Integer>(...) { ... } | file://:0:0:0:0 | void |
|
|
| delegates.kt:4:26:6:5 | | delegates.kt:4:26:6:5 | new Function0<Integer>(...) { ... } | file://:0:0:0:0 | void |
|
|
| delegates.kt:8:35:11:5 | | delegates.kt:8:35:11:5 | new KMutableProperty1<MyClass,String>(...) { ... } | file://:0:0:0:0 | void |
|
|
| delegates.kt:8:35:11:5 | | delegates.kt:8:35:11:5 | new KMutableProperty1<MyClass,String>(...) { ... } | file://:0:0:0:0 | void |
|
|
| delegates.kt:8:66:11:5 | | delegates.kt:8:66:11:5 | new Function3<KProperty<?>,String,String,Unit>(...) { ... } | file://:0:0:0:0 | void |
|
|
| enumClass.kt:1:21:1:32 | EnumClass | enumClass.kt:1:1:4:1 | EnumClass | file://:0:0:0:0 | void |
|
|
| enumClass.kt:6:1:16:1 | EnumWithFunctions | enumClass.kt:6:1:16:1 | EnumWithFunctions | file://:0:0:0:0 | void |
|
|
| enumClass.kt:8:3:11:4 | VAL | enumClass.kt:8:3:11:4 | VAL | file://:0:0:0:0 | void |
|
|
| methods2.kt:7:1:10:1 | Class2 | methods2.kt:7:1:10:1 | Class2 | file://:0:0:0:0 | void |
|
|
| methods3.kt:5:1:7:1 | Class3 | methods3.kt:5:1:7:1 | Class3 | file://:0:0:0:0 | void |
|
|
| methods4.kt:3:1:11:1 | NestedTest | methods4.kt:3:1:11:1 | NestedTest | file://:0:0:0:0 | void |
|
|
| methods4.kt:5:3:9:3 | InsideNestedTest | methods4.kt:5:3:9:3 | InsideNestedTest | file://:0:0:0:0 | void |
|
|
| methods5.kt:5:3:5:27 | | methods5.kt:5:3:5:27 | | file://:0:0:0:0 | void |
|
|
| methods5.kt:9:3:9:32 | | methods5.kt:9:3:9:32 | | file://:0:0:0:0 | void |
|
|
| methods5.kt:13:1:13:14 | C1 | methods5.kt:13:1:13:14 | C1 | file://:0:0:0:0 | void |
|
|
| methods.kt:5:1:20:1 | Class | methods.kt:5:1:20:1 | Class | file://:0:0:0:0 | void |
|