diff --git a/toolchain/check/handle_binding_pattern.cpp b/toolchain/check/handle_binding_pattern.cpp index 9a1945000415..21456eb77af6 100644 --- a/toolchain/check/handle_binding_pattern.cpp +++ b/toolchain/check/handle_binding_pattern.cpp @@ -132,6 +132,10 @@ struct BindingPatternTypeInfo { // For a `:?` binding this is the type component of the form denoted by // `inst_id`. Otherwise this is the type denoted by `inst_id`. SemIR::TypeId type_component_id; + // The instruction describing `type_component_id` as it was written. For a + // `:?` binding this is a `TypeComponentOf` the form; otherwise it is + // `inst_id` itself. + SemIR::TypeInstId type_component_inst_id; }; } // namespace @@ -211,7 +215,8 @@ static auto HandleAnyBindingPatternType( auto as_type = ExprAsType(context, binding_node_id, *self_type_inst_id); return {.node_id = binding_node_id, .inst_id = as_type.inst_id, - .type_component_id = as_type.type_id}; + .type_component_id = as_type.type_id, + .type_component_inst_id = as_type.inst_id}; } auto [node_id, original_inst_id] = context.node_stack().PopExprWithNodeId(); @@ -277,12 +282,14 @@ static auto HandleAnyBindingPatternType( auto as_form = FormExprAsForm(context, node_id, original_inst_id); return {.node_id = node_id, .inst_id = as_form.form_inst_id, - .type_component_id = as_form.type_component_id}; + .type_component_id = as_form.type_component_id, + .type_component_inst_id = as_form.type_component_inst_id}; } else { auto as_type = ExprAsType(context, node_id, original_inst_id); return {.node_id = node_id, .inst_id = as_type.inst_id, - .type_component_id = as_type.type_id}; + .type_component_id = as_type.type_id, + .type_component_inst_id = as_type.inst_id}; } } @@ -339,8 +346,9 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, context, node_id, type_expr_region_id, type_expr.type_component_id, {.kind = kind, .type_id = GetPatternType(context, type_expr.type_component_id), - .entity_name_id = AddBindingEntityName(context, name_id, form_id, - /*is_unused=*/false, phase), + .entity_name_id = AddBindingEntityName( + context, name_id, type_expr.type_component_inst_id, form_id, + /*is_unused=*/false, phase), .subpattern_id = subpattern_id}); // TODO: If `is_generic`, then `binding.bind_id is a SymbolicBinding. Subst diff --git a/toolchain/check/pattern.cpp b/toolchain/check/pattern.cpp index 4b41437e7eba..201c200beb3a 100644 --- a/toolchain/check/pattern.cpp +++ b/toolchain/check/pattern.cpp @@ -92,8 +92,9 @@ auto MakeEmptyRegion(Context& context, SemIR::InstId result_id) } auto AddBindingEntityName(Context& context, SemIR::NameId name_id, - SemIR::InstId form_id, bool is_unused, - BindingPhase phase) -> SemIR::EntityNameId { + SemIR::TypeInstId type_inst_id, SemIR::InstId form_id, + bool is_unused, BindingPhase phase) + -> SemIR::EntityNameId { SemIR::EntityName entity_name = { .name_id = name_id, .parent_scope_id = context.scope_stack().PeekNameScopeId(), @@ -104,6 +105,7 @@ auto AddBindingEntityName(Context& context, SemIR::NameId name_id, entity_name.is_template = phase == BindingPhase::Template; } entity_name.form_id = form_id; + entity_name.type_inst_id = type_inst_id; return context.entity_names().Add(entity_name); } @@ -243,10 +245,14 @@ auto AddParamPattern(Context& context, SemIR::LocId loc_id, } }(); - auto entity_name_id = AddBindingEntityName(context, name_id, - /*form_id=*/SemIR::InstId::None, - /*is_unused=*/false, - /*phase=*/BindingPhase::Runtime); + // This pattern is synthesized rather than written in the source, so there is + // no spelling to record for its type. + auto entity_name_id = + AddBindingEntityName(context, name_id, + /*type_inst_id=*/SemIR::TypeInstId::None, + /*form_id=*/SemIR::InstId::None, + /*is_unused=*/false, + /*phase=*/BindingPhase::Runtime); auto pattern_type_id = GetPatternType(context, type_id); if (kind == ParamPatternKind::Var) { diff --git a/toolchain/check/pattern.h b/toolchain/check/pattern.h index bd5384a35e30..0e05677cbf5c 100644 --- a/toolchain/check/pattern.h +++ b/toolchain/check/pattern.h @@ -58,9 +58,12 @@ struct BindingPatternInfo { enum class BindingPhase { Template, Symbolic, Runtime }; // Creates an entity name for a binding pattern with the given properties. +// `type_inst_id` is the declared type of the binding as written, if known; see +// `SemIR::EntityName::type_inst_id`. auto AddBindingEntityName(Context& context, SemIR::NameId name_id, - SemIR::InstId form_id, bool is_unused, - BindingPhase phase) -> SemIR::EntityNameId; + SemIR::TypeInstId type_inst_id, SemIR::InstId form_id, + bool is_unused, BindingPhase phase) + -> SemIR::EntityNameId; // Creates a binding pattern and the associated binding inst, and returns their // IDs. `scrutinee_type_id` is the type of the binding, and `type_region_id` is diff --git a/toolchain/check/testdata/basics/raw_sem_ir/bundle.carbon b/toolchain/check/testdata/basics/raw_sem_ir/bundle.carbon index 9b413e26bf33..eb7d6619ff86 100644 --- a/toolchain/check/testdata/basics/raw_sem_ir/bundle.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/bundle.carbon @@ -34,9 +34,9 @@ fn F(generic Form: Core.Form) ->? Form; // CHECK:STDOUT: name_scope0: {inst: inst10, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name(Core): inst70000012, name0: inst70000033}} // CHECK:STDOUT: name_scope70000001: {inst: inst70000012, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name1: inst70000017}} // CHECK:STDOUT: entity_names: -// CHECK:STDOUT: entity_name70000000: {name: name(PeriodSelf), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, is_frozen_period_self: 1}, form: inst} -// CHECK:STDOUT: entity_name70000001: {name: name1, parent_scope: name_scope70000001, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name70000002: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} +// CHECK:STDOUT: entity_name70000000: {name: name(PeriodSelf), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, is_frozen_period_self: 1}, form: inst, type: inst} +// CHECK:STDOUT: entity_name70000001: {name: name1, parent_scope: name_scope70000001, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name70000002: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst70000018} // CHECK:STDOUT: functions: // CHECK:STDOUT: function70000000: {name: name0, parent_scope: name_scope0, call_param_patterns_id: inst_block70000007, call_params_id: inst_block70000008, return_type_inst_id: inst70000021, return_form_inst_id: inst70000020, return_pattern_id: inst7000002A} // CHECK:STDOUT: classes: {} diff --git a/toolchain/check/testdata/basics/raw_sem_ir/cpp_interop.carbon b/toolchain/check/testdata/basics/raw_sem_ir/cpp_interop.carbon index e80bda057978..3f3865bf078c 100644 --- a/toolchain/check/testdata/basics/raw_sem_ir/cpp_interop.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/cpp_interop.carbon @@ -70,10 +70,10 @@ fn G(x: Cpp.X) { // CHECK:STDOUT: name_scope50000001: {inst: inst50000012, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name2: inst50000014, name3: inst5000002D, name4: inst50000055}} // CHECK:STDOUT: name_scope50000002: {inst: inst50000014, parent_scope: name_scope50000001, has_error: false, extended_scopes: [], names: {}} // CHECK:STDOUT: entity_names: -// CHECK:STDOUT: entity_name50000000: {name: name1, parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name50000001: {name: name1, parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name50000002: {name: name1, parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name50000003: {name: name4, parent_scope: name_scope50000001, index: -1, is_template: 0, is_unused: 0, form: inst} +// CHECK:STDOUT: entity_name50000000: {name: name1, parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst50000016} +// CHECK:STDOUT: entity_name50000001: {name: name1, parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name50000002: {name: name1, parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name50000003: {name: name4, parent_scope: name_scope50000001, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} // CHECK:STDOUT: functions: // CHECK:STDOUT: function50000000: {name: name0, parent_scope: name_scope0, call_param_patterns_id: inst_block50000007, call_params_id: inst_block50000008, body: [inst_block5000000B]} // CHECK:STDOUT: function50000001: {name: name3, parent_scope: name_scope50000001, call_param_patterns_id: inst_block_empty, call_params_id: inst_block_empty, cpp_thunk_decl: inst50000033} diff --git a/toolchain/check/testdata/basics/raw_sem_ir/multifile.carbon b/toolchain/check/testdata/basics/raw_sem_ir/multifile.carbon index ce7a4562b35b..b203fc96791d 100644 --- a/toolchain/check/testdata/basics/raw_sem_ir/multifile.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/multifile.carbon @@ -146,7 +146,7 @@ fn B() { // CHECK:STDOUT: name_scope0: {inst: inst10, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name1: inst70000012, name0: inst70000013}} // CHECK:STDOUT: name_scope70000001: {inst: inst70000012, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name1: inst70000018}} // CHECK:STDOUT: entity_names: -// CHECK:STDOUT: entity_name70000000: {name: name1, parent_scope: name_scope70000001, index: -1, is_template: 0, is_unused: 0, form: inst} +// CHECK:STDOUT: entity_name70000000: {name: name1, parent_scope: name_scope70000001, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} // CHECK:STDOUT: functions: // CHECK:STDOUT: function70000000: {name: name0, parent_scope: name_scope0, call_param_patterns_id: inst_block_empty, call_params_id: inst_block_empty, body: [inst_block70000006]} // CHECK:STDOUT: function70000001: {name: name1, parent_scope: name_scope70000001, call_param_patterns_id: inst_block_empty} diff --git a/toolchain/check/testdata/basics/raw_sem_ir/multifile_with_textual_ir.carbon b/toolchain/check/testdata/basics/raw_sem_ir/multifile_with_textual_ir.carbon index 77645adc6711..7141168657b4 100644 --- a/toolchain/check/testdata/basics/raw_sem_ir/multifile_with_textual_ir.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/multifile_with_textual_ir.carbon @@ -165,7 +165,7 @@ fn B() { // CHECK:STDOUT: name_scope0: {inst: inst10, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name1: inst70000012, name0: inst70000013}} // CHECK:STDOUT: name_scope70000001: {inst: inst70000012, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name1: inst70000018}} // CHECK:STDOUT: entity_names: -// CHECK:STDOUT: entity_name70000000: {name: name1, parent_scope: name_scope70000001, index: -1, is_template: 0, is_unused: 0, form: inst} +// CHECK:STDOUT: entity_name70000000: {name: name1, parent_scope: name_scope70000001, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} // CHECK:STDOUT: functions: // CHECK:STDOUT: function70000000: {name: name0, parent_scope: name_scope0, call_param_patterns_id: inst_block_empty, call_params_id: inst_block_empty, body: [inst_block70000006]} // CHECK:STDOUT: function70000001: {name: name1, parent_scope: name_scope70000001, call_param_patterns_id: inst_block_empty} diff --git a/toolchain/check/testdata/basics/raw_sem_ir/non_core_interfaces.carbon b/toolchain/check/testdata/basics/raw_sem_ir/non_core_interfaces.carbon index ed5bb811f3a9..69d46296a5b7 100644 --- a/toolchain/check/testdata/basics/raw_sem_ir/non_core_interfaces.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/non_core_interfaces.carbon @@ -52,7 +52,7 @@ fn UseLocalCopy[T: Copy](_: T.T1, _: T.T2) {} // CHECK:STDOUT: name_scope60000001: {inst: inst60000011, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name(SelfType): inst60000013}} // CHECK:STDOUT: name_scope60000002: {inst: inst60000016, parent_scope: name_scope60000001, has_error: false, extended_scopes: [], names: {name2: inst6000001A, name3: inst6000001E}} // CHECK:STDOUT: entity_names: -// CHECK:STDOUT: entity_name60000000: {name: name(SelfType), parent_scope: name_scope60000001, index: 0, is_template: 0, is_unused: 0, form: inst} +// CHECK:STDOUT: entity_name60000000: {name: name(SelfType), parent_scope: name_scope60000001, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} // CHECK:STDOUT: functions: {} // CHECK:STDOUT: classes: {} // CHECK:STDOUT: interfaces: @@ -219,19 +219,19 @@ fn UseLocalCopy[T: Copy](_: T.T1, _: T.T2) {} // CHECK:STDOUT: name_scope50000004: {inst: inst50000027, parent_scope: name_scope50000001, has_error: false, extended_scopes: [], names: {name(SelfType): inst50000030}} // CHECK:STDOUT: name_scope50000005: {inst: inst50000029, parent_scope: name_scope50000004, has_error: false, extended_scopes: [], names: {name2: inst5000002B, name3: inst5000002C}} // CHECK:STDOUT: entity_names: -// CHECK:STDOUT: entity_name50000000: {name: name(SelfType), parent_scope: name_scope50000002, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name50000001: {name: name(PeriodSelf), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, is_frozen_period_self: 1}, form: inst} -// CHECK:STDOUT: entity_name50000002: {name: name6, parent_scope: name_scope50000001, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name50000003: {name: name(SelfType), parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name50000004: {name: name2, parent_scope: name_scope50000005, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name50000005: {name: name3, parent_scope: name_scope50000005, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name50000006: {name: name(SelfType), parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name50000007: {name: name5, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name50000008: {name: name(Underscore), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 1, form: inst} -// CHECK:STDOUT: entity_name50000009: {name: name(Underscore), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 1, form: inst} -// CHECK:STDOUT: entity_name5000000A: {name: name5, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name5000000B: {name: name(Underscore), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 1, form: inst} -// CHECK:STDOUT: entity_name5000000C: {name: name(Underscore), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 1, form: inst} +// CHECK:STDOUT: entity_name50000000: {name: name(SelfType), parent_scope: name_scope50000002, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name50000001: {name: name(PeriodSelf), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, is_frozen_period_self: 1}, form: inst, type: inst} +// CHECK:STDOUT: entity_name50000002: {name: name6, parent_scope: name_scope50000001, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name50000003: {name: name(SelfType), parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name50000004: {name: name2, parent_scope: name_scope50000005, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name50000005: {name: name3, parent_scope: name_scope50000005, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name50000006: {name: name(SelfType), parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name50000007: {name: name5, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst50000031} +// CHECK:STDOUT: entity_name50000008: {name: name(Underscore), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 1, form: inst, type: inst50000045} +// CHECK:STDOUT: entity_name50000009: {name: name(Underscore), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 1, form: inst, type: inst5000005A} +// CHECK:STDOUT: entity_name5000000A: {name: name5, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst50000077} +// CHECK:STDOUT: entity_name5000000B: {name: name(Underscore), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 1, form: inst, type: inst50000087} +// CHECK:STDOUT: entity_name5000000C: {name: name(Underscore), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 1, form: inst, type: inst50000099} // CHECK:STDOUT: functions: // CHECK:STDOUT: function50000000: {name: name4, parent_scope: name_scope0, call_param_patterns_id: inst_block50000018, call_params_id: inst_block50000019, body: [inst_block5000001F]} // CHECK:STDOUT: function50000001: {name: name7, parent_scope: name_scope0, call_param_patterns_id: inst_block50000028, call_params_id: inst_block50000029, body: [inst_block5000002F]} diff --git a/toolchain/check/testdata/basics/raw_sem_ir/one_file.carbon b/toolchain/check/testdata/basics/raw_sem_ir/one_file.carbon index d55b644c0de4..702281783fd5 100644 --- a/toolchain/check/testdata/basics/raw_sem_ir/one_file.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/one_file.carbon @@ -355,76 +355,76 @@ fn Foo[T: type](p: T*) -> (T*, ()) { // CHECK:STDOUT: name_scope7800000C: {inst: inst7800012E, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {}} // CHECK:STDOUT: name_scope7800000D: {inst: inst7800018D, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {}} // CHECK:STDOUT: entity_names: -// CHECK:STDOUT: entity_name78000000: {name: name(PeriodSelf), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, is_frozen_period_self: 1}, form: inst} -// CHECK:STDOUT: entity_name78000001: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000002: {name: name2, parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000003: {name: name3, parent_scope: name_scope78000001, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000004: {name: name(SelfType), parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000005: {name: name4, parent_scope: name_scope78000003, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000006: {name: name(SelfType), parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000007: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000008: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000009: {name: name(SelfType), parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800000A: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800000B: {name: name(SelfType), parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800000C: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800000D: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800000E: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800000F: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000010: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000011: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000012: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000013: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000014: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000015: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000016: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000017: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000018: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000019: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800001A: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800001B: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800001C: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800001D: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800001E: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800001F: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000020: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000021: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000022: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000023: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000024: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000025: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000026: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000027: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000028: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000029: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800002A: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800002B: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800002C: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800002D: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800002E: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800002F: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000030: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000031: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000032: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000033: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000034: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000035: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000036: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000037: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000038: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000039: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800003A: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800003B: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800003C: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800003D: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800003E: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name7800003F: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000040: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000041: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000042: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000043: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000044: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst} -// CHECK:STDOUT: entity_name78000045: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst} +// CHECK:STDOUT: entity_name78000000: {name: name(PeriodSelf), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, is_frozen_period_self: 1}, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000001: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst78000016} +// CHECK:STDOUT: entity_name78000002: {name: name2, parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst7800001F} +// CHECK:STDOUT: entity_name78000003: {name: name3, parent_scope: name_scope78000001, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000004: {name: name(SelfType), parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000005: {name: name4, parent_scope: name_scope78000003, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000006: {name: name(SelfType), parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000007: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000008: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000009: {name: name(SelfType), parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800000A: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800000B: {name: name(SelfType), parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800000C: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800000D: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800000E: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800000F: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000010: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000011: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000012: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000013: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000014: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000015: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000016: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000017: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000018: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000019: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800001A: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800001B: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800001C: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800001D: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800001E: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800001F: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000020: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000021: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000022: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000023: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000024: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000025: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000026: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000027: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000028: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000029: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800002A: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800002B: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800002C: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800002D: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800002E: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800002F: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000030: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000031: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000032: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000033: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000034: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000035: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000036: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000037: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000038: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000039: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800003A: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800003B: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800003C: {name: name(SelfValue), parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800003D: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800003E: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name7800003F: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000040: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000041: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000042: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000043: {name: name6, parent_scope: name_scope, index: 2, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000044: {name: name5, parent_scope: name_scope, index: 1, is_template: 0, is_unused: 0, form: inst, type: inst} +// CHECK:STDOUT: entity_name78000045: {name: name1, parent_scope: name_scope, index: 0, is_template: 0, is_unused: 0, form: inst, type: inst} // CHECK:STDOUT: functions: // CHECK:STDOUT: function78000000: {name: name0, parent_scope: name_scope0, call_param_patterns_id: inst_block78000010, call_params_id: inst_block78000011, return_type_inst_id: inst78000037, return_form_inst_id: inst78000039, return_pattern_id: inst78000041, body: [inst_block78000018]} // CHECK:STDOUT: function78000001: {name: name4, parent_scope: name_scope78000003, call_param_patterns_id: inst_block7800001E, return_type_inst_id: inst78000073, return_form_inst_id: inst78000074, return_pattern_id: inst78000075} diff --git a/toolchain/check/testdata/basics/raw_sem_ir/one_file_with_textual_ir.carbon b/toolchain/check/testdata/basics/raw_sem_ir/one_file_with_textual_ir.carbon index a1e4c2dfe9d3..1c9543bb0060 100644 --- a/toolchain/check/testdata/basics/raw_sem_ir/one_file_with_textual_ir.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/one_file_with_textual_ir.carbon @@ -32,7 +32,7 @@ fn Foo(n: ()) -> ((), ()) { // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst10, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name0: inst5000002F}} // CHECK:STDOUT: entity_names: -// CHECK:STDOUT: entity_name50000000: {name: name1, parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst} +// CHECK:STDOUT: entity_name50000000: {name: name1, parent_scope: name_scope, index: -1, is_template: 0, is_unused: 0, form: inst, type: inst50000014} // CHECK:STDOUT: functions: // CHECK:STDOUT: function50000000: {name: name0, parent_scope: name_scope0, call_param_patterns_id: inst_block5000000B, call_params_id: inst_block5000000C, return_type_inst_id: inst50000023, return_form_inst_id: inst50000024, return_pattern_id: inst50000029, body: [inst_block5000000F]} // CHECK:STDOUT: classes: {} diff --git a/toolchain/check/testdata/class/self/self.carbon b/toolchain/check/testdata/class/self/self.carbon index a8659323b4b8..9000947510d3 100644 --- a/toolchain/check/testdata/class/self/self.carbon +++ b/toolchain/check/testdata/class/self/self.carbon @@ -82,7 +82,7 @@ fn Class.F(unused self: Class) {} library "[[@TEST_NAME]]"; class Class { - // CHECK:STDERR: fail_return_self_value.carbon:[[@LINE+7]]:17: error: cannot implicitly convert non-type value of type `Class` to `type` [ConversionFailureNonTypeToFacet] + // CHECK:STDERR: fail_return_self_value.carbon:[[@LINE+7]]:17: error: cannot implicitly convert non-type value of type `Self` to `type` [ConversionFailureNonTypeToFacet] // CHECK:STDERR: fn F(self) -> self; // CHECK:STDERR: ^~~~ // CHECK:STDERR: fail_return_self_value.carbon:[[@LINE+4]]:17: note: type `Class` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessInContext] diff --git a/toolchain/check/testdata/interface/fail_type_as_facet.carbon b/toolchain/check/testdata/interface/fail_type_as_facet.carbon index 02f3b766c6f5..1c4974c03bf1 100644 --- a/toolchain/check/testdata/interface/fail_type_as_facet.carbon +++ b/toolchain/check/testdata/interface/fail_type_as_facet.carbon @@ -12,7 +12,7 @@ interface I { let T: type; - // CHECK:STDERR: fail_type_as_facet.carbon:[[@LINE+7]]:17: error: cannot implicitly convert non-type value of type `Self.(TODO: element 0 in incomplete Self as I)` to `type` [ConversionFailureNonTypeToFacet] + // CHECK:STDERR: fail_type_as_facet.carbon:[[@LINE+7]]:17: error: cannot implicitly convert non-type value of type `T` to `type` [ConversionFailureNonTypeToFacet] // CHECK:STDERR: fn F[X: T](x: X); // CHECK:STDERR: ^ // CHECK:STDERR: fail_type_as_facet.carbon:[[@LINE+4]]:17: note: type `Self.(TODO: element 0 in incomplete Self as I)` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessInContext] diff --git a/toolchain/check/testdata/interop/cpp/class/import/base.carbon b/toolchain/check/testdata/interop/cpp/class/import/base.carbon index 8557877b0e7a..7c3c784c2b24 100644 --- a/toolchain/check/testdata/interop/cpp/class/import/base.carbon +++ b/toolchain/check/testdata/interop/cpp/class/import/base.carbon @@ -156,7 +156,7 @@ library "[[@TEST_NAME]]"; import Cpp library "multiple_inheritance.h"; fn ConvertA(p: Cpp.C*) -> Cpp.A* { - // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.C*` to `Cpp.A*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `C*` to `Cpp.A*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+4]]:3: note: type `Cpp.C*` does not implement interface `Core.ImplicitAs(Cpp.A*)` [MissingImplInMemberAccessInContext] @@ -167,7 +167,7 @@ fn ConvertA(p: Cpp.C*) -> Cpp.A* { } fn ConvertB(p: Cpp.C*) -> Cpp.B* { - // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.C*` to `Cpp.B*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `C*` to `Cpp.B*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+4]]:3: note: type `Cpp.C*` does not implement interface `Core.ImplicitAs(Cpp.B*)` [MissingImplInMemberAccessInContext] @@ -178,7 +178,7 @@ fn ConvertB(p: Cpp.C*) -> Cpp.B* { } fn ConvertOneNonEmptyBaseToEmpty1(p: Cpp.OneNonEmptyBase*) -> Cpp.Empty1* { - // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.OneNonEmptyBase*` to `Cpp.Empty1*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `OneNonEmptyBase*` to `Cpp.Empty1*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+4]]:3: note: type `Cpp.OneNonEmptyBase*` does not implement interface `Core.ImplicitAs(Cpp.Empty1*)` [MissingImplInMemberAccessInContext] @@ -189,7 +189,7 @@ fn ConvertOneNonEmptyBaseToEmpty1(p: Cpp.OneNonEmptyBase*) -> Cpp.Empty1* { } fn ConvertOneNonEmptyBaseToEmpty2(p: Cpp.OneNonEmptyBase*) -> Cpp.Empty2* { - // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.OneNonEmptyBase*` to `Cpp.Empty2*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `OneNonEmptyBase*` to `Cpp.Empty2*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+4]]:3: note: type `Cpp.OneNonEmptyBase*` does not implement interface `Core.ImplicitAs(Cpp.Empty2*)` [MissingImplInMemberAccessInContext] @@ -200,7 +200,7 @@ fn ConvertOneNonEmptyBaseToEmpty2(p: Cpp.OneNonEmptyBase*) -> Cpp.Empty2* { } fn ConvertTwoNonEmptyBasesToA(p: Cpp.TwoNonEmptyBases*) -> Cpp.A* { - // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.TwoNonEmptyBases*` to `Cpp.A*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `TwoNonEmptyBases*` to `Cpp.A*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+4]]:3: note: type `Cpp.TwoNonEmptyBases*` does not implement interface `Core.ImplicitAs(Cpp.A*)` [MissingImplInMemberAccessInContext] @@ -211,7 +211,7 @@ fn ConvertTwoNonEmptyBasesToA(p: Cpp.TwoNonEmptyBases*) -> Cpp.A* { } fn ConvertTwoNonEmptyBasesToB(p: Cpp.TwoNonEmptyBases*) -> Cpp.B* { - // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.TwoNonEmptyBases*` to `Cpp.B*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `TwoNonEmptyBases*` to `Cpp.B*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+4]]:3: note: type `Cpp.TwoNonEmptyBases*` does not implement interface `Core.ImplicitAs(Cpp.B*)` [MissingImplInMemberAccessInContext] @@ -222,7 +222,7 @@ fn ConvertTwoNonEmptyBasesToB(p: Cpp.TwoNonEmptyBases*) -> Cpp.B* { } fn ConvertOnePolymorphicBaseToA(p: Cpp.OnePolymorphicBase*) -> Cpp.A* { - // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.OnePolymorphicBase*` to `Cpp.A*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `OnePolymorphicBase*` to `Cpp.A*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+4]]:3: note: type `Cpp.OnePolymorphicBase*` does not implement interface `Core.ImplicitAs(Cpp.A*)` [MissingImplInMemberAccessInContext] @@ -233,7 +233,7 @@ fn ConvertOnePolymorphicBaseToA(p: Cpp.OnePolymorphicBase*) -> Cpp.A* { } fn ConvertOnePolymorphicBaseToB(p: Cpp.OnePolymorphicBase*) -> Cpp.B* { - // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.OnePolymorphicBase*` to `Cpp.B*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `OnePolymorphicBase*` to `Cpp.B*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+4]]:3: note: type `Cpp.OnePolymorphicBase*` does not implement interface `Core.ImplicitAs(Cpp.B*)` [MissingImplInMemberAccessInContext] @@ -244,7 +244,7 @@ fn ConvertOnePolymorphicBaseToB(p: Cpp.OnePolymorphicBase*) -> Cpp.B* { } fn ConvertTwoPolymorphicBasesToPolymorphic1(p: Cpp.TwoPolymorphicBases*) -> Cpp.Polymorphic1* { - // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.TwoPolymorphicBases*` to `Cpp.Polymorphic1*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `TwoPolymorphicBases*` to `Cpp.Polymorphic1*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+4]]:3: note: type `Cpp.TwoPolymorphicBases*` does not implement interface `Core.ImplicitAs(Cpp.Polymorphic1*)` [MissingImplInMemberAccessInContext] @@ -255,7 +255,7 @@ fn ConvertTwoPolymorphicBasesToPolymorphic1(p: Cpp.TwoPolymorphicBases*) -> Cpp. } fn ConvertTwoPolymorphicBasesToPolymorphic2(p: Cpp.TwoPolymorphicBases*) -> Cpp.Polymorphic2* { - // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.TwoPolymorphicBases*` to `Cpp.Polymorphic2*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `TwoPolymorphicBases*` to `Cpp.Polymorphic2*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_multiple_inheritance.carbon:[[@LINE+4]]:3: note: type `Cpp.TwoPolymorphicBases*` does not implement interface `Core.ImplicitAs(Cpp.Polymorphic2*)` [MissingImplInMemberAccessInContext] @@ -308,7 +308,7 @@ library "[[@TEST_NAME]]"; import Cpp library "virtual_inheritance.h"; fn Convert(p: Cpp.VirtB*) -> Cpp.VirtA* { - // CHECK:STDERR: fail_todo_use_virtual_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.VirtB*` to `Cpp.VirtA*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_virtual_inheritance.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `VirtB*` to `Cpp.VirtA*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_virtual_inheritance.carbon:[[@LINE+4]]:3: note: type `Cpp.VirtB*` does not implement interface `Core.ImplicitAs(Cpp.VirtA*)` [MissingImplInMemberAccessInContext] @@ -343,7 +343,7 @@ library "[[@TEST_NAME]]"; import Cpp library "diamond.h"; fn ConvertBA(p: Cpp.DiamondB*) -> Cpp.DiamondA* { - // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.DiamondB*` to `Cpp.DiamondA*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `DiamondB*` to `Cpp.DiamondA*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+4]]:3: note: type `Cpp.DiamondB*` does not implement interface `Core.ImplicitAs(Cpp.DiamondA*)` [MissingImplInMemberAccessInContext] @@ -354,7 +354,7 @@ fn ConvertBA(p: Cpp.DiamondB*) -> Cpp.DiamondA* { } fn ConvertCA(p: Cpp.DiamondC*) -> Cpp.DiamondA* { - // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.DiamondC*` to `Cpp.DiamondA*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `DiamondC*` to `Cpp.DiamondA*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+4]]:3: note: type `Cpp.DiamondC*` does not implement interface `Core.ImplicitAs(Cpp.DiamondA*)` [MissingImplInMemberAccessInContext] @@ -365,7 +365,7 @@ fn ConvertCA(p: Cpp.DiamondC*) -> Cpp.DiamondA* { } fn ConvertDB(p: Cpp.DiamondD*) -> Cpp.DiamondB* { - // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.DiamondD*` to `Cpp.DiamondB*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `DiamondD*` to `Cpp.DiamondB*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+4]]:3: note: type `Cpp.DiamondD*` does not implement interface `Core.ImplicitAs(Cpp.DiamondB*)` [MissingImplInMemberAccessInContext] @@ -376,7 +376,7 @@ fn ConvertDB(p: Cpp.DiamondD*) -> Cpp.DiamondB* { } fn ConvertDC(p: Cpp.DiamondD*) -> Cpp.DiamondC* { - // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Cpp.DiamondD*` to `Cpp.DiamondC*` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `DiamondD*` to `Cpp.DiamondC*` [ConversionFailure] // CHECK:STDERR: return p; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+4]]:3: note: type `Cpp.DiamondD*` does not implement interface `Core.ImplicitAs(Cpp.DiamondC*)` [MissingImplInMemberAccessInContext] @@ -387,7 +387,7 @@ fn ConvertDC(p: Cpp.DiamondD*) -> Cpp.DiamondC* { } fn AccessBA(d: Cpp.DiamondD) -> i32 { - // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:11: error: cannot convert expression of type `Cpp.DiamondD` to `Cpp.DiamondB` with `as` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:11: error: cannot convert expression of type `DiamondD` to `Cpp.DiamondB` with `as` [ConversionFailure] // CHECK:STDERR: return (d as Cpp.DiamondB).b; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+4]]:11: note: type `Cpp.DiamondD` does not implement interface `Core.As(Cpp.DiamondB)` [MissingImplInMemberAccessInContext] @@ -398,7 +398,7 @@ fn AccessBA(d: Cpp.DiamondD) -> i32 { } fn AccessCA(d: Cpp.DiamondD) -> i32 { - // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:11: error: cannot convert expression of type `Cpp.DiamondD` to `Cpp.DiamondC` with `as` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:11: error: cannot convert expression of type `DiamondD` to `Cpp.DiamondC` with `as` [ConversionFailure] // CHECK:STDERR: return (d as Cpp.DiamondC).b; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+4]]:11: note: type `Cpp.DiamondD` does not implement interface `Core.As(Cpp.DiamondC)` [MissingImplInMemberAccessInContext] @@ -409,7 +409,7 @@ fn AccessCA(d: Cpp.DiamondD) -> i32 { } fn AccessDB(d: Cpp.DiamondD) -> i32 { - // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:10: error: cannot implicitly convert expression of type `Cpp.DiamondD` to `Cpp.DiamondB` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:10: error: cannot implicitly convert expression of type `DiamondD` to `Cpp.DiamondB` [ConversionFailure] // CHECK:STDERR: return d.b; // CHECK:STDERR: ^~~ // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+4]]:10: note: type `Cpp.DiamondD` does not implement interface `Core.ImplicitAs(Cpp.DiamondB)` [MissingImplInMemberAccessInContext] @@ -420,7 +420,7 @@ fn AccessDB(d: Cpp.DiamondD) -> i32 { } fn AccessDC(d: Cpp.DiamondD) -> i32 { - // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:10: error: cannot implicitly convert expression of type `Cpp.DiamondD` to `Cpp.DiamondC` [ConversionFailure] + // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+7]]:10: error: cannot implicitly convert expression of type `DiamondD` to `Cpp.DiamondC` [ConversionFailure] // CHECK:STDERR: return d.c; // CHECK:STDERR: ^~~ // CHECK:STDERR: fail_todo_use_diamond.carbon:[[@LINE+4]]:10: note: type `Cpp.DiamondD` does not implement interface `Core.ImplicitAs(Cpp.DiamondC)` [MissingImplInMemberAccessInContext] diff --git a/toolchain/check/testdata/interop/cpp/impls/as.carbon b/toolchain/check/testdata/interop/cpp/impls/as.carbon index 7a2b6f404222..807ee948955d 100644 --- a/toolchain/check/testdata/interop/cpp/impls/as.carbon +++ b/toolchain/check/testdata/interop/cpp/impls/as.carbon @@ -112,7 +112,7 @@ import Cpp library "conversions.h"; fn ConstructorExplicit(s: Cpp.Source) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_conditionally_explicit_implicit.carbon:[[@LINE+7]]:42: error: cannot implicitly convert expression of type `Cpp.Source` to `Cpp.ConditionallyExplicit` [ConversionFailure] + // CHECK:STDERR: fail_conditionally_explicit_implicit.carbon:[[@LINE+7]]:42: error: cannot implicitly convert expression of type `Source` to `Cpp.ConditionallyExplicit` [ConversionFailure] // CHECK:STDERR: let _: Cpp.ConditionallyExplicitTrue = s; // CHECK:STDERR: ^ // CHECK:STDERR: fail_conditionally_explicit_implicit.carbon:[[@LINE+4]]:42: note: type `Cpp.Source` does not implement interface `Core.ImplicitAs(Cpp.ConditionallyExplicit)` [MissingImplInMemberAccessInContext] diff --git a/toolchain/check/testdata/interop/cpp/impls/copy.carbon b/toolchain/check/testdata/interop/cpp/impls/copy.carbon index 09a467f01965..3d110e241395 100644 --- a/toolchain/check/testdata/interop/cpp/impls/copy.carbon +++ b/toolchain/check/testdata/interop/cpp/impls/copy.carbon @@ -120,7 +120,7 @@ fn CopyDeletedMove(c: Cpp.DeletedMove) -> Cpp.DeletedMove { fn CopyNonConstCopy(c: Cpp.NonConstCopy) -> Cpp.NonConstCopy { // TODO: List candidates here. - // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+7]]:10: error: cannot copy value of type `Cpp.NonConstCopy` [CopyOfUncopyableType] + // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+7]]:10: error: cannot copy value of type `NonConstCopy` [CopyOfUncopyableType] // CHECK:STDERR: return c; // CHECK:STDERR: ^ // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+4]]:10: note: type `Cpp.NonConstCopy` does not implement interface `Core.Copy` [MissingImplInMemberAccessInContext] @@ -132,7 +132,7 @@ fn CopyNonConstCopy(c: Cpp.NonConstCopy) -> Cpp.NonConstCopy { fn CopyAmbiguousCopy(c: Cpp.AmbiguousCopy) -> Cpp.AmbiguousCopy { // TODO: List candidates here. - // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+7]]:10: error: cannot copy value of type `Cpp.AmbiguousCopy` [CopyOfUncopyableType] + // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+7]]:10: error: cannot copy value of type `AmbiguousCopy` [CopyOfUncopyableType] // CHECK:STDERR: return c; // CHECK:STDERR: ^ // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+4]]:10: note: type `Cpp.AmbiguousCopy` does not implement interface `Core.Copy` [MissingImplInMemberAccessInContext] diff --git a/toolchain/check/testdata/interop/cpp/impls/implicit_as.carbon b/toolchain/check/testdata/interop/cpp/impls/implicit_as.carbon index c390906b88ed..043ee53376ef 100644 --- a/toolchain/check/testdata/interop/cpp/impls/implicit_as.carbon +++ b/toolchain/check/testdata/interop/cpp/impls/implicit_as.carbon @@ -92,7 +92,7 @@ import Cpp library "implicit_conversions.h"; fn NonConstConversionTest(s: Cpp.NonConstConversion) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_expr_category.carbon:[[@LINE+7]]:21: error: cannot implicitly convert expression of type `Cpp.NonConstConversion` to `Cpp.Dest` [ConversionFailure] + // CHECK:STDERR: fail_expr_category.carbon:[[@LINE+7]]:21: error: cannot implicitly convert expression of type `NonConstConversion` to `Cpp.Dest` [ConversionFailure] // CHECK:STDERR: let _: Cpp.Dest = s; // CHECK:STDERR: ^ // CHECK:STDERR: fail_expr_category.carbon:[[@LINE+4]]:21: note: type `Cpp.NonConstConversion` does not implement interface `Core.ImplicitAs(Cpp.Dest)` [MissingImplInMemberAccessInContext] @@ -145,7 +145,7 @@ import Cpp library "implicit_conversions.h"; fn DeletedConstructorTest(s: Cpp.Source) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_deleted.carbon:[[@LINE+7]]:35: error: cannot implicitly convert expression of type `Cpp.Source` to `Cpp.DeletedConstructor` [ConversionFailure] + // CHECK:STDERR: fail_deleted.carbon:[[@LINE+7]]:35: error: cannot implicitly convert expression of type `Source` to `Cpp.DeletedConstructor` [ConversionFailure] // CHECK:STDERR: let _: Cpp.DeletedConstructor = s; // CHECK:STDERR: ^ // CHECK:STDERR: fail_deleted.carbon:[[@LINE+4]]:35: note: type `Cpp.Source` does not implement interface `Core.ImplicitAs(Cpp.DeletedConstructor)` [MissingImplInMemberAccessInContext] @@ -158,7 +158,7 @@ fn DeletedConstructorTest(s: Cpp.Source) { fn DeletedConversionTest(s: Cpp.DeletedConversion) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_deleted.carbon:[[@LINE+7]]:21: error: cannot implicitly convert expression of type `Cpp.DeletedConversion` to `Cpp.Dest` [ConversionFailure] + // CHECK:STDERR: fail_deleted.carbon:[[@LINE+7]]:21: error: cannot implicitly convert expression of type `DeletedConversion` to `Cpp.Dest` [ConversionFailure] // CHECK:STDERR: let _: Cpp.Dest = s; // CHECK:STDERR: ^ // CHECK:STDERR: fail_deleted.carbon:[[@LINE+4]]:21: note: type `Cpp.DeletedConversion` does not implement interface `Core.ImplicitAs(Cpp.Dest)` [MissingImplInMemberAccessInContext] @@ -177,7 +177,7 @@ import Cpp library "implicit_conversions.h"; fn ExplicitConstructorTest(s: Cpp.Source) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_explicit.carbon:[[@LINE+7]]:36: error: cannot implicitly convert expression of type `Cpp.Source` to `Cpp.ExplicitConstructor` [ConversionFailure] + // CHECK:STDERR: fail_explicit.carbon:[[@LINE+7]]:36: error: cannot implicitly convert expression of type `Source` to `Cpp.ExplicitConstructor` [ConversionFailure] // CHECK:STDERR: let _: Cpp.ExplicitConstructor = s; // CHECK:STDERR: ^ // CHECK:STDERR: fail_explicit.carbon:[[@LINE+4]]:36: note: type `Cpp.Source` does not implement interface `Core.ImplicitAs(Cpp.ExplicitConstructor)` [MissingImplInMemberAccessInContext] @@ -190,7 +190,7 @@ fn ExplicitConstructorTest(s: Cpp.Source) { fn ExplicitConversionTest(s: Cpp.ExplicitConversion) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_explicit.carbon:[[@LINE+7]]:21: error: cannot implicitly convert expression of type `Cpp.ExplicitConversion` to `Cpp.Dest` [ConversionFailure] + // CHECK:STDERR: fail_explicit.carbon:[[@LINE+7]]:21: error: cannot implicitly convert expression of type `ExplicitConversion` to `Cpp.Dest` [ConversionFailure] // CHECK:STDERR: let _: Cpp.Dest = s; // CHECK:STDERR: ^ // CHECK:STDERR: fail_explicit.carbon:[[@LINE+4]]:21: note: type `Cpp.ExplicitConversion` does not implement interface `Core.ImplicitAs(Cpp.Dest)` [MissingImplInMemberAccessInContext] diff --git a/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.llp64.carbon b/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.llp64.carbon index 9ee3490286a5..e3ab75e51efc 100644 --- a/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.llp64.carbon +++ b/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.llp64.carbon @@ -79,7 +79,7 @@ import Cpp; fn F() { let cpp_long: Cpp.long = 1; - // CHECK:STDERR: fail_implicit_conversion_long_to_i32.carbon:[[@LINE+7]]:32: error: cannot implicitly convert expression of type `Cpp.long` to `i32` [ConversionFailure] + // CHECK:STDERR: fail_implicit_conversion_long_to_i32.carbon:[[@LINE+7]]:32: error: cannot implicitly convert expression of type `long` to `i32` [ConversionFailure] // CHECK:STDERR: let unused carbon_i32: i32 = cpp_long; // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: fail_implicit_conversion_long_to_i32.carbon:[[@LINE+4]]:32: note: type `Cpp.long` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext] @@ -656,7 +656,7 @@ fn F() { // For portability reasons, this is not allowed even though `unsigned long` // happens to fit in `u32` on this target. - // CHECK:STDERR: fail_no_ulong_to_u32.carbon:[[@LINE+11]]:25: error: cannot implicitly convert expression of type `Cpp.unsigned_long` to `u32` [ConversionFailure] + // CHECK:STDERR: fail_no_ulong_to_u32.carbon:[[@LINE+11]]:25: error: cannot implicitly convert expression of type `unsigned_long` to `u32` [ConversionFailure] // CHECK:STDERR: let carbon_u32: u32 = cpp_unsigned_long; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_no_ulong_to_u32.carbon:[[@LINE+8]]:25: note: type `Cpp.unsigned_long` does not implement interface `Core.ImplicitAs(u32)` [MissingImplInMemberAccessInContext] diff --git a/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.lp64.carbon b/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.lp64.carbon index 8180c2be59a3..b9b70b3732cc 100644 --- a/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.lp64.carbon +++ b/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.lp64.carbon @@ -78,7 +78,7 @@ import Cpp; fn F() { let cpp_long_long: Cpp.long_long = 1; - // CHECK:STDERR: fail_implicit_conversion_long_long_to_i64.carbon:[[@LINE+7]]:32: error: cannot implicitly convert expression of type `Cpp.long_long` to `i64` [ConversionFailure] + // CHECK:STDERR: fail_implicit_conversion_long_long_to_i64.carbon:[[@LINE+7]]:32: error: cannot implicitly convert expression of type `long_long` to `i64` [ConversionFailure] // CHECK:STDERR: let unused carbon_i64: i64 = cpp_long_long; // CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: fail_implicit_conversion_long_long_to_i64.carbon:[[@LINE+4]]:32: note: type `Cpp.long_long` does not implement interface `Core.ImplicitAs(i64)` [MissingImplInMemberAccessInContext] @@ -604,7 +604,7 @@ fn F() { // For portability reasons, this is not allowed even though `unsigned long // long` happens to fit in `u64` on this target. - // CHECK:STDERR: fail_pass_ulonglong_to_u64.carbon:[[@LINE+11]]:25: error: cannot implicitly convert expression of type `Cpp.unsigned_long_long` to `u64` [ConversionFailure] + // CHECK:STDERR: fail_pass_ulonglong_to_u64.carbon:[[@LINE+11]]:25: error: cannot implicitly convert expression of type `unsigned_long_long` to `u64` [ConversionFailure] // CHECK:STDERR: let carbon_u64: u64 = cpp_unsigned_long_long; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_pass_ulonglong_to_u64.carbon:[[@LINE+8]]:25: note: type `Cpp.unsigned_long_long` does not implement interface `Core.ImplicitAs(u64)` [MissingImplInMemberAccessInContext] diff --git a/toolchain/check/testdata/interop/cpp/primitive_types/void_pointer.carbon b/toolchain/check/testdata/interop/cpp/primitive_types/void_pointer.carbon index 66eab8c285ac..85505f9cac62 100644 --- a/toolchain/check/testdata/interop/cpp/primitive_types/void_pointer.carbon +++ b/toolchain/check/testdata/interop/cpp/primitive_types/void_pointer.carbon @@ -76,7 +76,7 @@ struct S {}; fn F(input: Cpp.void*) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_explicit_as_from_void_pointer_to_cpp_class_pointer.carbon:[[@LINE+7]]:26: error: cannot convert expression of type `Cpp.void*` to `Cpp.S*` with `as` [ConversionFailure] + // CHECK:STDERR: fail_explicit_as_from_void_pointer_to_cpp_class_pointer.carbon:[[@LINE+7]]:26: error: cannot convert expression of type `void*` to `Cpp.S*` with `as` [ConversionFailure] // CHECK:STDERR: let unused p: Cpp.S* = input as Cpp.S*; // CHECK:STDERR: ^~~~~~~~~~~~~~~ // CHECK:STDERR: fail_explicit_as_from_void_pointer_to_cpp_class_pointer.carbon:[[@LINE+4]]:26: note: type `Cpp.void*` does not implement interface `Core.As(Cpp.S*)` [MissingImplInMemberAccessInContext] @@ -97,7 +97,7 @@ class C {} fn F(input: Cpp.void*) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_explicit_as_from_void_pointer_to_carbon_class_pointer.carbon:[[@LINE+7]]:22: error: cannot convert expression of type `Cpp.void*` to `C*` with `as` [ConversionFailure] + // CHECK:STDERR: fail_explicit_as_from_void_pointer_to_carbon_class_pointer.carbon:[[@LINE+7]]:22: error: cannot convert expression of type `void*` to `C*` with `as` [ConversionFailure] // CHECK:STDERR: let unused p: C* = input as C*; // CHECK:STDERR: ^~~~~~~~~~~ // CHECK:STDERR: fail_explicit_as_from_void_pointer_to_carbon_class_pointer.carbon:[[@LINE+4]]:22: note: type `Cpp.void*` does not implement interface `Core.As(C*)` [MissingImplInMemberAccessInContext] diff --git a/toolchain/check/testdata/primitives/int_conversions.carbon b/toolchain/check/testdata/primitives/int_conversions.carbon index 16d2afa227a9..063ba084c3ab 100644 --- a/toolchain/check/testdata/primitives/int_conversions.carbon +++ b/toolchain/check/testdata/primitives/int_conversions.carbon @@ -88,7 +88,7 @@ fn TestCppCompat() { // CHECK:STDERR: var unused b: i33 = a; // CHECK:STDERR: ^~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_cpp_compat_widen_long32_to_i33.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Core.CppCompat.Long32` to `i33` [ConversionFailure] + // CHECK:STDERR: fail_todo_cpp_compat_widen_long32_to_i33.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Long32` to `i33` [ConversionFailure] // CHECK:STDERR: var unused b: i33 = a; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_cpp_compat_widen_long32_to_i33.carbon:[[@LINE+4]]:3: note: type `Core.CppCompat.Long32` does not implement interface `Core.ImplicitAs(i33)` [MissingImplInMemberAccessInContext] @@ -108,7 +108,7 @@ fn TestCppCompat() { // CHECK:STDERR: var unused d: i65 = c; // CHECK:STDERR: ^~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_cpp_compat_widen_long64_to_i65.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Core.CppCompat.Long64` to `i65` [ConversionFailure] + // CHECK:STDERR: fail_todo_cpp_compat_widen_long64_to_i65.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Long64` to `i65` [ConversionFailure] // CHECK:STDERR: var unused d: i65 = c; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_cpp_compat_widen_long64_to_i65.carbon:[[@LINE+4]]:3: note: type `Core.CppCompat.Long64` does not implement interface `Core.ImplicitAs(i65)` [MissingImplInMemberAccessInContext] @@ -128,7 +128,7 @@ fn TestCppCompat() { // CHECK:STDERR: var unused f: i65 = e; // CHECK:STDERR: ^~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_cpp_compat_widen_longlong64_to_i65.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Core.CppCompat.LongLong64` to `i65` [ConversionFailure] + // CHECK:STDERR: fail_todo_cpp_compat_widen_longlong64_to_i65.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `LongLong64` to `i65` [ConversionFailure] // CHECK:STDERR: var unused f: i65 = e; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_cpp_compat_widen_longlong64_to_i65.carbon:[[@LINE+4]]:3: note: type `Core.CppCompat.LongLong64` does not implement interface `Core.ImplicitAs(i65)` [MissingImplInMemberAccessInContext] @@ -148,7 +148,7 @@ fn TestCppCompat() { // CHECK:STDERR: var unused h: u33 = g; // CHECK:STDERR: ^~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_cpp_compat_widen_ulong32_to_u33.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Core.CppCompat.ULong32` to `u33` [ConversionFailure] + // CHECK:STDERR: fail_todo_cpp_compat_widen_ulong32_to_u33.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `ULong32` to `u33` [ConversionFailure] // CHECK:STDERR: var unused h: u33 = g; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_cpp_compat_widen_ulong32_to_u33.carbon:[[@LINE+4]]:3: note: type `Core.CppCompat.ULong32` does not implement interface `Core.ImplicitAs(u33)` [MissingImplInMemberAccessInContext] @@ -168,7 +168,7 @@ fn TestCppCompat() { // CHECK:STDERR: var unused j: u65 = i; // CHECK:STDERR: ^~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_cpp_compat_widen_ulong64_to_u65.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Core.CppCompat.ULong64` to `u65` [ConversionFailure] + // CHECK:STDERR: fail_todo_cpp_compat_widen_ulong64_to_u65.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `ULong64` to `u65` [ConversionFailure] // CHECK:STDERR: var unused j: u65 = i; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_cpp_compat_widen_ulong64_to_u65.carbon:[[@LINE+4]]:3: note: type `Core.CppCompat.ULong64` does not implement interface `Core.ImplicitAs(u65)` [MissingImplInMemberAccessInContext] @@ -188,7 +188,7 @@ fn TestCppCompat() { // CHECK:STDERR: var unused l: u65 = k; // CHECK:STDERR: ^~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_cpp_compat_widen_ulonglong64_to_u65.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Core.CppCompat.ULongLong64` to `u65` [ConversionFailure] + // CHECK:STDERR: fail_todo_cpp_compat_widen_ulonglong64_to_u65.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `ULongLong64` to `u65` [ConversionFailure] // CHECK:STDERR: var unused l: u65 = k; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_cpp_compat_widen_ulonglong64_to_u65.carbon:[[@LINE+4]]:3: note: type `Core.CppCompat.ULongLong64` does not implement interface `Core.ImplicitAs(u65)` [MissingImplInMemberAccessInContext] @@ -205,7 +205,7 @@ library "[[@TEST_NAME]]"; fn TestCppCompat() { // Long32 is slightly wider than i32. var a: Core.CppCompat.Long32 = 1; - // CHECK:STDERR: fail_cpp_compat_narrow_long32_to_i32.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Core.CppCompat.Long32` to `i32` [ConversionFailure] + // CHECK:STDERR: fail_cpp_compat_narrow_long32_to_i32.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Long32` to `i32` [ConversionFailure] // CHECK:STDERR: var unused b: i32 = a; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_cpp_compat_narrow_long32_to_i32.carbon:[[@LINE+4]]:3: note: type `Core.CppCompat.Long32` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext] @@ -239,7 +239,7 @@ library "[[@TEST_NAME]]"; fn TestCppCompat() { // LongLong64 is slightly wider than i64. var e: Core.CppCompat.LongLong64 = 1; - // CHECK:STDERR: fail_cpp_compat_narrow_longlong64_to_i64.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Core.CppCompat.LongLong64` to `i64` [ConversionFailure] + // CHECK:STDERR: fail_cpp_compat_narrow_longlong64_to_i64.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `LongLong64` to `i64` [ConversionFailure] // CHECK:STDERR: var unused f: i64 = e; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_cpp_compat_narrow_longlong64_to_i64.carbon:[[@LINE+4]]:3: note: type `Core.CppCompat.LongLong64` does not implement interface `Core.ImplicitAs(i64)` [MissingImplInMemberAccessInContext] @@ -256,7 +256,7 @@ library "[[@TEST_NAME]]"; fn TestCppCompat() { // ULong32 is slightly wider than u32. var g: Core.CppCompat.ULong32 = 1; - // CHECK:STDERR: fail_cpp_compat_narrow_ulong32_to_u32.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Core.CppCompat.ULong32` to `u32` [ConversionFailure] + // CHECK:STDERR: fail_cpp_compat_narrow_ulong32_to_u32.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `ULong32` to `u32` [ConversionFailure] // CHECK:STDERR: var unused h: u32 = g; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_cpp_compat_narrow_ulong32_to_u32.carbon:[[@LINE+4]]:3: note: type `Core.CppCompat.ULong32` does not implement interface `Core.ImplicitAs(u32)` [MissingImplInMemberAccessInContext] @@ -290,7 +290,7 @@ library "[[@TEST_NAME]]"; fn TestCppCompat() { // ULongLong64 is slightly wider than u64. var k: Core.CppCompat.ULongLong64 = 1; - // CHECK:STDERR: fail_cpp_compat_narrow_ulonglong64_to_u64.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `Core.CppCompat.ULongLong64` to `u64` [ConversionFailure] + // CHECK:STDERR: fail_cpp_compat_narrow_ulonglong64_to_u64.carbon:[[@LINE+7]]:3: error: cannot implicitly convert expression of type `ULongLong64` to `u64` [ConversionFailure] // CHECK:STDERR: var unused l: u64 = k; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_cpp_compat_narrow_ulonglong64_to_u64.carbon:[[@LINE+4]]:3: note: type `Core.CppCompat.ULongLong64` does not implement interface `Core.ImplicitAs(u64)` [MissingImplInMemberAccessInContext] diff --git a/toolchain/check/thunk.cpp b/toolchain/check/thunk.cpp index 987f13e7598d..61cbae832e94 100644 --- a/toolchain/check/thunk.cpp +++ b/toolchain/check/thunk.cpp @@ -112,9 +112,12 @@ static auto CloneBindingPattern(Context& context, SemIR::InstId pattern_id, phase = entity_name.is_template ? BindingPhase::Template : BindingPhase::Symbolic; } - pattern.entity_name_id = AddBindingEntityName(context, entity_name.name_id, - /*form_id=*/SemIR::InstId::None, - entity_name.is_unused, phase); + // The type of the clone is the result of substitution, so the type as + // written in the original declaration no longer describes it. + pattern.entity_name_id = AddBindingEntityName( + context, entity_name.name_id, + /*type_inst_id=*/SemIR::TypeInstId::None, + /*form_id=*/SemIR::InstId::None, entity_name.is_unused, phase); if (pattern.kind == SemIR::WrapperBindingPattern::Kind) { // Now that we're inside the binding pattern, we can use CloneInstId. pattern.subpattern_id = diff --git a/toolchain/sem_ir/entity_name.h b/toolchain/sem_ir/entity_name.h index e80ca0d76130..c63fa48e472b 100644 --- a/toolchain/sem_ir/entity_name.h +++ b/toolchain/sem_ir/entity_name.h @@ -21,22 +21,33 @@ struct EntityName : public Printable { if (name_id == SemIR::NameId::PeriodSelf) { out << ", is_frozen_period_self: " << is_frozen_period_self << "}"; } - out << ", form: " << form_id << "}"; + out << ", form: " << form_id << ", type: " << type_inst_id << "}"; + } + + // Returns a copy of this name with the fields that are not part of its + // identity cleared. Two `EntityName`s that differ only in how the declared + // type of the binding was written describe the same name. + auto IdentityKey() const -> EntityName { + EntityName key = *this; + key.type_inst_id = TypeInstId::None; + return key; } friend auto CarbonHashtableEq(const EntityName& lhs, const EntityName& rhs) -> bool { // This requires that there are no padding bits in the type. This is upheld // since it holds values all of the same size: each is 32 bits, with one - // split into 30, 1, and 1 bits. - return std::memcmp(&lhs, &rhs, sizeof(EntityName)) == 0; + // split into 29, 1, 1, and 1 bits. + EntityName lhs_key = lhs.IdentityKey(); + EntityName rhs_key = rhs.IdentityKey(); + return std::memcmp(&lhs_key, &rhs_key, sizeof(EntityName)) == 0; } // Hashing for EntityName. See common/hashing.h. friend auto CarbonHashValue(const EntityName& value, uint64_t seed) -> HashCode { Hasher hasher(seed); - hasher.HashRaw(value); + hasher.HashRaw(value.IdentityKey()); return static_cast(hasher); } @@ -73,6 +84,14 @@ struct EntityName : public Printable { // TODO: Unify this with the previous three fields, which also represent form // information. InstId form_id = InstId::None; + + // The declared type of the binding, as written. This describes the same type + // as the binding's `type_id`, but may retain type sugar that `type_id` loses, + // such as the use of an alias to name the type. For a `:?` binding, this is + // the type component of `form_id`. This is `None` if the binding has no + // declared type, or if it was not written in the source, for example because + // the binding was synthesized or imported. + TypeInstId type_inst_id = TypeInstId::None; }; // Value store for EntityName. In addition to the regular ValueStore diff --git a/toolchain/sem_ir/stringify.cpp b/toolchain/sem_ir/stringify.cpp index 7f3145a71172..4e21e1f60dee 100644 --- a/toolchain/sem_ir/stringify.cpp +++ b/toolchain/sem_ir/stringify.cpp @@ -349,15 +349,24 @@ class Stringifier { auto StringifyInst(InstId /*inst_id*/, ConstType inst) -> void { *out_ << "const "; + // `const (const T)` is the same type as `const T`, so don't print a chain + // of `const`s. + // TODO: Do this generically for all type qualifiers, and don't repeat + // qualifiers in types like `const (partial (const T))`. + auto inner_id = inst.inner_id; + while (auto inner_const = sem_ir_->insts().TryGetAs(inner_id)) { + inner_id = inner_const->inner_id; + } + // Add parentheses if required. - if (GetPrecedence(sem_ir_->insts().Get(inst.inner_id).kind()) < + if (GetPrecedence(sem_ir_->insts().Get(inner_id).kind()) < GetPrecedence(ConstType::Kind)) { *out_ << "("; - // Note the `inst.inner_id` ends up here. + // Note the `inner_id` ends up here. step_stack_->PushString(")"); } - step_stack_->PushInstId(inst.inner_id); + step_stack_->PushInstId(inner_id); } auto StringifyInst(InstId /*inst_id*/, CppTemplateNameType inst) -> void { diff --git a/toolchain/sem_ir/sugared_type.cpp b/toolchain/sem_ir/sugared_type.cpp index 80cceed3ffbb..3e529520c8c7 100644 --- a/toolchain/sem_ir/sugared_type.cpp +++ b/toolchain/sem_ir/sugared_type.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "toolchain/base/kind_switch.h" +#include "toolchain/sem_ir/entity_name.h" #include "toolchain/sem_ir/function.h" #include "toolchain/sem_ir/ids.h" #include "toolchain/sem_ir/inst.h" @@ -136,6 +137,14 @@ auto SugaredTypeFinder::FindSpelledType(InstId inst_id) -> TypeInstId { continue; } case CARBON_KIND_ANY(AnyBinding, binding): { + // Prefer the type as written in the declaration of the binding. + auto declared_type_inst_id = + sem_ir_->entity_names().Get(binding.entity_name_id).type_inst_id; + if (declared_type_inst_id.has_value() && + sem_ir_->types().GetTypeIdForTypeInstId(declared_type_inst_id) == + inst.type_id()) { + return declared_type_inst_id; + } inst_id = LookThrough(inst.type_id(), binding.value_id); continue; } @@ -161,11 +170,10 @@ auto SugaredTypeFinder::FindSpelledType(InstId inst_id) -> TypeInstId { } default: { - // TODO: Handle more cases here. For example, the type of a name - // reference to a binding or field should use the type as written in - // the declaration of that binding or field, and the type of an index - // into an array should be the element type as written in the array - // type. + // TODO: Handle more cases here. For example, the type of a reference to + // a class field should use the type as written in the declaration of + // that field, and the type of an index into an array should be the + // element type as written in the array type. return TypeInstId::None; } }