Files
codeql/java/ql/test-kotlin2
Anders Fugmann 5626a5d897 Kotlin: locate generated data-class copy params at their property
A data class's generated `copy(...)` has one value parameter per
primary-constructor property. The K1 frontend records each such
parameter (and its type accesses) at the source location of the
corresponding property; the K2 frontend leaves them with undefined
offsets, which the extractor emits as a `0:0:0:0` location.

This divergence is purely a K2 information regression: the richer K1
location is unambiguously better (it points at the real property in
source, enabling location-based queries), so we converge K2 onto K1
rather than the other way around.

Because K2 exposes no PSI back-mapping, the location cannot be
recomputed from source; instead we recover it from the IR. For a value
parameter of a `GENERATED_DATA_CLASS_MEMBER` function whose own offsets
are undefined, we look up the primary-constructor parameter at the same
index and reuse its location.

Guards keep the change surgical:
  - `vp.startOffset >= 0` bails out, so K1 (which already has real
    offsets) is untouched.
  - the origin must be `GENERATED_DATA_CLASS_MEMBER`.
  - the primary-ctor parameter name must match and carry real offsets,
    which restricts the remap to `copy`-style parameters and excludes
    members such as `equals(other)`.

Relearned both suites: only data-class `copy` parameter rows change
(K2 now matches K1). data-classes/PrintAst.expected becomes byte
-identical across suites; the residual diffs in methods/{exprs,
parameters}.expected are pre-existing, unrelated divergences.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-12 15:18:10 +02:00
..
2026-06-11 23:40:14 +02:00