mirror of
https://github.com/github/codeql.git
synced 2026-07-15 16:29:39 +02:00
Two compiler-synthesised value parameters that carry no source token of their
own were located differently by the K1 and K2 frontends:
- the `<set-?>` parameter of a delegated property's synthesised setter: K1
anchored it at the delegate expression (`delegates.kt:8:32:11:5`) while K2
spans the whole property declaration (`8:5:11:5`); and
- the `value` parameter of the synthetic enum `valueOf` member: K1 has no
offsets and emitted the null `0:0:0:0` location while K2 attributes it to
the enum-class declaration (`1:1:4:1`).
In both cases the parameter is synthesised, so the K2 span (the owning
declaration) is a real, navigable location and strictly more useful than either
the delegate-expression fragment or K1's null `0:0`. We therefore converge K1
onto the K2-native span, consistent with how the other synthesised members
(accessors, implicit constructors, super calls, `$delegate` fields) are already
being anchored on their owning declaration.
`getPsiBasedSyntheticParameterLocation` recovers the span from the PSI under K1
and returns null under K2 (where `getKtFile` is unavailable and the raw offsets
already carry the owning-declaration span) and for every ordinary, source-backed
parameter, so the canonical K2 output is untouched.
Relearn (both suites, CPUS=5): all 3333 tests pass. Only test-kotlin1 changes;
methods/parameters is now byte-identical across suites (6 -> 0 divergent rows),
and the same setter/valueOf parameter rows converge in the PrintAst/exprs
projections that reference them (annotation_classes/PrintAst 88->84,
classes/PrintAst 18->10, exprs/PrintAst 75->67, exprs/exprs 189->171,
exprs_typeaccess/PrintAst 9->5, methods/exprs 36->30). Every touched file's
divergence strictly decreases; no new divergence is introduced.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>