Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

K2: scope functions still called rather than inlined (follow-up to #88)

Open
#98 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
28/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
java, kotlin
Domain
compilers

Research direction

This is a follow-up to #88 on inlining Kotlin scope functions (apply/also/let/run/with/use) in the K2-related analysis. Read that issue and the listed remaining cases: lambdas in conditionals or argument position, function values instead of literals, labelled returns, and destructured parameters. Generalise value-to-statement lowering so inlining does not change evaluation order. Done when those sites are inlined and receiver mutations inside the body are visible on the receiver, matching the census intent.

Written by the indexing model from the issue text.

Description

After #88 (stages 1–3 and the control-flow elvis, local commits 154d99b83…429446994), apply/also/let/run/with/use are inlined wherever they sit on a statement's unconditionally evaluated spine, as a statement, or on the left of a control-flow elvis. What still stays a call, measured by a scratch census over the detekt and coil parses (site visits, some counted twice, so read these as relative sizes):

  • A literal lambda in a conditional or argument position (~96 on detekt, ~20 on coil): the arm of a null-safe conditional (a ?: b.also { … }, c?.x?.run { … } inside a larger expression), an argument (f(x.let { … })), a when arm's value. Inlining one moves an evaluation unless the enclosing expression is itself lowered to statements, so it needs the value-to-statement lowering generalised.
  • A function value instead of a literal (~46 on detekt, ~11 on coil): x?.let(this::extractRuleDocumentation), let(nonNullChecks::add), let(::RealEditor), apply(builder). Inlined, this is a direct call on the bound receiver (r.m(x), new C(x), f.invoke(x)).
  • A return@label to the literal inside a loop, a when or a nested lambda (0 on the three corpora): kept deliberately, since the analysis cannot merge a jump out of a block (see #88 stage 2).
  • A destructured lambda parameter.

Each still-called site loses exactly what #88 was about: a modification of the receiver inside the body is not carried back to it.

Dominant language
Java
Stars
1
Forks
1
Avg merge
2h 51m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CodeLaser/maddi

All issues in CodeLaser/maddi

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.