Consider using all-args constructor automatically when JSpecify is enabled

Aperta
#884 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@sjohnr ci sta già lavorando.

Dal 1/12/2025.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

enhancement

It would be nice to omit the default no-arg constructor and use the all-args constructor when JSpecify annotations are generated (see gh-866). This would allow linting and static analysis tools to consider the generated types fully null-safe with no warnings.

Context:

By default, a no-arg constructor is generated for all Java types. Currently, this constructor is generated as private when generating JSpecify annotations on Java types. The all-args constructor is still optional and the no-arg constructor is used in the generated builder's build() method. Static analysis and linting tools cannot see that the no-arg constructor is private, the builder's build() method validates fields, and the all-args constructor is null-safe. This issue is flagged by IntelliJ code intentions with the following message on fields of the generated type:

@NullMarked fields must be initialized 
Lingua principale
Kotlin
Stelle
220
Fork
123
Merge medio
1g 6h
PR unite (30g)
23

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Netflix/dgs-codegen

Tutte le issue di Netflix/dgs-codegen

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.