K2: a secondary constructor's body is never converted
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
調査の方向性
Start in KotlinScan.finalizeType, where each constructor body is assembled as delegation call, parameter-property assignments, then planned init blocks, and look at how runsInitOf decides which constructor runs the init blocks. Then in maddi-kotlin-k2 find where the primary constructor's body is converted and mirror it for KtSecondaryConstructor.bodyBlockExpression, appending it after the current prefix. ConstructorParameterNamedAsPropertyTest deliberately avoids a secondary constructor with a body, so extend it (or add a sibling test) with the snippet from the issue and check that n reads as assigned. Done means a secondary constructor's own body statements appear in the CST after the delegation call and init blocks.
索引モデルが issue の本文から書いたものです。
説明
The K2 front-end never converts a secondary constructor's block body. Given
class Secondary {
val n: Int
constructor(n: Int) { this.n = n + 1 }
}
the constructor's CST body is empty. KotlinScan.finalizeType builds every constructor body as: the explicit this(..)/super(..) invocation, then the parameter-property assignments, then the init blocks planned for it. Nothing in maddi-kotlin-k2 reads KtSecondaryConstructor.bodyBlockExpression. Only the delegation call of a secondary constructor survives.
Consequence: the body's assignments, calls and modifications are invisible to the analysis. Above, n is never assigned. A field assigned only there looks unassigned, and a parameter modified only there looks unmodified. That is the unsafe direction.
What kotlinc does: a secondary constructor runs its delegation call; when that is super(..) (or implicit), it then runs the property initializers and init blocks. Its own body comes last. A body converted after the current prefix and planned init blocks matches that order (runsInitOf already picks the constructor that runs the init blocks).
Found while fixing the same-name parameter assignment (CodeLaser/maddi-mod#73). ConstructorParameterNamedAsPropertyTest avoids a secondary constructor with a body for that reason.
- 主要言語
- Java
- スター
- 1
- フォーク
- 1
- 平均マージ
- 1時間 55分
- マージ済み PR(30日)
- 8
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CodeLaser/maddi のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
CodeLaser/maddi#166 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
build/ci good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
Java printer: a nested type prints by simple name when the unit imports another type of that nameオープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 57/100
メンテナーはふだん 1 日以内に返信
CodeLaser/maddi の issue をすべて見る
似ている issue
-
priority: medium Review effort [1-5]: 3 status: needs-triage type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
carlos-emr/carlos#5431 ·
メンテナーはふだん 1 日以内に返信
-
Integration tests: jetty:run fails with WELD-001408 for CountryJpaService対応中かも @viniciusmachak が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
primefaces/primefaces#15431 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
OpenAPITools/openapi-generator#25454 ·
メンテナーはふだん 1 日以内に返信
-
Component - Build
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100