Inline Method leaves unqualified instance method call inside local class when inlining into static context
まだ誰も着手していません。
評価
調査の方向性
Inline Method の実装から始め、I01 の例を使って問題を再現します。static な main コンテキストに移動されたローカルクラスに焦点を当ててください。元の obj.f() のレシーバーが H.g() 内でどのように扱われるかを追跡します。生成された helper() 呼び出しがレシーバーで修飾され、リファクタリング後の Java コードがコンパイルできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Description
Inline Method produces uncompilable code when inlining an instance method that contains a local class into the static method main.
Before refactoring, the local class H is declared inside the instance method f(). The call helper() inside H.g() is valid because it is implicitly bound to the enclosing I01 instance.
After applying Inline Method to the invocation obj.f(), the local class H is moved into the static method main. However, the call inside H.g() remains:
return helper();
At this point, there is no implicit I01.this available in the static context. The call should be qualified with the original receiver, for example:
return obj.helper();
The refactored code no longer compiles.
Code before refactoring
public class I01 {
public static void main(String[] args) {
I01 obj = new I01();
// Refactoring operation: Inline Method
// Target invocation: obj.f()
int result = obj.f();
System.out.println(result);
}
int helper() {
return 7;
}
int f() {
class H {
int g() {
return helper();
}
}
return H.class.getSimpleName().length();
}
}
Code after refactoring
public class I01 {
public static void main(String[] args) {
I01 obj = new I01();
class H {
int g() {
return helper();
}
}
// Refactoring operation: Inline Method
// Target invocation: obj.f()
int result = H.class.getSimpleName().length();
System.out.println(result);
}
int helper() {
return 7;
}
int f() {
class H {
int g() {
return helper();
}
}
return H.class.getSimpleName().length();
}
}
- 主要言語
- TypeScript
- スター
- 2.3k
- フォーク
- 547
- 平均マージ
- 20時間 9分
- マージ済み PR(30日)
- 10
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
redhat-developer/vscode-java のほかの issue
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
redhat-developer/vscode-java#4509 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
redhat-developer/vscode-java#4426 ·
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
redhat-developer/vscode-java#4506 · コメント 3 件 · リアクション 4 件 ·
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
redhat-developer/vscode-java#4505 · コメント 2 件 · リアクション 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
redhat-developer/vscode-java#4504 · コメント 3 件 · リアクション 1 件 ·
redhat-developer/vscode-java の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
bug v2
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
modelcontextprotocol/inspector#2458 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
railmapgen/rmp-gallery#4068 ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
carbon-design-system/ibm-products#9907 ·