Skip to content

[JVM] Support callable references to contextualized declarations - #7639

Open
grechkovlad wants to merge 1 commit into
masterfrom
rr/vgrechko/ccr-3
Open

[JVM] Support callable references to contextualized declarations#7639
grechkovlad wants to merge 1 commit into
masterfrom
rr/vgrechko/ccr-3

Conversation

@grechkovlad

Copy link
Copy Markdown
Contributor
  • FunctionReferenceLowering passes the bound context arguments as additional context$N constructor parameters of the generated reference class, packs them into the boundContextArguments array, and reads them back in invoke via array accesses.
  • PropertyReferenceLowering calls the new (Mutable)PropertyReference{0,1}Impl constructors that take an Object[] contextArguments in front of the usual arguments.
  • PropertyReferenceDelegationLowering is generalized from a single optional bound receiver to a list of bound values: inlinable values (including casts of stable expressions) are re-evaluated on each accessor call, a non-trivial bound receiver is still cached in a field, and inlined values with possible class-initialization side effects are evaluated in an initializer block.
  • JvmStaticAnnotationLowering replaces only the last bound value (the receiver) with the object instance instead of clearing the whole boundValues list, preserving bound context arguments.

This commit does NOT include reflection support of contextualized callable reference.

^KT-86452: Fixed

- `FunctionReferenceLowering` passes the bound context arguments as
  additional `context$N` constructor parameters of the generated
  reference class, packs them into the `boundContextArguments` array,
  and reads them back in `invoke` via array accesses.
- `PropertyReferenceLowering` calls the new
  `(Mutable)PropertyReference{0,1}Impl` constructors that take an
  `Object[] contextArguments` in front of the usual arguments.
- `PropertyReferenceDelegationLowering` is generalized from a single
  optional bound receiver to a list of bound values: inlinable values
  (including casts of stable expressions) are re-evaluated on each
  accessor call, a non-trivial bound receiver is still cached in a
  field, and inlined values with possible class-initialization side
  effects are evaluated in an initializer block.
- `JvmStaticAnnotationLowering` replaces only the last bound value
  (the receiver) with the object instance instead of clearing the
  whole `boundValues` list, preserving bound context arguments.

This commit does NOT include reflection support of contextualized
callable reference.

^KT-86452: Fixed
@kotlin-safemerge

kotlin-safemerge Bot commented Aug 21, 2026

Copy link
Copy Markdown

Code Owners

RuleOwnersApproval
/​compiler/​ir/​backend.​jvm/​
kotlin-jvm

udalov
/​compiler/​testData/​codegen/​box/​, /​compiler/​testData/​ir/​irText/​
kotlin-compiler

udalov
PR commands for maintainers
CommandDescriptionParameters
/safe-mergeRebase-merges with automatic fixup commit squashing--fixup Autosquash fixup commits (on by default)
/safe-squash-mergeSquash-merges with optional commit title/body override--title Title of the squashed commit
--message Body of the squashed commit
/dry-runRuns the test pipeline with changes rebased on latest master--retry Retry the CI run on failure
/test-publicTriggers the public test suite without rebasing on latest master
/test-privateTriggers the private test suite without rebasing on latest master
/codeownersTriggers code owners check and comment update
/fixupSquashes fixup commits and force pushes the branch
/cancel-coordinatorCancels the merge coordinator currently running for this branch

@grechkovlad
grechkovlad marked this pull request as ready for review August 21, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant