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

K2: a @JvmField actual companion property, read from common code, is read through a getter it does not have

Chiusa
#96 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
32/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, kotlin
Ambito
compilers, tooling

Direzione di ricerca

Reproduce with the given commonMain/jvmMain expect/actual Listener.Factory.NONE fixture and compare the IR/access path to coil’s EventListener.Factory.NONE (nonAndroidMain) after the TestCoilJvmSlice fix. Trace where an expect companion property still synthesizes a getter instead of taking @JvmField/const from the actual (readAsField) and falling back to the enclosing interface’s static field. Done when common-code reads of the actual @JvmField companion use Listener.Factory.NONE with no getter.

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

Descrizione

A @JvmField actual companion property read from common code is read through a getter it does not have, in a minimal multiplatform fixture:

// commonMain
expect abstract class Listener {
    fun interface Factory {
        fun create(): Listener
        companion object { val NONE: Factory }
    }
}
class User { fun none(f: Listener.Factory?): Listener.Factory = f ?: Listener.Factory.NONE }

// jvmMain
actual abstract class Listener {
    actual fun interface Factory {
        actual fun create(): Listener
        actual companion object { @JvmField actual val NONE = Factory { object : Listener() {} } }
    }
}

User.none converts to return f==null?Factory.Companion.getNONE():f;. kotlinc compiles a @JvmField companion property to a public static field of the enclosing interface, with no getter, so the read should be the field Listener.Factory.NONE.

The same source shape in coil (EventListener.Factory.NONE, nonAndroidMain actual) took a different path: no getter was found there either, so it was a k2-unresolved-access:NONE placeholder. Since the fix for TestCoilJvmSlice, a companion with no getter for the name falls back to the enclosing class's static field, and coil reads the field. This fixture, however, still finds a getter, most likely one built from the expect companion's declaration, which has no @JvmField.

Likely direction: when an expect property has an actual, take @JvmField/const from the actual (readAsField), and do not synthesize accessors for an expect companion property whose actual is a @JvmField.

Lingua principale
Java
Stelle
1
Fork
1
Merge medio
1h 58m
PR unite (30g)
5

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.