Kotlin: cover 2.4.20 language features - #22462
Draft
andersfugmann wants to merge 18 commits into
Draft
Conversation
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
force-pushed
the
andersfugmann/kotlin-2.4.20-language-features
branch
from
August 28, 2026 14:09
8eb2160 to
701a005
Compare
Run the full multi-field value class fixture only with Kotlin 2.4.20-RC2 or later in K2 mode. Earlier supported compilers reject the tested syntax even with the FullValueClasses language feature enabled.\n\nThis is coverage metadata only. Existing extraction remains correct and no extractor change is required.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run the short-form name-based destructuring fixture only with Kotlin 2.4.20-RC2 or later in K2 mode. Earlier supported compilers reject the tested combination of full value classes and name-based destructuring options.\n\nThis is coverage metadata only. Existing extraction remains correct and no extractor change is required.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run the function, getter, and setter context-parameter fixture from Kotlin 2.2.20-Beta2 onwards in K2 mode. This is the earliest supported compiler that accepts the exact fixture with -Xcontext-parameters.\n\nThe wider gate makes the existing regression test applicable to earlier compilers so their extraction behaviour can be assessed rather than assuming the fix is specific to Kotlin 2.4.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run the custom collection literal fixture from Kotlin 2.4.0 onwards in K2 mode. Earlier supported compilers reject the tested CollectionLiterals language feature.\n\nThis is coverage metadata only. Existing extraction remains correct and no extractor change is required.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run the companion block and companion extension fixture only with Kotlin 2.4.20-RC2 or later in K2 mode. Earlier supported compilers reject -Xcompanion-blocks-and-extensions.\n\nThis is coverage metadata only. Existing extraction remains correct and no extractor change is required.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run the invokedynamic when-expression fixture from Kotlin 2.2.20-Beta2 onwards in K2 mode, and require Java 21 for its configured JVM target. Earlier supported compilers reject the tested backend option.\n\nThis is coverage metadata only. Existing source-level extraction remains correct and no extractor change is required.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the unified parameter and argument layout introduced in Kotlin 2.2.20-Beta2 so context parameters and their implicit call arguments are included before the old accessors disappear in Kotlin 2.4.\n\nAssign parameter indices after excluding receiver slots, and give compiler-generated context arguments a stable whole-file location when the earlier compiler supplies inconsistent offsets. This fixes the version-gated function, getter, and setter regression test without changing its expected output. Earlier compilers retain the legacy compatibility implementation because they do not accept the tested context-parameter syntax.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the shared whole-file location for implicit context arguments across Kotlin 2.2.20-Beta2 through 2.4.20-RC2. Kotlin 2.3.20 reports broad source ranges for these generated reads while other versions report synthetic offsets, although the extracted argument semantics are identical.\n\nNormalising only implicit arguments to context parameters keeps one focused expected result across supported compilers without weakening the assertions or changing unrelated expression locations.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add focused extraction coverage for Kotlin 2.4.20 language constructs:
whengeneration usinginvokedynamicThe new constructs already lower to supported IR except for context parameters. Kotlin 2.2.20-Beta2 introduced the unified parameter and argument layout used by context parameters, so the compatibility layer now extracts them as callable parameters and call arguments from that compiler onwards.
Callable references with context parameters are not covered because Kotlin 2.4.20-RC2 rejects them.
Compatibility
Test metadata records the first supported compiler and required language mode for each fixture:
whenusinginvokedynamicImplicit context argument locations are normalised because supported compiler versions represent these generated reads differently. Other expression locations are unchanged.
Validation
Stack
This pull request is stacked on #22404 and should be reviewed after it.