K2: scope functions still called rather than inlined (follow-up to #88)
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 28/100
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 { … })), awhenarm'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@labelto the literal inside a loop, awhenor 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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CodeLaser/maddi
-
build/ci good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 3/5 Half a day Newbie friendliness 62/100
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Java → C# translation: an idiomatic C# printer driven by the modification and nullability analysesOpenenhancement extension front-end:csharp
Difficulty 5/5 Over a week Newbie friendliness 8/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 40/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
utopia-rise/godot-jvm#1004 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
spring-projects/spring-grpc#442 ·
-
Expose numberOfPermits in RateLimiterEvent.toString() and the ratelimiterevents actuator DTOPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
resilience4j/resilience4j#2547 ·
Maintainers usually reply within 9 days
-
Clock.MakeDate continues execution and returns a rolled-over instant after dispatching error on invalid datePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 1/5 Under an hour Newbie friendliness 82/100
mit-cml/appinventor-sources#4155 ·
Maintainers usually reply within 1 day