diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index f06a0d65c563..92265f83535d 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -475,33 +475,6 @@ static auto RequireConstantValue(EvalContext& eval_context, return SemIR::ErrorInst::InstId; } -// If the given instruction is constant, returns its constant value. Otherwise, -// produces an error diagnostic. When determining the phase of the result, -// ignore any dependence on `.Self`. -// -// This is used when evaluating facet types, for which `where` expressions using -// `.Self` should not be considered symbolic -// - `Interface where .Self impls I and .A = bool` -> concrete -// - `T:! type` ... `Interface where .A = T` -> symbolic, since uses `T` which -// is symbolic and not due to `.Self`. -static auto RequireConstantValueIgnoringPeriodSelf(EvalContext& eval_context, - SemIR::InstId inst_id, - Phase* phase) - -> SemIR::InstId { - if (!inst_id.has_value()) { - return SemIR::InstId::None; - } - Phase constant_phase = *phase; - auto const_inst_id = - RequireConstantValue(eval_context, inst_id, &constant_phase); - // Since LatestPhase(x, Phase::Concrete) == x, this is equivalent to replacing - // Phase::PeriodSelfSymbolic with Phase::Concrete. - if (constant_phase != Phase::PeriodSelfSymbolic) { - *phase = LatestPhase(*phase, constant_phase); - } - return const_inst_id; -} - // Gets a constant value for an `inst_id`, diagnosing when the input is not // constant, and CHECKing that it is concrete. Should only be used in contexts // where non-concrete constants cannot appear. @@ -723,6 +696,10 @@ static auto GetConstantFacetTypeInfo(EvalContext& eval_context, Phase* phase) -> SemIR::FacetTypeInfo { SemIR::FacetTypeInfo info = {}; + // Phase of constraints whose `.Self` refers to the type constrained by this + // facet type. + Phase self_phase = Phase::Concrete; + info.extend_constraints.reserve(orig.extend_constraints.size()); for (const auto& extend : orig.extend_constraints) { // TODO: Add GetConstantValue for SpecificInterface. @@ -737,8 +714,8 @@ static auto GetConstantFacetTypeInfo(EvalContext& eval_context, // TODO: Add GetConstantValue for SpecificInterface. info.self_impls_constraints.push_back( {.interface_id = self_impls.interface_id, - .specific_id = - GetConstantValue(eval_context, self_impls.specific_id, phase)}); + .specific_id = GetConstantValue(eval_context, self_impls.specific_id, + &self_phase)}); } info.extend_named_constraints.reserve(orig.extend_named_constraints.size()); @@ -756,21 +733,21 @@ static auto GetConstantFacetTypeInfo(EvalContext& eval_context, // TODO: Add GetConstantValue for SpecificNamedConstraint. info.self_impls_named_constraints.push_back( {.named_constraint_id = self_impls.named_constraint_id, - .specific_id = - GetConstantValue(eval_context, self_impls.specific_id, phase)}); + .specific_id = GetConstantValue(eval_context, self_impls.specific_id, + &self_phase)}); } info.type_impls_interfaces.reserve(orig.type_impls_interfaces.size()); for (const auto& type_impls : orig.type_impls_interfaces) { info.type_impls_interfaces.push_back( {.self_type = - GetConstantValue(eval_context, type_impls.self_type, phase), + GetConstantValue(eval_context, type_impls.self_type, &self_phase), // TODO: Add GetConstantValue for SpecificInterface. .specific_interface = { .interface_id = type_impls.specific_interface.interface_id, .specific_id = GetConstantValue( eval_context, type_impls.specific_interface.specific_id, - phase)}}); + &self_phase)}}); } info.type_impls_named_constraints.reserve( @@ -778,14 +755,14 @@ static auto GetConstantFacetTypeInfo(EvalContext& eval_context, for (const auto& type_impls : orig.type_impls_named_constraints) { info.type_impls_named_constraints.push_back( {.self_type = - GetConstantValue(eval_context, type_impls.self_type, phase), + GetConstantValue(eval_context, type_impls.self_type, &self_phase), // TODO: Add GetConstantValue for SpecificNamedConstraint. .specific_named_constraint = { .named_constraint_id = type_impls.specific_named_constraint.named_constraint_id, .specific_id = GetConstantValue( eval_context, type_impls.specific_named_constraint.specific_id, - phase)}}); + &self_phase)}}); } // Rewrite constraints are resolved first before replacing them with their @@ -806,14 +783,19 @@ static auto GetConstantFacetTypeInfo(EvalContext& eval_context, } for (auto& rewrite : info.rewrite_constraints) { - // `where` requirements using `.Self` should not be considered symbolic. - auto lhs_id = RequireConstantValueIgnoringPeriodSelf(eval_context, - rewrite.lhs_id, phase); - auto rhs_id = RequireConstantValueIgnoringPeriodSelf(eval_context, - rewrite.rhs_id, phase); + auto lhs_id = + RequireConstantValue(eval_context, rewrite.lhs_id, &self_phase); + auto rhs_id = + RequireConstantValue(eval_context, rewrite.rhs_id, &self_phase); rewrite = {.lhs_id = lhs_id, .rhs_id = rhs_id}; } + // Update phase, ignoring `.Self` dependence from constraints whose `.Self` is + // scoped to this facet type. + if (self_phase > Phase::PeriodSelfSymbolic) { + *phase = LatestPhase(*phase, self_phase); + } + // TODO: Process other requirements. info.other_requirements = orig.other_requirements; diff --git a/toolchain/check/testdata/deduce/binding_pattern.carbon b/toolchain/check/testdata/deduce/binding_pattern.carbon index d5c14edaf825..b8d6fcd358b1 100644 --- a/toolchain/check/testdata/deduce/binding_pattern.carbon +++ b/toolchain/check/testdata/deduce/binding_pattern.carbon @@ -274,8 +274,8 @@ fn F(unused U:! type, V:! Core.Destroy where {} impls Core.ImplicitAs(.Self)) { // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.751: %ImplicitAs.WithSelf.Convert.type.7c0 = struct_value () [symbolic] // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.d91 [symbolic_self] // CHECK:STDOUT: %ImplicitAs.type.33a: type = facet_type <@ImplicitAs, @ImplicitAs(%.Self.as_type)> [symbolic_self] -// CHECK:STDOUT: %Destroy_where.type: type = facet_type <@Destroy where %empty_struct_type impls @ImplicitAs, @ImplicitAs(%.Self.as_type)> [symbolic_self] -// CHECK:STDOUT: %pattern_type.785: type = pattern_type %Destroy_where.type [symbolic_self] +// CHECK:STDOUT: %Destroy_where.type: type = facet_type <@Destroy where %empty_struct_type impls @ImplicitAs, @ImplicitAs(%.Self.as_type)> [concrete] +// CHECK:STDOUT: %pattern_type.785: type = pattern_type %Destroy_where.type [concrete] // CHECK:STDOUT: %V: %Destroy_where.type = symbolic_binding V, 1 [symbolic] // CHECK:STDOUT: %F.type: type = fn_type @F [concrete] // CHECK:STDOUT: %F: %F.type = struct_value () [concrete] @@ -347,7 +347,7 @@ fn F(unused U:! type, V:! Core.Destroy where {} impls Core.ImplicitAs(.Self)) { // CHECK:STDOUT: %.loc9_17.2: type = type_literal type [concrete = type] // CHECK:STDOUT: } // CHECK:STDOUT: %U.loc9_14.2: type = symbolic_binding U, 0 [symbolic = %U.loc9_14.1 (constants.%U)] -// CHECK:STDOUT: %.loc9_40.1: type = splice_block %.loc9_40.2 [symbolic_self = constants.%Destroy_where.type] { +// CHECK:STDOUT: %.loc9_40.1: type = splice_block %.loc9_40.2 [concrete = constants.%Destroy_where.type] { // CHECK:STDOUT: %.Self.loc9_24: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.c39] // CHECK:STDOUT: %Core.ref.loc9_27: = name_ref Core, imports.%Core [concrete = imports.%Core] // CHECK:STDOUT: %Destroy.ref: type = name_ref Destroy, imports.%Core.Destroy [concrete = constants.%Destroy.type] @@ -360,7 +360,7 @@ fn F(unused U:! type, V:! Core.Destroy where {} impls Core.ImplicitAs(.Self)) { // CHECK:STDOUT: %.loc9_76: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type] // CHECK:STDOUT: %ImplicitAs.type.loc9: type = facet_type <@ImplicitAs, @ImplicitAs(constants.%.Self.as_type)> [symbolic_self = constants.%ImplicitAs.type.33a] // CHECK:STDOUT: %.loc9_47.2: type = converted %.loc9_47.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type] -// CHECK:STDOUT: %.loc9_40.2: type = where_expr [symbolic_self = constants.%Destroy_where.type] { +// CHECK:STDOUT: %.loc9_40.2: type = where_expr [concrete = constants.%Destroy_where.type] { // CHECK:STDOUT: requirement_base_facet_type %Destroy.ref // CHECK:STDOUT: requirement_impls %.loc9_47.2, %ImplicitAs.type.loc9 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/facet/validate_impl_constraints.carbon b/toolchain/check/testdata/facet/validate_impl_constraints.carbon index 82e6a479a95f..e9dbf8b287ae 100644 --- a/toolchain/check/testdata/facet/validate_impl_constraints.carbon +++ b/toolchain/check/testdata/facet/validate_impl_constraints.carbon @@ -62,9 +62,9 @@ fn G(T:! L) { // CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_type_non_final_impl.carbon:[[@LINE+7]]:3: error: cannot convert type `T` that implements `L` into type implementing `type where C(.Self) impls M and C(.Self).(M.M0) = {}` [ConversionFailureFacetToFacet] // CHECK:STDERR: F(T); // CHECK:STDERR: ^~~~ - // CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_type_non_final_impl.carbon:[[@LINE-10]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] + // CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_type_non_final_impl.carbon:[[@LINE-10]]:13: note: initializing generic parameter `U` declared here [InitializingGenericParam] // CHECK:STDERR: fn F(unused U:! type where C(.Self) impls (M where .M0 = {})) {} - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: F(T); } @@ -107,9 +107,9 @@ fn G(T:! L) { // CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_type_type_differs.carbon:[[@LINE+7]]:3: error: cannot convert type `T` that implements `L` into type implementing `type where C(.Self) impls M and C(.Self).(M.M0) = {}` [ConversionFailureFacetToFacet] // CHECK:STDERR: F(T); // CHECK:STDERR: ^~~~ - // CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_type_type_differs.carbon:[[@LINE-6]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] + // CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_type_type_differs.carbon:[[@LINE-6]]:13: note: initializing generic parameter `U` declared here [InitializingGenericParam] // CHECK:STDERR: fn F(unused U:! type where C(.Self) impls (M where .M0 = {})) {} - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: F(T); } @@ -137,9 +137,9 @@ fn G(T:! L) { // CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_interface_non_final_impl.carbon:[[@LINE+7]]:3: error: cannot convert type `T` that implements `L` into type implementing `type where C impls M(.Self) and C.(M(.Self).M0) = {}` [ConversionFailureFacetToFacet] // CHECK:STDERR: F(T); // CHECK:STDERR: ^~~~ - // CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_interface_non_final_impl.carbon:[[@LINE-10]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] + // CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_interface_non_final_impl.carbon:[[@LINE-10]]:13: note: initializing generic parameter `U` declared here [InitializingGenericParam] // CHECK:STDERR: fn F(unused U:! type where C impls (M(.Self) where .M0 = {})) {} - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: F(T); } @@ -182,9 +182,9 @@ fn G(T:! L) { // CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_interface_type_differs.carbon:[[@LINE+7]]:3: error: cannot convert type `T` that implements `L` into type implementing `type where C impls M(.Self) and C.(M(.Self).M0) = {}` [ConversionFailureFacetToFacet] // CHECK:STDERR: F(T); // CHECK:STDERR: ^~~~ - // CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_interface_type_differs.carbon:[[@LINE-6]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] + // CHECK:STDERR: fail_where_impls_tests_associated_constant_of_generic_interface_type_differs.carbon:[[@LINE-6]]:13: note: initializing generic parameter `U` declared here [InitializingGenericParam] // CHECK:STDERR: fn F(unused U:! type where C impls (M(.Self) where .M0 = {})) {} - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: F(T); } @@ -356,9 +356,9 @@ fn G() { // CHECK:STDERR: fail_concrete_witness_without_impl.carbon:[[@LINE+7]]:3: error: cannot convert type `C` into type implementing `I where .(I.I1) impls J` [ConversionFailureTypeToFacet] // CHECK:STDERR: F(C); // CHECK:STDERR: ^~~~ - // CHECK:STDERR: fail_concrete_witness_without_impl.carbon:[[@LINE-16]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] + // CHECK:STDERR: fail_concrete_witness_without_impl.carbon:[[@LINE-16]]:6: note: initializing generic parameter `_` declared here [InitializingGenericParam] // CHECK:STDERR: fn F(_:! I where .I1 impls J) {} - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: F(C); } diff --git a/toolchain/check/testdata/impl/assoc_const_self.carbon b/toolchain/check/testdata/impl/assoc_const_self.carbon index b6ed357236e1..445156c467e0 100644 --- a/toolchain/check/testdata/impl/assoc_const_self.carbon +++ b/toolchain/check/testdata/impl/assoc_const_self.carbon @@ -93,9 +93,9 @@ fn CallF() { // CHECK:STDERR: fail_todo_constrained_fn.carbon:[[@LINE+7]]:3: error: cannot convert type `{}` into type implementing `I where {} impls Core.ImplicitAs(.Self) and .(I.V) = {}` [ConversionFailureTypeToFacet] // CHECK:STDERR: F({}); // CHECK:STDERR: ^~~~~ - // CHECK:STDERR: fail_todo_constrained_fn.carbon:[[@LINE-7]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] + // CHECK:STDERR: fail_todo_constrained_fn.carbon:[[@LINE-7]]:6: note: initializing generic parameter `T` declared here [InitializingGenericParam] // CHECK:STDERR: fn F(T:! I where {} impls Core.ImplicitAs(.Self) and .V = {}); - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: F({}); } @@ -750,8 +750,8 @@ fn CallF() { // CHECK:STDOUT: %ImplicitAs.type.7ec: type = facet_type <@ImplicitAs, @ImplicitAs(%.Self.as_type)> [symbolic_self] // CHECK:STDOUT: %I.lookup_impl_witness.5fc: = lookup_impl_witness %.Self.908, @I [symbolic_self] // CHECK:STDOUT: %impl.elem0: %.Self.as_type = impl_witness_access %I.lookup_impl_witness.5fc, element0 [symbolic_self] -// CHECK:STDOUT: %I_where.type: type = facet_type <@I where %empty_struct_type impls @ImplicitAs, @ImplicitAs(%.Self.as_type) and %impl.elem0 = %empty_struct> [symbolic_self] -// CHECK:STDOUT: %pattern_type.010: type = pattern_type %I_where.type [symbolic_self] +// CHECK:STDOUT: %I_where.type: type = facet_type <@I where %empty_struct_type impls @ImplicitAs, @ImplicitAs(%.Self.as_type) and %impl.elem0 = %empty_struct> [concrete] +// CHECK:STDOUT: %pattern_type.010: type = pattern_type %I_where.type [concrete] // CHECK:STDOUT: %T: %I_where.type = symbolic_binding T, 0 [symbolic] // CHECK:STDOUT: %F.type: type = fn_type @F [concrete] // CHECK:STDOUT: %F: %F.type = struct_value () [concrete] @@ -780,7 +780,7 @@ fn CallF() { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] { // CHECK:STDOUT: %T.patt: %pattern_type.010 = symbolic_binding_pattern T, 0 [concrete] // CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc8_12.1: type = splice_block %.loc8_12.2 [symbolic_self = constants.%I_where.type] { +// CHECK:STDOUT: %.loc8_12.1: type = splice_block %.loc8_12.2 [concrete = constants.%I_where.type] { // CHECK:STDOUT: %.Self.loc8_7: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.c39] // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type] // CHECK:STDOUT: %.Self.loc8_12: %I.type = symbolic_binding .Self [symbolic_self = constants.%.Self.908] @@ -800,7 +800,7 @@ fn CallF() { // CHECK:STDOUT: %.loc8_60.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct] // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete = constants.%empty_struct] // CHECK:STDOUT: %.loc8_60.2: %empty_struct_type = converted %.loc8_60.1, %empty_struct [concrete = constants.%empty_struct] -// CHECK:STDOUT: %.loc8_12.2: type = where_expr [symbolic_self = constants.%I_where.type] { +// CHECK:STDOUT: %.loc8_12.2: type = where_expr [concrete = constants.%I_where.type] { // CHECK:STDOUT: requirement_base_facet_type %I.ref // CHECK:STDOUT: requirement_impls %.loc8_19.2, %ImplicitAs.type // CHECK:STDOUT: requirement_rewrite %impl.elem0, %.loc8_60.2 diff --git a/toolchain/check/testdata/interop/cpp/range_for.carbon b/toolchain/check/testdata/interop/cpp/range_for.carbon index 6220ef0c82c2..37bed9df2e1d 100644 --- a/toolchain/check/testdata/interop/cpp/range_for.carbon +++ b/toolchain/check/testdata/interop/cpp/range_for.carbon @@ -477,7 +477,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %impl.elem0.354: type = impl_witness_access %CppRangeForIterate.lookup_impl_witness.ae8, element0 [symbolic_self] // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete] // CHECK:STDOUT: %impl.elem1.fdc: type = impl_witness_access %CppRangeForIterate.lookup_impl_witness.ae8, element1 [symbolic_self] -// CHECK:STDOUT: %CppRangeForIterate_where.type: type = facet_type <@CppRangeForIterate where %impl.elem0.354 impls @Destroy and %impl.elem1.fdc impls @Destroy> [symbolic_self] +// CHECK:STDOUT: %CppRangeForIterate_where.type: type = facet_type <@CppRangeForIterate where %impl.elem0.354 impls @Destroy and %impl.elem1.fdc impls @Destroy> [concrete] // CHECK:STDOUT: %R: %CppRangeForIterate_where.type = symbolic_binding R, 0 [symbolic] // CHECK:STDOUT: %R.as_type: type = facet_access_type %R [symbolic] // CHECK:STDOUT: %pattern_type.ff859f.2: type = pattern_type %R.as_type [symbolic] @@ -524,7 +524,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %Iterator.Op.type.f11: type = fn_type @Iterator.Op.1 [concrete] // CHECK:STDOUT: %Iterator.Op.78e: %Iterator.Op.type.f11 = struct_value () [concrete] // CHECK:STDOUT: %custom_witness.b91: = custom_witness (%Iterator.Op.78e), @Destroy [concrete] -// CHECK:STDOUT: %facet_value.665: %CppRangeForIterate_where.type = facet_value %MutableRange, (%custom_witness.7e3fb2.1, %custom_witness.b91) [symbolic_self] +// CHECK:STDOUT: %facet_value.665: %CppRangeForIterate_where.type = facet_value %MutableRange, (%custom_witness.7e3fb2.1, %custom_witness.b91) [concrete] // CHECK:STDOUT: %Iterator.a7566c.2: type = class_type @Iterator.2 [concrete] // CHECK:STDOUT: %ConstRange.Begin.type: type = fn_type @ConstRange.Begin [concrete] // CHECK:STDOUT: %ConstRange.Begin: %ConstRange.Begin.type = struct_value () [concrete] @@ -535,7 +535,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %Iterator.Op.type.798: type = fn_type @Iterator.Op.2 [concrete] // CHECK:STDOUT: %Iterator.Op.250: %Iterator.Op.type.798 = struct_value () [concrete] // CHECK:STDOUT: %custom_witness.018: = custom_witness (%Iterator.Op.250), @Destroy [concrete] -// CHECK:STDOUT: %facet_value.57a: %CppRangeForIterate_where.type = facet_value %ConstRange, (%custom_witness.7e3fb2.2, %custom_witness.018) [symbolic_self] +// CHECK:STDOUT: %facet_value.57a: %CppRangeForIterate_where.type = facet_value %ConstRange, (%custom_witness.7e3fb2.2, %custom_witness.018) [concrete] // CHECK:STDOUT: %CppRangeForIterate.WithSelf.Begin.type.a13: type = fn_type @CppRangeForIterate.WithSelf.Begin, @CppRangeForIterate.WithSelf(%CppRangeForIterate.facet.d24) [concrete] // CHECK:STDOUT: %.a34: type = fn_type_with_self_type %CppRangeForIterate.WithSelf.Begin.type.a13, %CppRangeForIterate.facet.d24 [concrete] // CHECK:STDOUT: %CppRangeForIterate.WithSelf.End.type.e9f: type = fn_type @CppRangeForIterate.WithSelf.End, @CppRangeForIterate.WithSelf(%CppRangeForIterate.facet.d24) [concrete] @@ -714,7 +714,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %impl.elem0.354: type = impl_witness_access %CppRangeForIterate.lookup_impl_witness.ae8, element0 [symbolic_self] // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete] // CHECK:STDOUT: %impl.elem1.fdc: type = impl_witness_access %CppRangeForIterate.lookup_impl_witness.ae8, element1 [symbolic_self] -// CHECK:STDOUT: %CppRangeForIterate_where.type: type = facet_type <@CppRangeForIterate where %impl.elem0.354 impls @Destroy and %impl.elem1.fdc impls @Destroy> [symbolic_self] +// CHECK:STDOUT: %CppRangeForIterate_where.type: type = facet_type <@CppRangeForIterate where %impl.elem0.354 impls @Destroy and %impl.elem1.fdc impls @Destroy> [concrete] // CHECK:STDOUT: %R: %CppRangeForIterate_where.type = symbolic_binding R, 0 [symbolic] // CHECK:STDOUT: %R.as_type: type = facet_access_type %R [symbolic] // CHECK:STDOUT: %pattern_type.ff859f.2: type = pattern_type %R.as_type [symbolic] @@ -765,7 +765,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %Sentinel.Op.type.f11: type = fn_type @Sentinel.Op.1 [concrete] // CHECK:STDOUT: %Sentinel.Op.78e: %Sentinel.Op.type.f11 = struct_value () [concrete] // CHECK:STDOUT: %custom_witness.b916b4.2: = custom_witness (%Sentinel.Op.78e), @Destroy [concrete] -// CHECK:STDOUT: %facet_value.8f5: %CppRangeForIterate_where.type = facet_value %MutableRange, (%custom_witness.607036.1, %custom_witness.b916b4.1, %custom_witness.b916b4.2) [symbolic_self] +// CHECK:STDOUT: %facet_value.8f5: %CppRangeForIterate_where.type = facet_value %MutableRange, (%custom_witness.607036.1, %custom_witness.b916b4.1, %custom_witness.b916b4.2) [concrete] // CHECK:STDOUT: %Iterator.a7566c.2: type = class_type @Iterator.2 [concrete] // CHECK:STDOUT: %Sentinel.885798.2: type = class_type @Sentinel.2 [concrete] // CHECK:STDOUT: %ConstRange.Begin.type: type = fn_type @ConstRange.Begin [concrete] @@ -780,7 +780,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %Sentinel.Op.type.798: type = fn_type @Sentinel.Op.2 [concrete] // CHECK:STDOUT: %Sentinel.Op.250: %Sentinel.Op.type.798 = struct_value () [concrete] // CHECK:STDOUT: %custom_witness.0183d1.2: = custom_witness (%Sentinel.Op.250), @Destroy [concrete] -// CHECK:STDOUT: %facet_value.058: %CppRangeForIterate_where.type = facet_value %ConstRange, (%custom_witness.607036.2, %custom_witness.0183d1.1, %custom_witness.0183d1.2) [symbolic_self] +// CHECK:STDOUT: %facet_value.058: %CppRangeForIterate_where.type = facet_value %ConstRange, (%custom_witness.607036.2, %custom_witness.0183d1.1, %custom_witness.0183d1.2) [concrete] // CHECK:STDOUT: %CppRangeForIterate.WithSelf.Begin.type.dc4: type = fn_type @CppRangeForIterate.WithSelf.Begin, @CppRangeForIterate.WithSelf(%CppRangeForIterate.facet.5b8) [concrete] // CHECK:STDOUT: %.314: type = fn_type_with_self_type %CppRangeForIterate.WithSelf.Begin.type.dc4, %CppRangeForIterate.facet.5b8 [concrete] // CHECK:STDOUT: %CppRangeForIterate.WithSelf.End.type.143: type = fn_type @CppRangeForIterate.WithSelf.End, @CppRangeForIterate.WithSelf(%CppRangeForIterate.facet.5b8) [concrete] @@ -965,7 +965,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %impl.elem0.354: type = impl_witness_access %CppRangeForIterate.lookup_impl_witness.ae8, element0 [symbolic_self] // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete] // CHECK:STDOUT: %impl.elem1.fdc: type = impl_witness_access %CppRangeForIterate.lookup_impl_witness.ae8, element1 [symbolic_self] -// CHECK:STDOUT: %CppRangeForIterate_where.type: type = facet_type <@CppRangeForIterate where %impl.elem0.354 impls @Destroy and %impl.elem1.fdc impls @Destroy> [symbolic_self] +// CHECK:STDOUT: %CppRangeForIterate_where.type: type = facet_type <@CppRangeForIterate where %impl.elem0.354 impls @Destroy and %impl.elem1.fdc impls @Destroy> [concrete] // CHECK:STDOUT: %R: %CppRangeForIterate_where.type = symbolic_binding R, 0 [symbolic] // CHECK:STDOUT: %R.as_type: type = facet_access_type %R [symbolic] // CHECK:STDOUT: %pattern_type.ff859f.2: type = pattern_type %R.as_type [symbolic] @@ -1012,7 +1012,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %Iterator.Op.type.37d: type = fn_type @Iterator.Op.1 [concrete] // CHECK:STDOUT: %Iterator.Op.26b: %Iterator.Op.type.37d = struct_value () [concrete] // CHECK:STDOUT: %custom_witness.415: = custom_witness (%Iterator.Op.26b), @Destroy [concrete] -// CHECK:STDOUT: %facet_value.c35: %CppRangeForIterate_where.type = facet_value %MutableRange, (%custom_witness.827774.1, %custom_witness.415) [symbolic_self] +// CHECK:STDOUT: %facet_value.c35: %CppRangeForIterate_where.type = facet_value %MutableRange, (%custom_witness.827774.1, %custom_witness.415) [concrete] // CHECK:STDOUT: %Iterator.b6bc8f.2: type = class_type @Iterator.2 [concrete] // CHECK:STDOUT: %Begin.type.793876.2: type = fn_type @Begin.2 [concrete] // CHECK:STDOUT: %Begin.1544bb.2: %Begin.type.793876.2 = struct_value () [concrete] @@ -1023,7 +1023,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %Iterator.Op.type.152: type = fn_type @Iterator.Op.2 [concrete] // CHECK:STDOUT: %Iterator.Op.84b: %Iterator.Op.type.152 = struct_value () [concrete] // CHECK:STDOUT: %custom_witness.0d3: = custom_witness (%Iterator.Op.84b), @Destroy [concrete] -// CHECK:STDOUT: %facet_value.057: %CppRangeForIterate_where.type = facet_value %ConstRange, (%custom_witness.827774.2, %custom_witness.0d3) [symbolic_self] +// CHECK:STDOUT: %facet_value.057: %CppRangeForIterate_where.type = facet_value %ConstRange, (%custom_witness.827774.2, %custom_witness.0d3) [concrete] // CHECK:STDOUT: %CppRangeForIterate.WithSelf.Begin.type.bfa: type = fn_type @CppRangeForIterate.WithSelf.Begin, @CppRangeForIterate.WithSelf(%CppRangeForIterate.facet.a7f) [concrete] // CHECK:STDOUT: %.73f: type = fn_type_with_self_type %CppRangeForIterate.WithSelf.Begin.type.bfa, %CppRangeForIterate.facet.a7f [concrete] // CHECK:STDOUT: %CppRangeForIterate.WithSelf.End.type.c37: type = fn_type @CppRangeForIterate.WithSelf.End, @CppRangeForIterate.WithSelf(%CppRangeForIterate.facet.a7f) [concrete] @@ -1202,7 +1202,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %impl.elem0.354: type = impl_witness_access %CppRangeForIterate.lookup_impl_witness.ae8, element0 [symbolic_self] // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete] // CHECK:STDOUT: %impl.elem1.fdc: type = impl_witness_access %CppRangeForIterate.lookup_impl_witness.ae8, element1 [symbolic_self] -// CHECK:STDOUT: %CppRangeForIterate_where.type: type = facet_type <@CppRangeForIterate where %impl.elem0.354 impls @Destroy and %impl.elem1.fdc impls @Destroy> [symbolic_self] +// CHECK:STDOUT: %CppRangeForIterate_where.type: type = facet_type <@CppRangeForIterate where %impl.elem0.354 impls @Destroy and %impl.elem1.fdc impls @Destroy> [concrete] // CHECK:STDOUT: %R: %CppRangeForIterate_where.type = symbolic_binding R, 0 [symbolic] // CHECK:STDOUT: %R.as_type: type = facet_access_type %R [symbolic] // CHECK:STDOUT: %pattern_type.ff859f.2: type = pattern_type %R.as_type [symbolic] @@ -1253,7 +1253,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %Sentinel.Op.type.37d: type = fn_type @Sentinel.Op.1 [concrete] // CHECK:STDOUT: %Sentinel.Op.26b: %Sentinel.Op.type.37d = struct_value () [concrete] // CHECK:STDOUT: %custom_witness.415faa.2: = custom_witness (%Sentinel.Op.26b), @Destroy [concrete] -// CHECK:STDOUT: %facet_value.b34: %CppRangeForIterate_where.type = facet_value %MutableRange, (%custom_witness.1bf5e5.1, %custom_witness.415faa.1, %custom_witness.415faa.2) [symbolic_self] +// CHECK:STDOUT: %facet_value.b34: %CppRangeForIterate_where.type = facet_value %MutableRange, (%custom_witness.1bf5e5.1, %custom_witness.415faa.1, %custom_witness.415faa.2) [concrete] // CHECK:STDOUT: %Iterator.b6bc8f.2: type = class_type @Iterator.2 [concrete] // CHECK:STDOUT: %Sentinel.50a788.2: type = class_type @Sentinel.2 [concrete] // CHECK:STDOUT: %Begin.type.793876.2: type = fn_type @Begin.2 [concrete] @@ -1268,7 +1268,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %Sentinel.Op.type.152: type = fn_type @Sentinel.Op.2 [concrete] // CHECK:STDOUT: %Sentinel.Op.84b: %Sentinel.Op.type.152 = struct_value () [concrete] // CHECK:STDOUT: %custom_witness.0d3cfa.2: = custom_witness (%Sentinel.Op.84b), @Destroy [concrete] -// CHECK:STDOUT: %facet_value.11c: %CppRangeForIterate_where.type = facet_value %ConstRange, (%custom_witness.1bf5e5.2, %custom_witness.0d3cfa.1, %custom_witness.0d3cfa.2) [symbolic_self] +// CHECK:STDOUT: %facet_value.11c: %CppRangeForIterate_where.type = facet_value %ConstRange, (%custom_witness.1bf5e5.2, %custom_witness.0d3cfa.1, %custom_witness.0d3cfa.2) [concrete] // CHECK:STDOUT: %CppRangeForIterate.WithSelf.Begin.type.bf8: type = fn_type @CppRangeForIterate.WithSelf.Begin, @CppRangeForIterate.WithSelf(%CppRangeForIterate.facet.d1e) [concrete] // CHECK:STDOUT: %.504: type = fn_type_with_self_type %CppRangeForIterate.WithSelf.Begin.type.bf8, %CppRangeForIterate.facet.d1e [concrete] // CHECK:STDOUT: %CppRangeForIterate.WithSelf.End.type.580: type = fn_type @CppRangeForIterate.WithSelf.End, @CppRangeForIterate.WithSelf(%CppRangeForIterate.facet.d1e) [concrete] @@ -1453,7 +1453,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %impl.elem0.354: type = impl_witness_access %CppRangeForIterate.lookup_impl_witness.ae8, element0 [symbolic_self] // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete] // CHECK:STDOUT: %impl.elem1.fdc: type = impl_witness_access %CppRangeForIterate.lookup_impl_witness.ae8, element1 [symbolic_self] -// CHECK:STDOUT: %CppRangeForIterate_where.type: type = facet_type <@CppRangeForIterate where %impl.elem0.354 impls @Destroy and %impl.elem1.fdc impls @Destroy> [symbolic_self] +// CHECK:STDOUT: %CppRangeForIterate_where.type: type = facet_type <@CppRangeForIterate where %impl.elem0.354 impls @Destroy and %impl.elem1.fdc impls @Destroy> [concrete] // CHECK:STDOUT: %R: %CppRangeForIterate_where.type = symbolic_binding R, 0 [symbolic] // CHECK:STDOUT: %R.as_type: type = facet_access_type %R [symbolic] // CHECK:STDOUT: %pattern_type.ff859f.2: type = pattern_type %R.as_type [symbolic] @@ -1498,7 +1498,7 @@ fn TestDriver(var no_begin_end: Cpp.NoBeginEnd, // CHECK:STDOUT: %Iterator.Op.type: type = fn_type @Iterator.Op [concrete] // CHECK:STDOUT: %Iterator.Op: %Iterator.Op.type = struct_value () [concrete] // CHECK:STDOUT: %custom_witness.2d3: = custom_witness (%Iterator.Op), @Destroy [concrete] -// CHECK:STDOUT: %facet_value: %CppRangeForIterate_where.type = facet_value %MutableAndConstRange, (%custom_witness.827, %custom_witness.2d3) [symbolic_self] +// CHECK:STDOUT: %facet_value: %CppRangeForIterate_where.type = facet_value %MutableAndConstRange, (%custom_witness.827, %custom_witness.2d3) [concrete] // CHECK:STDOUT: %CppRangeForIterate.WithSelf.Begin.type.706: type = fn_type @CppRangeForIterate.WithSelf.Begin, @CppRangeForIterate.WithSelf(%CppRangeForIterate.facet.98b) [concrete] // CHECK:STDOUT: %.ff3: type = fn_type_with_self_type %CppRangeForIterate.WithSelf.Begin.type.706, %CppRangeForIterate.facet.98b [concrete] // CHECK:STDOUT: %CppRangeForIterate.WithSelf.End.type.5f8: type = fn_type @CppRangeForIterate.WithSelf.End, @CppRangeForIterate.WithSelf(%CppRangeForIterate.facet.98b) [concrete] diff --git a/toolchain/check/testdata/named_constraint/require.carbon b/toolchain/check/testdata/named_constraint/require.carbon index 1e6e9f2ebdd6..a8de65b2798b 100644 --- a/toolchain/check/testdata/named_constraint/require.carbon +++ b/toolchain/check/testdata/named_constraint/require.carbon @@ -1425,7 +1425,7 @@ constraint N { // CHECK:STDOUT: %.Self.c14: %Z.type = symbolic_binding .Self [symbolic_self] // CHECK:STDOUT: %.Self.as_type.324: type = facet_access_type %.Self.c14 [symbolic_self] // CHECK:STDOUT: %Y.type.e27: type = facet_type <@Y, @Y(%.Self.as_type.324)> [symbolic_self] -// CHECK:STDOUT: %Z_where.type.87e: type = facet_type <@Z where .Self impls @Y, @Y(%.Self.as_type.324)> [symbolic_self] +// CHECK:STDOUT: %Z_where.type.87e: type = facet_type <@Z where .Self impls @Y, @Y(%.Self.as_type.324)> [concrete] // CHECK:STDOUT: %Z_where.type.f50: type = facet_type <@Z where .Self impls @Y, @Y(%Self.as_type.4b4)> [symbolic] // CHECK:STDOUT: %.Self.as_type.246: type = facet_access_type %.Self.c39 [symbolic_self] // CHECK:STDOUT: %facet_type: type = facet_type <@Z & @Y, @Y(%.Self.as_type.246)> [symbolic_self] @@ -1457,7 +1457,7 @@ constraint N { // CHECK:STDOUT: %Y.type: type = facet_type <@Y, @Y(constants.%.Self.as_type.324)> [symbolic_self = constants.%Y.type.e27] // CHECK:STDOUT: %.Self.as_type.loc10_25: type = facet_access_type %.Self.ref.loc10_25 [symbolic_self = constants.%.Self.as_type.324] // CHECK:STDOUT: %.loc10_25: type = converted %.Self.ref.loc10_25, %.Self.as_type.loc10_25 [symbolic_self = constants.%.Self.as_type.324] -// CHECK:STDOUT: %.loc10_19: type = where_expr [symbolic_self = constants.%Z_where.type.87e] { +// CHECK:STDOUT: %.loc10_19: type = where_expr [concrete = constants.%Z_where.type.87e] { // CHECK:STDOUT: requirement_base_facet_type %Z.ref // CHECK:STDOUT: requirement_impls %.loc10_25, %Y.type // CHECK:STDOUT: } @@ -1518,7 +1518,7 @@ constraint N { // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.069 [symbolic_self] // CHECK:STDOUT: %C.e61: type = class_type @C, @C(%.Self.as_type) [symbolic_self] // CHECK:STDOUT: %Y.type.313: type = facet_type <@Y, @Y(%.Self.as_type)> [symbolic_self] -// CHECK:STDOUT: %Z_where.type.d5dfdf.1: type = facet_type <@Z where %C.e61 impls @Y, @Y(%.Self.as_type)> [symbolic_self] +// CHECK:STDOUT: %Z_where.type.d5dfdf.1: type = facet_type <@Z where %C.e61 impls @Y, @Y(%.Self.as_type)> [concrete] // CHECK:STDOUT: %C.e28: type = class_type @C, @C(%Self.as_type) [symbolic] // CHECK:STDOUT: %Z_where.type.d5dfdf.2: type = facet_type <@Z where %C.e28 impls @Y, @Y(%Self.as_type)> [symbolic] // CHECK:STDOUT: %T.067: %Z.type = symbolic_binding T, 0 [symbolic] @@ -1552,7 +1552,7 @@ constraint N { // CHECK:STDOUT: %.Self.as_type.loc10_47: type = facet_access_type %.Self.ref.loc10_42 [symbolic_self = constants.%.Self.as_type] // CHECK:STDOUT: %.loc10_47: type = converted %.Self.ref.loc10_42, %.Self.as_type.loc10_47 [symbolic_self = constants.%.Self.as_type] // CHECK:STDOUT: %Y.type: type = facet_type <@Y, @Y(constants.%.Self.as_type)> [symbolic_self = constants.%Y.type.313] -// CHECK:STDOUT: %.loc10_19: type = where_expr [symbolic_self = constants.%Z_where.type.d5dfdf.1] { +// CHECK:STDOUT: %.loc10_19: type = where_expr [concrete = constants.%Z_where.type.d5dfdf.1] { // CHECK:STDOUT: requirement_base_facet_type %Z.ref // CHECK:STDOUT: requirement_impls %C.loc10_32, %Y.type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/where_expr/constraints.carbon b/toolchain/check/testdata/where_expr/constraints.carbon index e3749ceab40b..04959be4a6b0 100644 --- a/toolchain/check/testdata/where_expr/constraints.carbon +++ b/toolchain/check/testdata/where_expr/constraints.carbon @@ -439,8 +439,8 @@ fn F() { // CHECK:STDOUT: %K.lookup_impl_witness: = lookup_impl_witness %.Self.cb7, @K [symbolic_self] // CHECK:STDOUT: %impl.elem0: %L.type = impl_witness_access %K.lookup_impl_witness, element0 [symbolic_self] // CHECK:STDOUT: %as_type: type = facet_access_type %impl.elem0 [symbolic_self] -// CHECK:STDOUT: %K_where.type: type = facet_type <@K where %impl.elem0 impls @M> [symbolic_self] -// CHECK:STDOUT: %pattern_type: type = pattern_type %K_where.type [symbolic_self] +// CHECK:STDOUT: %K_where.type: type = facet_type <@K where %impl.elem0 impls @M> [concrete] +// CHECK:STDOUT: %pattern_type: type = pattern_type %K_where.type [concrete] // CHECK:STDOUT: %W: %K_where.type = symbolic_binding W, 0 [symbolic] // CHECK:STDOUT: %AssociatedTypeImpls.type: type = fn_type @AssociatedTypeImpls [concrete] // CHECK:STDOUT: %AssociatedTypeImpls: %AssociatedTypeImpls.type = struct_value () [concrete] @@ -450,7 +450,7 @@ fn F() { // CHECK:STDOUT: %AssociatedTypeImpls.decl: %AssociatedTypeImpls.type = fn_decl @AssociatedTypeImpls [concrete = constants.%AssociatedTypeImpls] { // CHECK:STDOUT: %W.patt: %pattern_type = symbolic_binding_pattern W, 0 [concrete] // CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc12_30.1: type = splice_block %.loc12_30.2 [symbolic_self = constants.%K_where.type] { +// CHECK:STDOUT: %.loc12_30.1: type = splice_block %.loc12_30.2 [concrete = constants.%K_where.type] { // CHECK:STDOUT: %.Self.loc12_25: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.c39] // CHECK:STDOUT: %K.ref: type = name_ref K, file.%K.decl [concrete = constants.%K.type] // CHECK:STDOUT: %.Self.loc12_30: %K.type = symbolic_binding .Self [symbolic_self = constants.%.Self.cb7] @@ -462,7 +462,7 @@ fn F() { // CHECK:STDOUT: %M.ref: type = name_ref M, file.%M.decl [concrete = constants.%M.type] // CHECK:STDOUT: %as_type: type = facet_access_type %impl.elem0 [symbolic_self = constants.%as_type] // CHECK:STDOUT: %.loc12_36.2: type = converted %impl.elem0, %as_type [symbolic_self = constants.%as_type] -// CHECK:STDOUT: %.loc12_30.2: type = where_expr [symbolic_self = constants.%K_where.type] { +// CHECK:STDOUT: %.loc12_30.2: type = where_expr [concrete = constants.%K_where.type] { // CHECK:STDOUT: requirement_base_facet_type %K.ref // CHECK:STDOUT: requirement_impls %.loc12_36.2, %M.ref // CHECK:STDOUT: } diff --git a/toolchain/lower/testdata/impl/period_self.carbon b/toolchain/lower/testdata/impl/period_self.carbon new file mode 100644 index 000000000000..4beceee49521 --- /dev/null +++ b/toolchain/lower/testdata/impl/period_self.carbon @@ -0,0 +1,105 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/impl/period_self.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/impl/period_self.carbon + +// --- library_with_period_self_in_impl.carbon + +library "[[@TEST_NAME]]"; + +interface J {} + +class A(T:! type) {} +class B {} + +impl forall [T:! type] A(T) as J {} + +impl forall [T:! type where A(.Self) impls J] A(T) as Core.As(T*) { + fn Convert[self: A(T)]() -> T* { + return self as T*; + } +} + +fn F[T:! type](x: A(T)) { + x as T*; +} + +// --- import_period_self_in_impl.carbon + +library "[[@TEST_NAME]]"; + +import library "library_with_period_self_in_impl"; + +fn G(a: A(B)) { + F(a); +} + +// CHECK:STDOUT: ; ModuleID = 'library_with_period_self_in_impl.carbon' +// CHECK:STDOUT: source_filename = "library_with_period_self_in_impl.carbon" +// CHECK:STDOUT: +// CHECK:STDOUT: !llvm.module.flags = !{!0, !1} +// CHECK:STDOUT: !llvm.dbg.cu = !{!2} +// CHECK:STDOUT: +// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5} +// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3} +// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) +// CHECK:STDOUT: !3 = !DIFile(filename: "library_with_period_self_in_impl.carbon", directory: "") +// CHECK:STDOUT: ; ModuleID = 'import_period_self_in_impl.carbon' +// CHECK:STDOUT: source_filename = "import_period_self_in_impl.carbon" +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define void @_CG.Main(ptr %a) #0 !dbg !4 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: call void @_CF.Main.b4fc7929164fb220(ptr %a), !dbg !10 +// CHECK:STDOUT: ret void, !dbg !11 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr void @_CF.Main.b4fc7929164fb220(ptr %x) #0 !dbg !12 { +// CHECK:STDOUT: %1 = call ptr @"_CConvert.A.5d7343568c0b5715.Main:As.00d5ad878904f3d1.Core.d9476ddaeffa1656"(ptr %x), !dbg !16 +// CHECK:STDOUT: ret void, !dbg !17 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.A.5d7343568c0b5715.Main:As.00d5ad878904f3d1.Core.d9476ddaeffa1656"(ptr %self) #0 !dbg !18 { +// CHECK:STDOUT: %1 = call ptr @"_CConvert.A.5d7343568c0b5715.Main:As.00d5ad878904f3d1.Core.d9476ddaeffa1656"(ptr %self), !dbg !23 +// CHECK:STDOUT: ret ptr %1, !dbg !24 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: attributes #0 = { nounwind } +// CHECK:STDOUT: +// CHECK:STDOUT: !llvm.module.flags = !{!0, !1} +// CHECK:STDOUT: !llvm.dbg.cu = !{!2} +// CHECK:STDOUT: +// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5} +// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3} +// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) +// CHECK:STDOUT: !3 = !DIFile(filename: "import_period_self_in_impl.carbon", directory: "") +// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 6, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8) +// CHECK:STDOUT: !5 = !DISubroutineType(types: !6) +// CHECK:STDOUT: !6 = !{null, !7} +// CHECK:STDOUT: !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +// CHECK:STDOUT: !8 = !{!9} +// CHECK:STDOUT: !9 = !DILocalVariable(arg: 1, scope: !4, type: !7) +// CHECK:STDOUT: !10 = !DILocation(line: 7, column: 3, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 6, column: 1, scope: !4) +// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main.b4fc7929164fb220", scope: null, file: !13, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !14) +// CHECK:STDOUT: !13 = !DIFile(filename: "library_with_period_self_in_impl.carbon", directory: "") +// CHECK:STDOUT: !14 = !{!15} +// CHECK:STDOUT: !15 = !DILocalVariable(arg: 1, scope: !12, type: !7) +// CHECK:STDOUT: !16 = !DILocation(line: 18, column: 3, scope: !12) +// CHECK:STDOUT: !17 = !DILocation(line: 17, column: 1, scope: !12) +// CHECK:STDOUT: !18 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.A.5d7343568c0b5715.Main:As.00d5ad878904f3d1.Core.d9476ddaeffa1656", scope: null, file: !13, line: 12, type: !19, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !21) +// CHECK:STDOUT: !19 = !DISubroutineType(types: !20) +// CHECK:STDOUT: !20 = !{!7, !7} +// CHECK:STDOUT: !21 = !{!22} +// CHECK:STDOUT: !22 = !DILocalVariable(arg: 1, scope: !18, type: !7) +// CHECK:STDOUT: !23 = !DILocation(line: 13, column: 12, scope: !18) +// CHECK:STDOUT: !24 = !DILocation(line: 13, column: 5, scope: !18) diff --git a/toolchain/lower/testdata/interface/where.carbon b/toolchain/lower/testdata/interface/where.carbon index 52a87e9ea368..0b2d0ff6aace 100644 --- a/toolchain/lower/testdata/interface/where.carbon +++ b/toolchain/lower/testdata/interface/where.carbon @@ -10,6 +10,10 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/interface/where.carbon +// --- basic.carbon + +library "[[@TEST_NAME]]"; + interface I { let T:! type; fn F(); @@ -22,8 +26,37 @@ impl C as I where .T = () { } } -// CHECK:STDOUT: ; ModuleID = 'where.carbon' -// CHECK:STDOUT: source_filename = "where.carbon" +// --- no_period_self_dependence.carbon + +library "[[@TEST_NAME]]"; + +class C {} +class D {} +class E {} + +interface I(T:! type) { fn F[self: Self](); } +interface J(T:! type) {} + +impl D as J(E) {} + +// The type of `T` is not `.Self`-dependent, because `.Self` appears after +// `where`. +impl forall [T:! type where D impls J(.Self)] C as I(T) { + fn F[unused self: Self]() {} +} + +fn F(a: C) { + a.(I(E).F)(); +} + +fn G() { + // This is a concrete, non-`.Self`-dependent type. + // (Lowering would assert if it sees a dependent constant.) + let unused t: type = type where D impls J(.Self); +} + +// CHECK:STDOUT: ; ModuleID = 'basic.carbon' +// CHECK:STDOUT: source_filename = "basic.carbon" // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @"_CF.C.Main:I.Main"() #0 !dbg !4 { @@ -39,8 +72,55 @@ impl C as I where .T = () { // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3} // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) -// CHECK:STDOUT: !3 = !DIFile(filename: "where.carbon", directory: "") -// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.C.Main:I.Main", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2) +// CHECK:STDOUT: !3 = !DIFile(filename: "basic.carbon", directory: "") +// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.C.Main:I.Main", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{null} -// CHECK:STDOUT: !7 = !DILocation(line: 21, column: 3, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) +// CHECK:STDOUT: ; ModuleID = 'no_period_self_dependence.carbon' +// CHECK:STDOUT: source_filename = "no_period_self_dependence.carbon" +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define void @_CF.Main(ptr %a) #0 !dbg !4 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: call void @"_CF.C.Main:I.5d7343568c0b5715.Main.36f6a86118c8cac1"(ptr %a), !dbg !10 +// CHECK:STDOUT: ret void, !dbg !11 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define void @_CG.Main() #0 !dbg !12 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: ret void, !dbg !15 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr void @"_CF.C.Main:I.5d7343568c0b5715.Main.36f6a86118c8cac1"(ptr %self) #0 !dbg !16 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: ret void, !dbg !19 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: attributes #0 = { nounwind } +// CHECK:STDOUT: +// CHECK:STDOUT: !llvm.module.flags = !{!0, !1} +// CHECK:STDOUT: !llvm.dbg.cu = !{!2} +// CHECK:STDOUT: +// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5} +// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3} +// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) +// CHECK:STDOUT: !3 = !DIFile(filename: "no_period_self_dependence.carbon", directory: "") +// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 19, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !8) +// CHECK:STDOUT: !5 = !DISubroutineType(types: !6) +// CHECK:STDOUT: !6 = !{null, !7} +// CHECK:STDOUT: !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +// CHECK:STDOUT: !8 = !{!9} +// CHECK:STDOUT: !9 = !DILocalVariable(arg: 1, scope: !4, type: !7) +// CHECK:STDOUT: !10 = !DILocation(line: 20, column: 3, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 19, column: 1, scope: !4) +// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 23, type: !13, spFlags: DISPFlagDefinition, unit: !2) +// CHECK:STDOUT: !13 = !DISubroutineType(types: !14) +// CHECK:STDOUT: !14 = !{null} +// CHECK:STDOUT: !15 = !DILocation(line: 23, column: 1, scope: !12) +// CHECK:STDOUT: !16 = distinct !DISubprogram(name: "F", linkageName: "_CF.C.Main:I.5d7343568c0b5715.Main.36f6a86118c8cac1", scope: null, file: !3, line: 16, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !17) +// CHECK:STDOUT: !17 = !{!18} +// CHECK:STDOUT: !18 = !DILocalVariable(arg: 1, scope: !16, type: !7) +// CHECK:STDOUT: !19 = !DILocation(line: 16, column: 3, scope: !16)