Skip to content

Kotlin: cover 2.4.20 language features - #22462

Draft
andersfugmann wants to merge 10 commits into
andersfugmann/kotlin-2.4.20rcfrom
andersfugmann/kotlin-2.4.20-language-features
Draft

Kotlin: cover 2.4.20 language features#22462
andersfugmann wants to merge 10 commits into
andersfugmann/kotlin-2.4.20rcfrom
andersfugmann/kotlin-2.4.20-language-features

Conversation

@andersfugmann

Copy link
Copy Markdown
Contributor

Summary

Add focused extraction coverage for Kotlin 2.4.20 language constructs:

  • full multi-field value classes
  • short-form name-based destructuring
  • context parameters on functions and property accessors
  • collection literals
  • companion blocks and companion extensions
  • JVM 21 when generation using invokedynamic

The new constructs already lower to supported IR except for context parameters. Kotlin 2.4 represents these as IrParameterKind.Context, so the compatibility layer now extracts them as callable parameters and call arguments, with stable indices when extension receivers are present.

Callable references with context parameters are not covered because Kotlin 2.4.20-RC2 rejects them.

Compatibility

The extractor change is limited to the Kotlin 2.4 compatibility source set. Earlier compiler compatibility implementations are unchanged. The remaining changes are focused tests using compiler-version-specific feature flags.

Validation

  • Built all standalone and embeddable extractor variants
  • Ran representative receiver, property, and method extraction tests with Kotlin 2.3.20
  • Ran all 3,453 Kotlin 2 tests in four sequential shards
  • Confirmed that existing expected output is unchanged and no tests are disabled

Stack

This pull request is stacked on #22404 and should be reviewed after it.

andersfugmann and others added 10 commits August 28, 2026 14:15
Add focused coverage for an abstract value base class and a concrete
multi-field subclass with property overrides, inheritance, and a secondary
constructor.

The existing extractor represents these constructs correctly. This commit
adds coverage only and requires no extractor change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add focused coverage for short-form name-based destructuring where the
selected property is not the first declared field. Check the resolved getter
and data flow from the selected field to the destructured local.

The existing extractor selects the property by name correctly. This commit
adds coverage only and requires no extractor change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add regression coverage for context parameters on a function and an
extension-property getter. Record callable parameters and implicit call
arguments.

Without the follow-up fix, the test reports missing context parameters,
missing arguments, and database consistency errors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Treat Kotlin 2.4 IR context parameters as callable value parameters and map
member-access arguments using their parameter kinds instead of assuming that
all non-regular parameters form a prefix.

This restores context parameters and implicit arguments while preserving
dispatch and extension receiver handling. The change is confined to the
Kotlin 2.4 compatibility source set.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extend the context-parameter regression test to an extension-property setter.
Check the extension receiver, context argument, assigned value, and resolved
setter call.

The preceding extractor fix already handles this case correctly. This commit
adds coverage only and requires no additional extractor change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add focused coverage for a collection literal resolved through a companion
operator fun of. Check the call target, arguments, result type, locations,
and element data flow through the resulting collection.

The existing extractor handles the lowered call correctly. This commit adds
coverage only and requires no extractor change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add focused coverage for a companion-block function and companion extension
function and property. Check declaration ownership, property accessors,
resolved calls, and data flow.

The existing extractor handles the lowered declarations and calls correctly.
This commit adds coverage only and requires no extractor change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a JVM 21 regression test for when generation using invokedynamic. The
same expected source AST also passes with inline when generation.

The backend choice does not change the IR observed by the extractor. This
commit adds coverage only and requires no extractor change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the secondary constructor's Long conversion with a String overload.
This preserves coverage for non-trivial value-class construction without
exercising an unrelated primitive-conversion diagnostic.

This is a test-only refinement and does not change extractor behaviour.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Derive Kotlin 2.4 parameter indices from preceding context and regular
parameters while reserving the Java parameter slot for an extension receiver.

This removes negative context-parameter indices and prevents setter parameter
label collisions found by the consistency checks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@andersfugmann
andersfugmann force-pushed the andersfugmann/kotlin-2.4.20-language-features branch from 8eb2160 to 701a005 Compare August 28, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant