Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

クローズ
#96 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
32/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java, kotlin
領域
compilers, tooling

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Java
スター
1
フォーク
1
平均マージ
1時間 55分
マージ済み PR(30日)
8

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CodeLaser/maddi のほかの issue

CodeLaser/maddi の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。