Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Java printer: drops the qualifier a call needs (explicit type arguments, a method named yield)

Aperta
#106 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
compilers

Direzione di ricerca

The bug is in the Java printer, reached via JavaInspector.print2 with Formatter2Impl; start by finding where method-call expressions are printed and how the qualifier is chosen. Reproduce with a round trip on the two snippets in the issue (explicit type arguments such as X.<T>empty(), and a method named yield called as this.yield(...)). Done means both snippets print with a qualifier and the output re-parses.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Problem

The Java printer drops the qualifier of a method call in two places where Java requires one. The printed source no longer compiles.

1. Explicit type arguments. Explicit type arguments need a qualifier (Type.<T>m(), this.<T>m(), super.<T>m()). The printer writes them bare, and <T> m() is a syntax error.

static <T> List<T> one(T t) { List<T> l = X.<T>empty(); ... }
<T> List<T> inst() { return this.<T>two(null); }

prints as

static <T> List<T> one(T t) { List<T> l = <T> empty(); ... }
<T> List<T> inst() { return <T> two(null); }

2. A method named yield. Since Java 14, an unqualified call to a method named yield is illegal ("invalid use of a restricted identifier 'yield'"). The printer drops the this.:

String callYield() { return this.yield("a"); }

prints as

String callYield() { return yield("a"); }

Expected

Keep (or write) a qualifier whenever the call has explicit type arguments, or the method is named yield. For a static method that's the type, and for an instance method it's this (or super, or the outer X.this as appropriate).

Seen on

A round trip (parse, then JavaInspector.print2 with Formatter2Impl) on maddi 0.9.5-alpha.5. On real code this is the most common reason a printed file fails to re-parse. In vavr it affects about 30 types, e.g. HashSet.<T>ofAll(elements), Promise.<T>make(executor), TreeMap.<K, V>empty(), and API's this.yield(Function.identity()).

Lingua principale
Java
Stelle
1
Fork
1
Merge medio
2h 51m
PR unite (30g)
3

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 CodeLaser/maddi

Tutte le issue di CodeLaser/maddi

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.