refactor(phase82): DRY化 - Case判定ロジックをヘルパー関数に統一
### リファクタ内容 - 2箇所の callsite で重複していた Case 判定ロジックを統一化 - classify_phi_fallback_case() ヘルパー関数を追加 ### 変更前(重複) - Callsite 1: L321-328 で Case 判定(9行) - Callsite 2: L378-385 で Case 判定(9行) - 完全に同一のロジックが重複 ### 変更後(DRY) - classify_phi_fallback_case() ヘルパー関数(14行) - 各 callsite は 1 行の呼び出しのみ ### メリット - ✅ DRY原則: ロジック重複削減 - ✅ 保守性: Case 分類変更が 1 箇所で完結 - ✅ テスト: ヘルパー関数単独でテスト可能 - ✅ 可読性: panic 処理が簡潔に ### 動作確認 - ビルド成功(warning のみ、既存のもの) - テスト結果: 482 PASS, 34 FAIL(既存の失敗のみ) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -42,6 +42,27 @@ use crate::mir::join_ir::lowering::type_hint_policy::TypeHintPolicy;
|
||||
// Phase 67: P3-C ジェネリック型推論箱
|
||||
use crate::mir::join_ir::lowering::generic_type_resolver::GenericTypeResolver;
|
||||
|
||||
// Phase 82: dev ガード用ヘルパー - Case 分類ロジック統一化
|
||||
//
|
||||
// infer_type_from_phi_with_hint() の 2 つの callsite で重複していた
|
||||
// Case 判定ロジックを DRY 化。
|
||||
//
|
||||
// Case 分類:
|
||||
// - Case A: hint 付き(GenericTypeResolver 不要)
|
||||
// - Case B: P1/P2/P3-A/B で hint 失敗(理論上不可)
|
||||
// - Case D: P3-C で GenericTypeResolver 失敗(PHI 走査フォールバック)
|
||||
//
|
||||
// Note: dev フラグで制御されるので、#[cfg] は不要(環境変数で制御)
|
||||
fn classify_phi_fallback_case(hint: Option<&MirType>, function_name: &str) -> &'static str {
|
||||
if hint.is_some() {
|
||||
"Case A (hint付き)"
|
||||
} else if TypeHintPolicy::is_target(function_name) {
|
||||
"Case B (P1/P2/P3-A/B hint失敗)"
|
||||
} else {
|
||||
"Case D (P3-C GenericTypeResolver失敗)"
|
||||
}
|
||||
}
|
||||
|
||||
impl super::MirBuilder {
|
||||
/// Unified declaration indexing (Phase A): collect symbols before lowering
|
||||
/// - user_defined_boxes: non-static Box names (for NewBox birth() skip)
|
||||
@ -319,13 +340,8 @@ impl super::MirBuilder {
|
||||
}
|
||||
// Phase 82: dev ガード - if_phi フォールバック禁止モード
|
||||
if crate::config::env::phi_fallback_disabled() {
|
||||
let case = if hint.is_some() {
|
||||
"Case A (hint付き)"
|
||||
} else if TypeHintPolicy::is_target(&function.signature.name) {
|
||||
"Case B (P1/P2/P3-A/B hint失敗)"
|
||||
} else {
|
||||
"Case D (P3-C GenericTypeResolver失敗)"
|
||||
};
|
||||
let case =
|
||||
classify_phi_fallback_case(hint.as_ref(), &function.signature.name);
|
||||
panic!(
|
||||
"[phase82/phi_fallback] disabled but infer_type_from_phi called\n\
|
||||
Function: {}\n\
|
||||
@ -376,13 +392,8 @@ impl super::MirBuilder {
|
||||
}
|
||||
// Phase 82: dev ガード - if_phi フォールバック禁止モード
|
||||
if crate::config::env::phi_fallback_disabled() {
|
||||
let case = if hint.is_some() {
|
||||
"Case A (hint付き)"
|
||||
} else if TypeHintPolicy::is_target(&function.signature.name) {
|
||||
"Case B (P1/P2/P3-A/B hint失敗)"
|
||||
} else {
|
||||
"Case D (P3-C GenericTypeResolver失敗)"
|
||||
};
|
||||
let case =
|
||||
classify_phi_fallback_case(hint.as_ref(), &function.signature.name);
|
||||
panic!(
|
||||
"[phase82/phi_fallback] disabled but infer_type_from_phi called\n\
|
||||
Function: {}\n\
|
||||
|
||||
Reference in New Issue
Block a user