Commit edaa710
Kotlin: converge explicit
An explicit property setter written `set(_)` produces a value parameter
whose source spelling is the Kotlin discard placeholder `_`. The two
frontends model this differently:
* K2 preserves the source name and exposes the parameter as `_`.
* K1 additionally flags the parameter with
`IrDeclarationOrigin.UNDERSCORE_PARAMETER`, which the extractor treats
as a synthesized name (no name is written and QL synthesizes `p0`).
This made `test-kotlin1` report `p0` while `test-kotlin2` reported `_`
for the same source (library-tests/underscore-parameters).
The `UNDERSCORE_PARAMETER` origin is *also* set by K1 (and, for the
synthesized cases, by K2) on discarded parameters that do not retain a
`_` source spelling, most importantly:
* lambda placeholder parameters, e.g. `{ index, _ -> ... }`
* the synthesized `invoke` parameters of function types
(funcExprs.kt lines 27/30/31/90/94)
For those, the two frontends assign *different* internal names
(`<anonymous parameter N>` under K1 vs `<unused var>` under K2), so the
synthetic-name treatment is exactly what keeps them converged at `pN`.
Removing the origin check wholesale therefore replaces one small
divergence with a much larger one.
To converge only the case both frontends agree on, we suppress the
synthetic-name treatment only when the parameter's own name is exactly
`_` (the source discard spelling that both K1 and K2 preserve). This
makes K1 emit `_` for `set(_)` (matching K2) while leaving every other
discarded parameter synthetic in both suites.
Scope of the change (verified by a full dual-suite `--learn` with
database-consistency checks, all 3333 tests passing):
* test-kotlin1 library-tests/underscore-parameters: `p0` -> `_`
(now identical to test-kotlin2).
* test-kotlin2: byte-for-byte unchanged.
* No other expected file changes (lambda / function-type discard
parameters remain `pN` in both suites).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>_ setter parameter name onto K21 parent a376228 commit edaa710
2 files changed
Lines changed: 3 additions & 2 deletions
File tree
- java
- kotlin-extractor/src/main/kotlin
- ql/test-kotlin1/library-tests/underscore-parameters
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1365 | 1365 | | |
1366 | 1366 | | |
1367 | 1367 | | |
1368 | | - | |
| 1368 | + | |
| 1369 | + | |
1369 | 1370 | | |
1370 | 1371 | | |
1371 | 1372 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments