Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions toolchain/check/handle_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ static auto BuildImplDecl(Context& context, Parse::AnyImplDeclId node_id)
// impl unusable for impl lookup.
impl.witness_id = SemIR::ErrorInst::InstId;
} else {
context.inst_block_stack().Push();
// This makes either a placeholder witness table or a full witness
// table. The full witness table is deferred to the impl definition
// unless the declaration uses rewrite constraints to set values of
Expand All @@ -293,6 +294,7 @@ static auto BuildImplDecl(Context& context, Parse::AnyImplDeclId node_id)
impl.witness_id = AddImplWitnessForDeclaration(
context, node_id, impl,
context.generics().GetSelfSpecific(impl.generic_id));
impl.witness_block_id = context.inst_block_stack().Pop();
}

FinishGenericDecl(context, node_id, impl.generic_id);
Expand Down
2 changes: 1 addition & 1 deletion toolchain/check/testdata/as/basics.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ let n: {.x: ()} = {.x = ()} as {.x = ()};
// CHECK:STDOUT: %struct.948: %struct_type.x = struct_value (%empty_tuple) [concrete]
// CHECK:STDOUT: %X.val: %X = struct_value (%empty_tuple) [concrete]
// CHECK:STDOUT: %As.type.cd7: type = facet_type <@As, @As(%Y)> [concrete]
// CHECK:STDOUT: %As.impl_witness.362: <witness> = impl_witness file.%As.impl_witness_table.loc14 [concrete]
// CHECK:STDOUT: %As.impl_witness.362: <witness> = impl_witness @X.as.As.impl.%As.impl_witness_table [concrete]
// CHECK:STDOUT: %As.Convert.type.5a7: type = fn_type @As.Convert, @As(%Y) [concrete]
// CHECK:STDOUT: %X.as.As.impl.Convert.type: type = fn_type @X.as.As.impl.Convert [concrete]
// CHECK:STDOUT: %X.as.As.impl.Convert: %X.as.As.impl.Convert.type = struct_value () [concrete]
Expand Down
2 changes: 1 addition & 1 deletion toolchain/check/testdata/as/var_init.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn Convert(t: ()) {
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.type.37a: type = facet_type <@ImplicitAs, @ImplicitAs(%X)> [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness: <witness> = impl_witness @X.%ImplicitAs.impl_witness_table [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness: <witness> = impl_witness @empty_tuple.type.as.ImplicitAs.impl.%ImplicitAs.impl_witness_table [concrete]
// CHECK:STDOUT: %ImplicitAs.Convert.type.9f8: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%X) [concrete]
// CHECK:STDOUT: %pattern_type.05f: type = pattern_type %X [concrete]
// CHECK:STDOUT: %empty_tuple.type.as.ImplicitAs.impl.Convert.type: type = fn_type @empty_tuple.type.as.ImplicitAs.impl.Convert [concrete]
Expand Down
2 changes: 1 addition & 1 deletion toolchain/check/testdata/basics/include_in_dumps.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn F(c: C) { c.(I.Op)(); }
// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%I.Op.decl [concrete]
// CHECK:STDOUT: %C: type = class_type @C [concrete]
// CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness @C.%I.impl_witness_table [concrete]
// CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness @C.as.I.impl.%I.impl_witness_table [concrete]
// CHECK:STDOUT: %pattern_type.7c7: type = pattern_type %C [concrete]
// CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
// CHECK:STDOUT: }
Expand Down
4 changes: 2 additions & 2 deletions toolchain/check/testdata/builtins/type/destroy.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ fn F() {
// CHECK:STDOUT: %assoc0: %DestroyLike.assoc_type = assoc_entity element0, @DestroyLike.%DestroyLike.Op.decl [concrete]
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
// CHECK:STDOUT: %DestroyLike.impl_witness.52f: <witness> = impl_witness file.%DestroyLike.impl_witness_table, @T.as.DestroyLike.impl(%empty_tuple.type) [concrete]
// CHECK:STDOUT: %DestroyLike.impl_witness.52f: <witness> = impl_witness @T.as.DestroyLike.impl.%DestroyLike.impl_witness_table, @T.as.DestroyLike.impl(%empty_tuple.type) [concrete]
// CHECK:STDOUT: %T.as.DestroyLike.impl.Op.type.6ca: type = fn_type @T.as.DestroyLike.impl.Op, @T.as.DestroyLike.impl(%empty_tuple.type) [concrete]
// CHECK:STDOUT: %T.as.DestroyLike.impl.Op.3ae: %T.as.DestroyLike.impl.Op.type.6ca = struct_value () [concrete]
// CHECK:STDOUT: %DestroyLike.facet.430: %DestroyLike.type = facet_value %empty_tuple.type, (%DestroyLike.impl_witness.52f) [concrete]
// CHECK:STDOUT: %.bcf: type = fn_type_with_self_type %DestroyLike.Op.type, %DestroyLike.facet.430 [concrete]
// CHECK:STDOUT: %T.as.DestroyLike.impl.Op.bound.f9f: <bound method> = bound_method file.%a.var, %T.as.DestroyLike.impl.Op.3ae [concrete]
// CHECK:STDOUT: %T.as.DestroyLike.impl.Op.specific_fn.38d: <specific function> = specific_function %T.as.DestroyLike.impl.Op.3ae, @T.as.DestroyLike.impl.Op(%empty_tuple.type) [concrete]
// CHECK:STDOUT: %bound_method.717: <bound method> = bound_method file.%a.var, %T.as.DestroyLike.impl.Op.specific_fn.38d [concrete]
// CHECK:STDOUT: %DestroyLike.impl_witness.409: <witness> = impl_witness file.%DestroyLike.impl_witness_table, @T.as.DestroyLike.impl(%empty_struct_type) [concrete]
// CHECK:STDOUT: %DestroyLike.impl_witness.409: <witness> = impl_witness @T.as.DestroyLike.impl.%DestroyLike.impl_witness_table, @T.as.DestroyLike.impl(%empty_struct_type) [concrete]
// CHECK:STDOUT: %T.as.DestroyLike.impl.Op.type.1f5: type = fn_type @T.as.DestroyLike.impl.Op, @T.as.DestroyLike.impl(%empty_struct_type) [concrete]
// CHECK:STDOUT: %T.as.DestroyLike.impl.Op.f28: %T.as.DestroyLike.impl.Op.type.1f5 = struct_value () [concrete]
// CHECK:STDOUT: %DestroyLike.facet.736: %DestroyLike.type = facet_value %empty_struct_type, (%DestroyLike.impl_witness.409) [concrete]
Expand Down
24 changes: 12 additions & 12 deletions toolchain/check/testdata/class/generic/member_type.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ fn Test() -> i32 {
// CHECK:STDOUT: %Inner.assoc_type.be2: type = assoc_entity_type @Inner, @Inner(%T) [symbolic]
// CHECK:STDOUT: %assoc0.0a9: %Inner.assoc_type.be2 = assoc_entity element0, @Inner.%Inner.F.decl [symbolic]
// CHECK:STDOUT: %C.131: type = class_type @C, @C(%T) [symbolic]
// CHECK:STDOUT: %Inner.impl_witness.154: <witness> = impl_witness @C.%Inner.impl_witness_table, @C.as.Inner.impl(%T) [symbolic]
// CHECK:STDOUT: %Inner.impl_witness.154: <witness> = impl_witness @C.as.Inner.impl.%Inner.impl_witness_table, @C.as.Inner.impl(%T) [symbolic]
// CHECK:STDOUT: %require_complete.0f7: <witness> = require_complete_type %Inner.type.e0e [symbolic]
// CHECK:STDOUT: %pattern_type.fe7: type = pattern_type %C.131 [symbolic]
// CHECK:STDOUT: %C.as.Inner.impl.F.type.9a2: type = fn_type @C.as.Inner.impl.F, @C.as.Inner.impl(%T) [symbolic]
Expand All @@ -454,7 +454,7 @@ fn Test() -> i32 {
// CHECK:STDOUT: %Outer.d71: type = class_type @Outer, @Outer(%i32) [concrete]
// CHECK:STDOUT: %Inner.type.b33: type = facet_type <@Inner, @Inner(%i32)> [concrete]
// CHECK:STDOUT: %C.d3f: type = class_type @C, @C(%i32) [concrete]
// CHECK:STDOUT: %Inner.impl_witness.744: <witness> = impl_witness @D.%Inner.impl_witness_table [concrete]
// CHECK:STDOUT: %Inner.impl_witness.744: <witness> = impl_witness @D.as.Inner.impl.%Inner.impl_witness_table [concrete]
// CHECK:STDOUT: %Self.d74: %Inner.type.b33 = symbolic_binding Self, 1 [symbolic]
// CHECK:STDOUT: %Inner.F.type.c8b: type = fn_type @Inner.F, @Inner(%i32) [concrete]
// CHECK:STDOUT: %Inner.F.1cd: %Inner.F.type.c8b = struct_value () [concrete]
Expand All @@ -472,7 +472,7 @@ fn Test() -> i32 {
// CHECK:STDOUT: %pattern_type.129: type = pattern_type %C.d3f [concrete]
// CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
// CHECK:STDOUT: %C.val: %C.d3f = struct_value () [concrete]
// CHECK:STDOUT: %Inner.impl_witness.2d0: <witness> = impl_witness @C.%Inner.impl_witness_table, @C.as.Inner.impl(%i32) [concrete]
// CHECK:STDOUT: %Inner.impl_witness.2d0: <witness> = impl_witness @C.as.Inner.impl.%Inner.impl_witness_table, @C.as.Inner.impl(%i32) [concrete]
// CHECK:STDOUT: %complete_type.75e: <witness> = complete_type_witness %Inner.type.b33 [concrete]
// CHECK:STDOUT: %C.as.Inner.impl.F.type.457: type = fn_type @C.as.Inner.impl.F, @C.as.Inner.impl(%i32) [concrete]
// CHECK:STDOUT: %C.as.Inner.impl.F.cc7: %C.as.Inner.impl.F.type.457 = struct_value () [concrete]
Expand Down Expand Up @@ -571,7 +571,7 @@ fn Test() -> i32 {
// CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %C: type = class_type @C, @C(%T) [symbolic = %C (constants.%C.131)]
// CHECK:STDOUT: %Inner.type: type = facet_type <@Inner, @Inner(%T)> [symbolic = %Inner.type (constants.%Inner.type.e0e)]
// CHECK:STDOUT: %Inner.impl_witness: <witness> = impl_witness @C.%Inner.impl_witness_table, @C.as.Inner.impl(%T) [symbolic = %Inner.impl_witness (constants.%Inner.impl_witness.154)]
// CHECK:STDOUT: %Inner.impl_witness.loc10_19.2: <witness> = impl_witness %Inner.impl_witness_table, @C.as.Inner.impl(%T) [symbolic = %Inner.impl_witness.loc10_19.2 (constants.%Inner.impl_witness.154)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Inner.type [symbolic = %require_complete (constants.%require_complete.0f7)]
Expand All @@ -595,13 +595,15 @@ fn Test() -> i32 {
// CHECK:STDOUT: %return.param: ref @C.as.Inner.impl.F.%T (%T) = out_param call_param1
// CHECK:STDOUT: %return: ref @C.as.Inner.impl.F.%T (%T) = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %Inner.impl_witness_table = impl_witness_table (%C.as.Inner.impl.F.decl), @C.as.Inner.impl [concrete]
// CHECK:STDOUT: %Inner.impl_witness.loc10_19.1: <witness> = impl_witness %Inner.impl_witness_table, @C.as.Inner.impl(constants.%T) [symbolic = %Inner.impl_witness.loc10_19.2 (constants.%Inner.impl_witness.154)]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .C = <poisoned>
// CHECK:STDOUT: .T = <poisoned>
// CHECK:STDOUT: .F = %C.as.Inner.impl.F.decl
// CHECK:STDOUT: .Inner = <poisoned>
// CHECK:STDOUT: witness = @C.%Inner.impl_witness
// CHECK:STDOUT: witness = %Inner.impl_witness.loc10_19.1
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
Expand All @@ -620,11 +622,13 @@ fn Test() -> i32 {
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %Inner.impl_witness_table = impl_witness_table (%D.as.Inner.impl.F.decl), @D.as.Inner.impl [concrete]
// CHECK:STDOUT: %Inner.impl_witness: <witness> = impl_witness %Inner.impl_witness_table [concrete = constants.%Inner.impl_witness.744]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .D = <poisoned>
// CHECK:STDOUT: .F = %D.as.Inner.impl.F.decl
// CHECK:STDOUT: witness = @D.%Inner.impl_witness
// CHECK:STDOUT: witness = %Inner.impl_witness
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic class @Outer(%T.loc4_13.2: type) {
Expand Down Expand Up @@ -657,8 +661,6 @@ fn Test() -> i32 {
// CHECK:STDOUT: %.loc10: type = specific_constant @Outer.%Inner.decl, @Outer(constants.%T) [symbolic = %Inner.type (constants.%Inner.type.e0e)]
// CHECK:STDOUT: %Inner.ref: type = name_ref Inner, %.loc10 [symbolic = %Inner.type (constants.%Inner.type.e0e)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %Inner.impl_witness_table = impl_witness_table (@C.as.Inner.impl.%C.as.Inner.impl.F.decl), @C.as.Inner.impl [concrete]
// CHECK:STDOUT: %Inner.impl_witness: <witness> = impl_witness %Inner.impl_witness_table, @C.as.Inner.impl(constants.%T) [symbolic = @C.as.Inner.impl.%Inner.impl_witness (constants.%Inner.impl_witness.154)]
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT:
Expand All @@ -680,8 +682,6 @@ fn Test() -> i32 {
// CHECK:STDOUT: %.loc17: type = specific_constant @Outer.%Inner.decl, @Outer(constants.%i32) [concrete = constants.%Inner.type.b33]
// CHECK:STDOUT: %Inner.ref: type = name_ref Inner, %.loc17 [concrete = constants.%Inner.type.b33]
// CHECK:STDOUT: }
// CHECK:STDOUT: %Inner.impl_witness_table = impl_witness_table (@D.as.Inner.impl.%D.as.Inner.impl.F.decl), @D.as.Inner.impl [concrete]
// CHECK:STDOUT: %Inner.impl_witness: <witness> = impl_witness %Inner.impl_witness_table [concrete = constants.%Inner.impl_witness.744]
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT:
Expand Down Expand Up @@ -820,7 +820,7 @@ fn Test() -> i32 {
// CHECK:STDOUT: %T => constants.%T
// CHECK:STDOUT: %C => constants.%C.131
// CHECK:STDOUT: %Inner.type => constants.%Inner.type.e0e
// CHECK:STDOUT: %Inner.impl_witness => constants.%Inner.impl_witness.154
// CHECK:STDOUT: %Inner.impl_witness.loc10_19.2 => constants.%Inner.impl_witness.154
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%require_complete.0f7
Expand Down Expand Up @@ -889,7 +889,7 @@ fn Test() -> i32 {
// CHECK:STDOUT: %T => constants.%i32
// CHECK:STDOUT: %C => constants.%C.d3f
// CHECK:STDOUT: %Inner.type => constants.%Inner.type.b33
// CHECK:STDOUT: %Inner.impl_witness => constants.%Inner.impl_witness.2d0
// CHECK:STDOUT: %Inner.impl_witness.loc10_19.2 => constants.%Inner.impl_witness.2d0
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.75e
Expand Down
8 changes: 4 additions & 4 deletions toolchain/check/testdata/class/virtual_modifiers.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,7 @@ class T2(G2:! type) {
// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.type.865: type = facet_type <@ImplicitAs, @ImplicitAs(%T1)> [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness: <witness> = impl_witness file.%ImplicitAs.impl_witness_table [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness: <witness> = impl_witness @T2.as.ImplicitAs.impl.%ImplicitAs.impl_witness_table [concrete]
// CHECK:STDOUT: %pattern_type.b8b: type = pattern_type %T2 [concrete]
// CHECK:STDOUT: %pattern_type.818: type = pattern_type %T1 [concrete]
// CHECK:STDOUT: %T2.as.ImplicitAs.impl.Convert.type: type = fn_type @T2.as.ImplicitAs.impl.Convert [concrete]
Expand Down Expand Up @@ -2055,8 +2055,6 @@ class T2(G2:! type) {
// CHECK:STDOUT: %T1.ref: type = name_ref T1, file.%T1.decl [concrete = constants.%T1]
// CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(constants.%T1)> [concrete = constants.%ImplicitAs.type.865]
// CHECK:STDOUT: }
// CHECK:STDOUT: %ImplicitAs.impl_witness_table = impl_witness_table (@T2.as.ImplicitAs.impl.%T2.as.ImplicitAs.impl.Convert.decl), @T2.as.ImplicitAs.impl [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness: <witness> = impl_witness %ImplicitAs.impl_witness_table [concrete = constants.%ImplicitAs.impl_witness]
// CHECK:STDOUT: %Base.decl: type = class_decl @Base [concrete = constants.%Base] {} {}
// CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [concrete = constants.%Derived] {} {}
// CHECK:STDOUT: }
Expand All @@ -2075,11 +2073,13 @@ class T2(G2:! type) {
// CHECK:STDOUT: %return.param: ref %T1 = out_param call_param1
// CHECK:STDOUT: %return: ref %T1 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %ImplicitAs.impl_witness_table = impl_witness_table (%T2.as.ImplicitAs.impl.Convert.decl), @T2.as.ImplicitAs.impl [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness: <witness> = impl_witness %ImplicitAs.impl_witness_table [concrete = constants.%ImplicitAs.impl_witness]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .T1 = <poisoned>
// CHECK:STDOUT: .Convert = %T2.as.ImplicitAs.impl.Convert.decl
// CHECK:STDOUT: witness = file.%ImplicitAs.impl_witness
// CHECK:STDOUT: witness = %ImplicitAs.impl_witness
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @T1 {
Expand Down
Loading
Loading