diff --git a/src/mir/builder/lifecycle.rs b/src/mir/builder/lifecycle.rs index 7b275040..45f63396 100644 --- a/src/mir/builder/lifecycle.rs +++ b/src/mir/builder/lifecycle.rs @@ -31,7 +31,9 @@ fn has_main_static(ast: &ASTNode) -> bool { /// Phase 63-6-3: PHI命令から型ヒントを取得 /// /// ValueId が PHI 命令の結果である場合、その type_hint を返す。 -/// P1 ケース(IfSelectTest.simple/local)でのみ使用を想定。 +/// P1 ケース(IfSelectTest.*)および P2 ケース(IfMergeTest.*, read_quoted*)で使用。 +/// +/// Phase 64-3: P2 ケース拡大 - IfMerge パターンと read_quoted 系関数を追加 /// /// # Arguments /// @@ -59,6 +61,33 @@ fn get_phi_type_hint( None } +/// Phase 64-3: P1/P2 型ヒント対象判定 +/// +/// 関数名が型ヒント使用対象かどうかを判定する。 +/// 箱理論: 段階的拡大のため、関数名フィルタで制御 +/// +/// # P1 対象(Phase 63-6 完了) +/// - `IfSelectTest.*` - If Select パターンのテスト関数 +/// +/// # P2 対象(Phase 64-3 追加) +/// - `IfMergeTest.*` - If Merge パターンのテスト関数 +/// - `read_quoted*` - selfhost の read_quoted 系関数 +fn is_type_hint_target(func_name: &str) -> bool { + // P1: If Select テスト関数 + if func_name.starts_with("IfSelectTest.") { + return true; + } + // P2: If Merge テスト関数 + if func_name.starts_with("IfMergeTest.") { + return true; + } + // P2: selfhost read_quoted 系関数 + if func_name.contains("read_quoted") { + return true; + } + false +} + impl super::MirBuilder { /// Unified declaration indexing (Phase A): collect symbols before lowering /// - user_defined_boxes: non-static Box names (for NewBox birth() skip) @@ -309,8 +338,8 @@ impl super::MirBuilder { inferred = Some(mt); break 'outer; } - // Phase 63-6-3: P1 ケース(IfSelectTest.*)で型ヒント使用 - let hint = if function.signature.name.starts_with("IfSelectTest.") { + // Phase 64-3: P1/P2 ケースで型ヒント使用 + let hint = if is_type_hint_target(&function.signature.name) { get_phi_type_hint(&function, *v) } else { None