Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Kotlin printer: apply for construct-then-configure sequences (#140 follow-up)

Abierto
#165 1 comentario 0 reacciones 0 asignados Ver en GitHub

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
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java, kotlin

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 argument size() or name that meant the enclosing class's would silently rebind.
    • An outer this must become this@Outer.
  • The local is not used afterwards except for the single return / assignment / argument the apply replaces, or it stays a val 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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CodeLaser/maddi

Todos los issues de CodeLaser/maddi

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.