Kotlin printer: apply for construct-then-configure sequences (#140 follow-up)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 45/100
Línea de trabajo
Start by reading the Kotlin printer and its CST name-resolution checks, then inspect how it represents construction, configuring calls, and the local’s final use. Implementing this rewrite requires preserving Kotlin name binding and the stated single-use cases. Measure apply counts and line counts on langchain4j and jenkins, and confirm compile counts stay unchanged across the five corpora.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Follow-up of #140 (idiom scorecard: apply 0 in langchain4j's output).
Today. The Kotlin printer never emits apply. also appears only as the mechanical .also { x = it } for Java's assignment as a value.
Shape (Java → Kotlin):
Config c = new Config();
c.setName(name);
c.setTimeout(30);
return c;
return Config().apply {
setName(name) // or name = name, once getX()/setX() print as properties
setTimeout(30)
}
The same holds where the last statement is an assignment this.config = c, or c is passed on once.
What decides it (corrected 2026-10-23, see the evaluation below):
- Every statement between construction and the last use calls a method on the new object, with arguments that do not mention it.
The new object does not escape before the last configuring call; that is the modification and independence analyses' job.Wrong:T().apply { a(); b() }runs the same calls in the same order as the Java statements, so escape changes nothing. The analyses do not decide this rewrite.- Name resolution, which the printer checks with the CST it already has:
- Inside the block, unqualified names resolve to
T's members first. An argumentsize()ornamethat meant the enclosing class's would silently rebind. - An outer
thismust becomethis@Outer.
- Inside the block, unqualified names resolve to
- The local is not used afterwards except for the single return / assignment / argument the
applyreplaces, or it stays aval x = T().apply { … }.
Not: with/run. They are taste, and a reviewer won't miss them.
Measure. apply count and line count on langchain4j and jenkins; compile counts unchanged across the five corpora.
🤖 Generated with Claude Code
- Lenguaje dominante
- Java
- Estrellas
- 1
- Forks
- 1
- Merge medio
- 1 h 34 min
- PR fusionados (30 d)
- 7
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de CodeLaser/maddi
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
CodeLaser/maddi#166 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
build/ci good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Java printer: a class literal in an annotation value prints by simple name, without an importAbiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Java printer: a static interface method called from an implementing class prints unqualifiedAbiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
Todos los issues de CodeLaser/maddi
Issues similares
-
code-maintenance
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
bug priority: medium Review effort [1-5]: 3 status: needs-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
carlos-emr/carlos#5258 ·
Los mantenedores suelen responder en 1 día
-
bug: author create/update with an unknown avatarId returns 404 instead of 400 UNKNOWN_REFERENCEPosiblemente ocupada @Vinu2111 la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
atomityhq/blog-cms#59 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
PlatformSpecific.hasGreenThreads incorrectly returns false for JDK updates and non-GA versionsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
dev/release: verify-release-candidate.sh runs 0 Java tests with Debian's MavenPosiblemente ocupada @kou la tomó hoy. AbiertoType: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/arrow-adbc#4947 ·
Los mantenedores suelen responder en 1 día