Kotlin printer: ?.let for null-guarded uses of a value (#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
- 40/100
Línea de trabajo
Start by reading the Kotlin printer and the KotlinNullCheckShapes pattern matching mentioned in the issue, then trace how modification analysis determines whether a getter call is side-effect free. Implement the listed null-guard shapes while retaining smart casts for stable locals and parameters. Check the reported ?.let, !!, and ?. counts on langchain4j and fernflower, and confirm compile counts remain unchanged across jenkins, guava, langchain4j, fernflower, and timefold.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Follow-up of #140 (idiom scorecard: .let 0 in langchain4j's output).
Today. The Kotlin printer never emits let. A null-guarded use of a value prints as a smart cast where the value is a local or a parameter, or as !! where it is a getter call or a field, which Kotlin cannot smart-cast.
Shapes (Java → Kotlin):
| Java | Kotlin |
|---|---|
x != null ? f(x) : null |
x?.let { f(it) } |
x != null ? f(x) : d |
x?.let { f(it) } ?: d |
if (getX() != null) use(getX()); (same pure getter) |
getX()?.let { use(it) } |
T v = getX(); if (v != null) { … v … } (v not used after) |
getX()?.let { v -> … } |
Why with #140's item 1. It shares the null-check pattern matching of ?./?: derived from Java's null checks (KotlinNullCheckShapes). It targets part of the !! count: the repeated nullable getter calls are about 100 of fernflower's 2,859 !! (corrected 2026-10-23, see the evaluation below; the first version called them the main source).
What decides it.
- The getter must be the same call and side-effect free between the test and the use: the modification analysis says so; a syntactic translator cannot.
Not where the block returns from the enclosing function, or breaks/continues a loop.Corrected:letis inline, so a non-localreturnis allowed inside it, and Kotlin 2.2+ allowsbreak/continuethere too.- Keep the plain smart cast where the value is a stable local or parameter:
if (x != null) use(x)is already idiomatic.
Measure. Counts of ?.let, !! and ?. on langchain4j and fernflower before and after; compile counts unchanged across jenkins, guava, langchain4j, fernflower and timefold.
🤖 Generated with Claude Code
- Lenguaje dominante
- Java
- Estrellas
- 1
- Forks
- 1
- Merge medio
- 1 h 13 min
- PR fusionados (30 d)
- 6
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
-
Javadoc warnings are the only noise on an otherwise clean CI runPosiblemente ocupada @jayeshamundkar06-bit la tomó hace 3 días. Abiertobuild/ci good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
CodeLaser/maddi#4 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
front-end:csharp
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 61/100
CodeLaser/maddi#185 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 14/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de CodeLaser/maddi
Issues similares
-
account bug exercise lecture programming user interface
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ls1intum/Artemis#14512 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
swiftlang/swift-java#955 ·
Los mantenedores suelen responder en 1 día
-
Good First Issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
hiero-ledger/hiero-sdk-java#3044 ·
Los mantenedores suelen responder en 1 día
-
A second build without clean fails in resources-optimizer-maven-plugin because minified files are minified againPosiblemente ocupada @papegaaij la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
hermes-queue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
chrisalunlloyd2-sudo/mindpalace#337 ·
Los mantenedores suelen responder en 1 día