diff --git a/toolchain/check/context.h b/toolchain/check/context.h index bff0ddb45744..237e9acbe0ba 100644 --- a/toolchain/check/context.h +++ b/toolchain/check/context.h @@ -230,8 +230,8 @@ class Context { auto facet_types() -> CanonicalValueStore& { return sem_ir().facet_types(); } - auto complete_facet_types() -> SemIR::File::CompleteFacetTypeStore& { - return sem_ir().complete_facet_types(); + auto identified_facet_types() -> SemIR::File::IdentifiedFacetTypeStore& { + return sem_ir().identified_facet_types(); } auto impls() -> SemIR::ImplStore& { return sem_ir().impls(); } auto specific_interfaces() diff --git a/toolchain/check/dump.cpp b/toolchain/check/dump.cpp index 1f83f1bfa19b..673eb692251f 100644 --- a/toolchain/check/dump.cpp +++ b/toolchain/check/dump.cpp @@ -147,9 +147,9 @@ LLVM_DUMP_METHOD static auto Dump(const Context& context, } LLVM_DUMP_METHOD static auto Dump( - const Context& context, SemIR::CompleteFacetTypeId complete_facet_type_id) - -> std::string { - return SemIR::Dump(context.sem_ir(), complete_facet_type_id); + const Context& context, + SemIR::IdentifiedFacetTypeId identified_facet_type_id) -> std::string { + return SemIR::Dump(context.sem_ir(), identified_facet_type_id); } LLVM_DUMP_METHOD static auto Dump(const Context& context, diff --git a/toolchain/check/eval_inst.cpp b/toolchain/check/eval_inst.cpp index 57c885d9b4e3..37f467c8eb5f 100644 --- a/toolchain/check/eval_inst.cpp +++ b/toolchain/check/eval_inst.cpp @@ -246,22 +246,24 @@ auto EvalConstantInst(Context& context, SemIRLoc loc, if (auto witness = context.insts().TryGetAs(inst.witness_id)) { auto elements = context.inst_blocks().Get(witness->elements_id); - auto index = static_cast(inst.index.index); - CARBON_CHECK(index < elements.size(), "Access out of bounds."); - auto element = elements[index]; - if (!element.has_value()) { - // TODO: Perhaps this should be a `{}` value with incomplete type? - CARBON_DIAGNOSTIC(ImplAccessMemberBeforeComplete, Error, - "accessing member from impl before the end of " - "its definition"); - // TODO: Add note pointing to the impl declaration. - context.emitter().Emit(loc, ImplAccessMemberBeforeComplete); - return ConstantEvalResult::Error; + // `elements` can be empty if there is only a forward declaration of the + // impl. + if (!elements.empty()) { + auto index = static_cast(inst.index.index); + CARBON_CHECK(index < elements.size(), "Access out of bounds."); + auto element = elements[index]; + if (element.has_value()) { + LoadImportRef(context, element); + return ConstantEvalResult::Existing(GetConstantValueInSpecific( + context.sem_ir(), witness->specific_id, element)); + } } - - LoadImportRef(context, element); - return ConstantEvalResult::Existing(GetConstantValueInSpecific( - context.sem_ir(), witness->specific_id, element)); + CARBON_DIAGNOSTIC( + ImplAccessMemberBeforeSet, Error, + "accessing member from impl before it has a defined value"); + // TODO: Add note pointing to the impl declaration. + context.emitter().Emit(loc, ImplAccessMemberBeforeSet); + return ConstantEvalResult::Error; } return ConstantEvalResult::NewSamePhase(inst); diff --git a/toolchain/check/facet_type.cpp b/toolchain/check/facet_type.cpp index df1ad02488c5..80925adb7a18 100644 --- a/toolchain/check/facet_type.cpp +++ b/toolchain/check/facet_type.cpp @@ -9,6 +9,7 @@ #include "toolchain/check/inst.h" #include "toolchain/check/interface.h" #include "toolchain/check/type.h" +#include "toolchain/check/type_completion.h" namespace Carbon::Check { @@ -37,16 +38,56 @@ static auto WitnessAccessMatchesInterface( return false; } -auto ResolveFacetTypeImplWitness( +static auto IncompleteFacetTypeDiagnosticBuilder( + Context& context, SemIRLoc loc, SemIR::InstId facet_type_inst_id, + bool is_definition) -> DiagnosticBuilder { + // The other case is "impl as incomplete facet type with rewrites", but + // currently all incomplete facet types with rewrites trigger errors before + // this. + CARBON_CHECK(is_definition); + CARBON_DIAGNOSTIC(ImplAsIncompleteFacetTypeDefinition, Error, + "definition of impl as incomplete facet type {0}", + InstIdAsType); + return context.emitter().Build(loc, ImplAsIncompleteFacetTypeDefinition, + facet_type_inst_id); +} + +auto InitialFacetTypeImplWitness( Context& context, SemIR::LocId witness_loc_id, SemIR::InstId facet_type_inst_id, SemIR::InstId self_type_inst_id, const SemIR::SpecificInterface& interface_to_witness, - SemIR::SpecificId self_specific_id) -> SemIR::InstId { + SemIR::SpecificId self_specific_id, bool is_definition) -> SemIR::InstId { // TODO: Finish facet type resolution. This code currently only handles // rewrite constraints that set associated constants to a concrete value. // Need logic to topologically sort rewrites to respect dependencies, and // afterwards reject duplicates that are not identical. + auto facet_type_id = + context.types().GetTypeIdForTypeInstId(facet_type_inst_id); + CARBON_CHECK(facet_type_id != SemIR::ErrorInst::SingletonTypeId); + auto facet_type = context.types().GetAs(facet_type_id); + // TODO: This is currently a copy because I'm not sure whether anything could + // cause the facet type store to resize before we are done with it. + auto facet_type_info = context.facet_types().Get(facet_type.facet_type_id); + + if (!is_definition && facet_type_info.rewrite_constraints.empty()) { + return AddInst( + context, witness_loc_id, + {.type_id = + GetSingletonType(context, SemIR::WitnessType::SingletonInstId), + .elements_id = context.inst_blocks().AddPlaceholder(), + .specific_id = self_specific_id}); + } + + if (!RequireCompleteType(context, facet_type_id, + context.insts().GetLocId(facet_type_inst_id), [&] { + return IncompleteFacetTypeDiagnosticBuilder( + context, witness_loc_id, facet_type_inst_id, + is_definition); + })) { + return SemIR::ErrorInst::SingletonInstId; + } + const auto& interface = context.interfaces().Get(interface_to_witness.interface_id); auto assoc_entities = @@ -73,14 +114,6 @@ auto ResolveFacetTypeImplWitness( .specific_id = self_specific_id}); } - auto facet_type_id = - context.types().GetTypeIdForTypeInstId(facet_type_inst_id); - CARBON_CHECK(facet_type_id != SemIR::ErrorInst::SingletonTypeId); - auto facet_type = context.types().GetAs(facet_type_id); - // TODO: This is currently a copy because I'm not sure whether anything could - // cause the facet type store to resize before we are done with it. - auto facet_type_info = context.facet_types().Get(facet_type.facet_type_id); - for (auto rewrite : facet_type_info.rewrite_constraints) { auto inst_id = context.constant_values().GetInstId(rewrite.lhs_const_id); auto access = context.insts().GetAs(inst_id); @@ -185,4 +218,33 @@ auto ResolveFacetTypeImplWitness( return witness_inst_id; } +auto RequireCompleteFacetTypeForImplDefinition(Context& context, SemIRLoc loc, + SemIR::InstId facet_type_inst_id) + -> bool { + auto facet_type_id = + context.types().GetTypeIdForTypeInstId(facet_type_inst_id); + return RequireCompleteType(context, facet_type_id, + context.insts().GetLocId(facet_type_inst_id), [&] { + return IncompleteFacetTypeDiagnosticBuilder( + context, loc, facet_type_inst_id, + /*is_definition=*/true); + }); +} + +auto AllocateFacetTypeImplWitness(Context& context, + SemIR::InterfaceId interface_id, + SemIR::InstBlockId witness_id) -> void { + const auto& interface = context.interfaces().Get(interface_id); + CARBON_CHECK(interface.is_complete()); + auto assoc_entities = + context.inst_blocks().Get(interface.associated_entities_id); + for (auto decl_id : assoc_entities) { + LoadImportRef(context, decl_id); + } + + llvm::SmallVector empty_table(assoc_entities.size(), + SemIR::InstId::None); + context.inst_blocks().ReplacePlaceholder(witness_id, empty_table); +} + } // namespace Carbon::Check diff --git a/toolchain/check/facet_type.h b/toolchain/check/facet_type.h index 810983310cef..9c9aa30ff8fb 100644 --- a/toolchain/check/facet_type.h +++ b/toolchain/check/facet_type.h @@ -16,11 +16,16 @@ namespace Carbon::Check { auto FacetTypeFromInterface(Context& context, SemIR::InterfaceId interface_id, SemIR::SpecificId specific_id) -> SemIR::FacetType; +// Creates a impl witness instruction for a facet type. The facet type is +// required to be complete if `is_definition` is true or the facet type has +// rewrites. Otherwise a placeholder witness is created, and +// `AllocateFacetTypeImplWitness` can be used at the `impl` definition. +// // Adds and returns an `ImplWitness` instruction (created with location set to // `witness_loc_id`) that shows "`Self` type" of type "facet type" (the value of // the `facet_type_inst_id` instruction) implements interface // `interface_to_witness`, which must be an interface required by "facet type" -// (as determined by `RequireCompleteFacetType`). This witness reflects the +// (as determined by `RequireIdentifiedFacetType`). This witness reflects the // values assigned to associated constant members of that interface by rewrite // constraints in the facet type. `self_specific_id` will be the `specific_id` // of the resulting witness. @@ -34,11 +39,24 @@ auto FacetTypeFromInterface(Context& context, SemIR::InterfaceId interface_id, // rewritten value to the type of the associated constant. That conversion // will also be performed as part of resolution, and may depend on the // `Self` type. -auto ResolveFacetTypeImplWitness( +auto InitialFacetTypeImplWitness( Context& context, SemIR::LocId witness_loc_id, SemIR::InstId facet_type_inst_id, SemIR::InstId self_type_inst_id, const SemIR::SpecificInterface& interface_to_witness, - SemIR::SpecificId self_specific_id) -> SemIR::InstId; + SemIR::SpecificId self_specific_id, bool is_definition) -> SemIR::InstId; + +// Returns `true` if the facet type is complete. Otherwise issues a diagnostic +// and returns `false`. +auto RequireCompleteFacetTypeForImplDefinition(Context& context, SemIRLoc loc, + SemIR::InstId facet_type_inst_id) + -> bool; + +// Replaces the placeholder created by `InitialFacetTypeImplWitness` with an +// empty witness table of the right size. Requires the interface designated by +// `interface_id` to be complete. +auto AllocateFacetTypeImplWitness(Context& context, + SemIR::InterfaceId interface_id, + SemIR::InstBlockId witness_id) -> void; } // namespace Carbon::Check diff --git a/toolchain/check/handle_impl.cpp b/toolchain/check/handle_impl.cpp index 1eeede2f1dd0..a80083a6b2d5 100644 --- a/toolchain/check/handle_impl.cpp +++ b/toolchain/check/handle_impl.cpp @@ -191,6 +191,21 @@ static auto ExtendImpl(Context& context, Parse::NodeId extend_node, const auto& impl = context.impls().Get(impl_id); if (impl.witness_id == SemIR::ErrorInst::SingletonInstId) { parent_scope.set_has_error(); + } else { + bool is_complete = RequireCompleteType( + context, constraint_id, context.insts().GetLocId(constraint_inst_id), + [&] { + CARBON_DIAGNOSTIC(ExtendImplAsIncomplete, Error, + "`extend impl as` incomplete facet type {0}", + InstIdAsType); + return context.emitter().Build(impl.latest_decl_id(), + ExtendImplAsIncomplete, + constraint_inst_id); + }); + if (!is_complete) { + parent_scope.set_has_error(); + return false; + } } parent_scope.AddExtendedScope(constraint_inst_id); @@ -303,47 +318,35 @@ static auto IsValidImplRedecl(Context& context, SemIR::Impl& new_impl, return true; } -// Checks that the constraint specified for the impl is valid and complete. -// Returns a pointer to the interface that the impl implements. On error, -// issues a diagnostic and returns nullptr. +// Checks that the constraint specified for the impl is valid and identified. +// Returns the interface that the impl implements. On error, issues a diagnostic +// and returns `None`. static auto CheckConstraintIsInterface(Context& context, - const SemIR::Impl& impl) - -> const SemIR::CompleteFacetType::RequiredInterface* { - auto facet_type_id = - context.types().GetTypeIdForTypeInstId(impl.constraint_id); + SemIR::InstId impl_decl_id, + SemIR::InstId constraint_id) + -> SemIR::SpecificInterface { + auto facet_type_id = context.types().GetTypeIdForTypeInstId(constraint_id); if (facet_type_id == SemIR::ErrorInst::SingletonTypeId) { - return nullptr; + return SemIR::SpecificInterface::None; } auto facet_type = context.types().TryGetAs(facet_type_id); if (!facet_type) { CARBON_DIAGNOSTIC(ImplAsNonFacetType, Error, "impl as non-facet type {0}", InstIdAsType); - context.emitter().Emit(impl.latest_decl_id(), ImplAsNonFacetType, - impl.constraint_id); - return nullptr; + context.emitter().Emit(impl_decl_id, ImplAsNonFacetType, constraint_id); + return SemIR::SpecificInterface::None; } - auto complete_id = RequireCompleteFacetType( - context, facet_type_id, context.insts().GetLocId(impl.constraint_id), - *facet_type, [&] { - CARBON_DIAGNOSTIC(ImplAsIncompleteFacetType, Error, - "impl as incomplete facet type {0}", InstIdAsType); - return context.emitter().Build(impl.latest_decl_id(), - ImplAsIncompleteFacetType, - impl.constraint_id); - }); - if (!complete_id.has_value()) { - return nullptr; - } - const auto& complete = context.complete_facet_types().Get(complete_id); - if (complete.num_to_impl != 1) { + auto identified_id = RequireIdentifiedFacetType(context, *facet_type); + const auto& identified = context.identified_facet_types().Get(identified_id); + if (!identified.is_valid_impl_as_target()) { CARBON_DIAGNOSTIC(ImplOfNotOneInterface, Error, "impl as {0} interfaces, expected 1", int); - context.emitter().Emit(impl.latest_decl_id(), ImplOfNotOneInterface, - complete.num_to_impl); - return nullptr; + context.emitter().Emit(impl_decl_id, ImplOfNotOneInterface, + identified.num_interfaces_to_impl()); + return SemIR::SpecificInterface::None; } - return &complete.required_interfaces.front(); + return identified.impl_as_target_interface(); } // Build an ImplDecl describing the signature of an impl. This handles the @@ -388,14 +391,8 @@ static auto BuildImplDecl(Context& context, Parse::AnyImplDeclId node_id, /*is_extern=*/false, SemIR::LibraryNameId::None), {.self_id = self_inst_id, .constraint_id = constraint_inst_id, - .interface = SemIR::SpecificInterface::None}}; - - const SemIR::CompleteFacetType::RequiredInterface* required_interface = - CheckConstraintIsInterface(context, impl_info); - if (required_interface) { - impl_info.interface = *required_interface; - } - + .interface = CheckConstraintIsInterface( + context, impl_decl_id, constraint_inst_id)}}; // Add the impl declaration. bool invalid_redeclaration = false; auto lookup_bucket_ref = context.impls().GetOrAddLookupBucket(impl_info); @@ -417,8 +414,9 @@ static auto BuildImplDecl(Context& context, Parse::AnyImplDeclId node_id, // Create a new impl if this isn't a valid redeclaration. if (!impl_decl.impl_id.has_value()) { impl_info.generic_id = BuildGeneric(context, impl_decl_id); - if (required_interface) { - impl_info.witness_id = ImplWitnessForDeclaration(context, impl_info); + if (impl_info.interface.interface_id.has_value()) { + impl_info.witness_id = + ImplWitnessForDeclaration(context, impl_info, is_definition); } else { impl_info.witness_id = SemIR::ErrorInst::SingletonInstId; // TODO: We might also want to mark that the name scope for the impl has diff --git a/toolchain/check/impl.cpp b/toolchain/check/impl.cpp index ef54de82aa51..74ab03b8c2f8 100644 --- a/toolchain/check/impl.cpp +++ b/toolchain/check/impl.cpp @@ -84,10 +84,9 @@ static auto CheckAssociatedFunctionImplementation( return impl_decl_id; } -// Builds an initial empty witness. -// TODO: Fill the witness with the rewrites from the declaration. -auto ImplWitnessForDeclaration(Context& context, const SemIR::Impl& impl) - -> SemIR::InstId { +// Builds an initial witness from the rewrites in the facet type, if any. +auto ImplWitnessForDeclaration(Context& context, const SemIR::Impl& impl, + bool is_definition) -> SemIR::InstId { CARBON_CHECK(!impl.has_definition_started()); auto self_type_id = context.types().GetTypeIdForTypeInstId(impl.self_id); @@ -96,10 +95,10 @@ auto ImplWitnessForDeclaration(Context& context, const SemIR::Impl& impl) return SemIR::ErrorInst::SingletonInstId; } - return ResolveFacetTypeImplWitness( + return InitialFacetTypeImplWitness( context, context.insts().GetLocId(impl.latest_decl_id()), impl.constraint_id, impl.self_id, impl.interface, - context.generics().GetSelfSpecific(impl.generic_id)); + context.generics().GetSelfSpecific(impl.generic_id), is_definition); } auto ImplWitnessStartDefinition(Context& context, SemIR::Impl& impl) -> void { @@ -110,6 +109,23 @@ auto ImplWitnessStartDefinition(Context& context, SemIR::Impl& impl) -> void { } auto witness = context.insts().GetAs(impl.witness_id); auto witness_block = context.inst_blocks().GetMutable(witness.elements_id); + // `witness.elements_id` will be `SemIR::InstBlockId::Empty` when the + // definition is the first declaration and the interface has no members. The + // other case where `witness_block` will be empty is when we are using a + // placeholder witness. This happens when there is a forward declaration of + // the impl and the facet type has no rewrite constraints and so it wasn't + // required to be complete. + if (witness.elements_id != SemIR::InstBlockId::Empty && + witness_block.empty()) { + if (!RequireCompleteFacetTypeForImplDefinition( + context, impl.latest_decl_id(), impl.constraint_id)) { + return; + } + + AllocateFacetTypeImplWitness(context, impl.interface.interface_id, + witness.elements_id); + witness_block = context.inst_blocks().GetMutable(witness.elements_id); + } const auto& interface = context.interfaces().Get(impl.interface.interface_id); auto assoc_entities = context.inst_blocks().Get(interface.associated_entities_id); diff --git a/toolchain/check/impl.h b/toolchain/check/impl.h index e8445e8f54ac..f33f9c414f48 100644 --- a/toolchain/check/impl.h +++ b/toolchain/check/impl.h @@ -11,8 +11,8 @@ namespace Carbon::Check { // Returns the initial witness value for a new impl declaration. -auto ImplWitnessForDeclaration(Context& context, const SemIR::Impl& impl) - -> SemIR::InstId; +auto ImplWitnessForDeclaration(Context& context, const SemIR::Impl& impl, + bool is_definition) -> SemIR::InstId; // Update `impl`'s witness at the start of a definition. auto ImplWitnessStartDefinition(Context& context, SemIR::Impl& impl) -> void; diff --git a/toolchain/check/name_lookup.cpp b/toolchain/check/name_lookup.cpp index edeb8bd5720d..790e54dfd0c7 100644 --- a/toolchain/check/name_lookup.cpp +++ b/toolchain/check/name_lookup.cpp @@ -291,6 +291,8 @@ auto AppendLookupScopesForConstant(Context& context, SemIR::LocId loc_id, return true; } if (auto base_as_class = base.TryAs()) { + // TODO: Allow name lookup into classes that are being defined even if they + // are not complete. RequireCompleteType( context, context.types().GetTypeIdForTypeConstantId(base_const_id), loc_id, [&] { @@ -306,18 +308,23 @@ auto AppendLookupScopesForConstant(Context& context, SemIR::LocId loc_id, return true; } if (auto base_as_facet_type = base.TryAs()) { - auto complete_id = RequireCompleteFacetType( - context, context.types().GetTypeIdForTypeConstantId(base_const_id), - loc_id, *base_as_facet_type, [&] { - CARBON_DIAGNOSTIC(QualifiedExprInIncompleteFacetTypeScope, Error, - "member access into incomplete facet type {0}", - InstIdAsType); - return context.emitter().Build( - loc_id, QualifiedExprInIncompleteFacetTypeScope, base_id); - }); - if (complete_id.has_value()) { - const auto& resolved = context.complete_facet_types().Get(complete_id); - for (const auto& interface : resolved.required_interfaces) { + // TODO: Allow name lookup into facet types that are being defined even if + // they are not complete. + if (RequireCompleteType( + context, context.types().GetTypeIdForTypeConstantId(base_const_id), + loc_id, [&] { + CARBON_DIAGNOSTIC(QualifiedExprInIncompleteFacetTypeScope, Error, + "member access into incomplete facet type {0}", + InstIdAsType); + return context.emitter().Build( + loc_id, QualifiedExprInIncompleteFacetTypeScope, base_id); + })) { + auto identified_id = + RequireIdentifiedFacetType(context, *base_as_facet_type); + CARBON_CHECK(identified_id.has_value()); + const auto& identified = + context.identified_facet_types().Get(identified_id); + for (const auto& interface : identified.required_interfaces()) { auto& interface_info = context.interfaces().Get(interface.interface_id); scopes->push_back({.name_scope_id = interface_info.scope_id, .specific_id = interface.specific_id}); @@ -430,12 +437,6 @@ auto LookupQualifiedName(Context& context, SemIR::LocId loc_id, SemIR::ConstantId const_id = GetConstantValueInSpecific( context.sem_ir(), specific_id, extended_id); - Diagnostics::AnnotationScope annotate_diagnostics( - &context.emitter(), [&](auto& builder) { - CARBON_DIAGNOSTIC(FromExtendHere, Note, - "declared as an extended scope here"); - builder.Note(extended_id, FromExtendHere); - }); if (!AppendLookupScopesForConstant(context, loc_id, const_id, &scopes)) { // TODO: Handle case where we have a symbolic type and instead should diff --git a/toolchain/check/testdata/impl/extend_impl_generic.carbon b/toolchain/check/testdata/impl/extend_impl_generic.carbon index 7511b0b65816..0e371d060cb2 100644 --- a/toolchain/check/testdata/impl/extend_impl_generic.carbon +++ b/toolchain/check/testdata/impl/extend_impl_generic.carbon @@ -456,6 +456,7 @@ class X(U:! type) { // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%U.loc8_9.2)> [symbolic = %I.type (constants.%I.type.325e65.2)] +// CHECK:STDOUT: %require_complete: = require_complete_type @X.%I.type (%I.type.325e65.2) [symbolic = %require_complete (constants.%require_complete.cfe)] // CHECK:STDOUT: // CHECK:STDOUT: class { // CHECK:STDOUT: impl_decl @impl [concrete] {} { @@ -524,6 +525,7 @@ class X(U:! type) { // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %I.type => constants.%I.type.325e65.2 +// CHECK:STDOUT: %require_complete => constants.%require_complete.cfe // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @I(constants.%U) { diff --git a/toolchain/check/testdata/impl/fail_extend_impl_type_as.carbon b/toolchain/check/testdata/impl/fail_extend_impl_type_as.carbon index 65e87c93b860..9627b7fa8523 100644 --- a/toolchain/check/testdata/impl/fail_extend_impl_type_as.carbon +++ b/toolchain/check/testdata/impl/fail_extend_impl_type_as.carbon @@ -52,10 +52,11 @@ class E { // CHECK:STDOUT: %C: type = class_type @C [concrete] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] -// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete] +// CHECK:STDOUT: %impl_witness.1bcebf.1: = impl_witness () [concrete] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] // CHECK:STDOUT: %complete_type.357: = complete_type_witness %empty_struct_type [concrete] // CHECK:STDOUT: %D: type = class_type @D [concrete] +// CHECK:STDOUT: %impl_witness.1bcebf.2: = impl_witness () [concrete] // CHECK:STDOUT: %E: type = class_type @E [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -108,7 +109,7 @@ class E { // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type] // CHECK:STDOUT: } -// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness] +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness.1bcebf.1] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: @@ -123,7 +124,7 @@ class E { // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [concrete = constants.%D] // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type] // CHECK:STDOUT: } -// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness] +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness.1bcebf.2] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: @@ -139,7 +140,7 @@ class E { // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%E [concrete = constants.%E] // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type] // CHECK:STDOUT: } -// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness] +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness.1bcebf.1] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/fail_extend_partially_defined_interface.carbon b/toolchain/check/testdata/impl/fail_extend_partially_defined_interface.carbon index 5990e1242ef1..83efa9b4b949 100644 --- a/toolchain/check/testdata/impl/fail_extend_partially_defined_interface.carbon +++ b/toolchain/check/testdata/impl/fail_extend_partially_defined_interface.carbon @@ -10,10 +10,13 @@ interface I { class C { - // CHECK:STDERR: fail_extend_partially_defined_interface.carbon:[[@LINE+11]]:5: error: impl as incomplete facet type `I` [ImplAsIncompleteFacetType] + // TODO: Don't generate "impl declared but not defined" diagnostic + // here after a diagnostic has already been issued. + + // CHECK:STDERR: fail_extend_partially_defined_interface.carbon:[[@LINE+11]]:5: error: `extend impl as` incomplete facet type `I` [ExtendImplAsIncomplete] // CHECK:STDERR: extend impl as I; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ - // CHECK:STDERR: fail_extend_partially_defined_interface.carbon:[[@LINE-5]]:1: note: interface is currently being defined [InterfaceIncompleteWithinDefinition] + // CHECK:STDERR: fail_extend_partially_defined_interface.carbon:[[@LINE-8]]:1: note: interface is currently being defined [InterfaceIncompleteWithinDefinition] // CHECK:STDERR: interface I { // CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: @@ -32,6 +35,7 @@ interface I { // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] // CHECK:STDOUT: %C.f28: type = class_type @C [concrete] // CHECK:STDOUT: %C.6b4: type = class_type @C, @C(%Self) [symbolic] +// CHECK:STDOUT: %impl_witness: = impl_witness (), @impl(%Self) [symbolic] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] // CHECK:STDOUT: } @@ -66,6 +70,7 @@ interface I { // CHECK:STDOUT: generic impl @impl(@I.%Self: %I.type) { // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)] // CHECK:STDOUT: %C: type = class_type @C, @C(%Self) [symbolic = %C (constants.%C.6b4)] +// CHECK:STDOUT: %impl_witness: = impl_witness (), @impl(%Self) [symbolic = %impl_witness (constants.%impl_witness)] // CHECK:STDOUT: // CHECK:STDOUT: impl: %Self.ref as %I.ref; // CHECK:STDOUT: } @@ -78,14 +83,14 @@ interface I { // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C.6b4 [symbolic = %C (constants.%C.6b4)] // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type] // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc24: type = specific_constant @impl.%I.ref, @impl(constants.%Self) [concrete = constants.%I.type] +// CHECK:STDOUT: %impl_witness: = impl_witness (), @impl(constants.%Self) [symbolic = @impl.%impl_witness (constants.%impl_witness)] +// CHECK:STDOUT: %.loc27: type = specific_constant @impl.%I.ref, @impl(constants.%Self) [concrete = constants.%I.type] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%C.6b4 // CHECK:STDOUT: .I = -// CHECK:STDOUT: extend %.loc24 // CHECK:STDOUT: has_error // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -95,7 +100,10 @@ interface I { // CHECK:STDOUT: specific @impl(constants.%Self) { // CHECK:STDOUT: %Self => constants.%Self // CHECK:STDOUT: %C => constants.%C.6b4 +// CHECK:STDOUT: %impl_witness => constants.%impl_witness // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @C(@impl.%Self) {} // CHECK:STDOUT: +// CHECK:STDOUT: specific @impl(%Self) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/fail_extend_undefined_interface.carbon b/toolchain/check/testdata/impl/fail_extend_undefined_interface.carbon index 45b1d2ee4985..5fff1babf44b 100644 --- a/toolchain/check/testdata/impl/fail_extend_undefined_interface.carbon +++ b/toolchain/check/testdata/impl/fail_extend_undefined_interface.carbon @@ -11,42 +11,22 @@ interface I; class C { - // CHECK:STDERR: fail_extend_undefined_interface.carbon:[[@LINE+7]]:3: error: impl as incomplete facet type `I` [ImplAsIncompleteFacetType] + // CHECK:STDERR: fail_extend_undefined_interface.carbon:[[@LINE+11]]:3: error: `extend impl as` incomplete facet type `I` [ExtendImplAsIncomplete] // CHECK:STDERR: extend impl as I; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_extend_undefined_interface.carbon:[[@LINE-6]]:1: note: interface was forward declared here [InterfaceForwardDeclaredHere] // CHECK:STDERR: interface I; // CHECK:STDERR: ^~~~~~~~~~~~ // CHECK:STDERR: + // CHECK:STDERR: fail_extend_undefined_interface.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] + // CHECK:STDERR: extend impl as I; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ + // CHECK:STDERR: extend impl as I; } fn F(c: C) { - // CHECK:STDERR: fail_extend_undefined_interface.carbon:[[@LINE+10]]:3: error: member access into incomplete facet type `I` [QualifiedExprInIncompleteFacetTypeScope] - // CHECK:STDERR: C.F(); - // CHECK:STDERR: ^~~ - // CHECK:STDERR: fail_extend_undefined_interface.carbon:[[@LINE-17]]:1: note: interface was forward declared here [InterfaceForwardDeclaredHere] - // CHECK:STDERR: interface I; - // CHECK:STDERR: ^~~~~~~~~~~~ - // CHECK:STDERR: fail_extend_undefined_interface.carbon:[[@LINE-10]]:18: note: declared as an extended scope here [FromExtendHere] - // CHECK:STDERR: extend impl as I; - // CHECK:STDERR: ^ - // CHECK:STDERR: C.F(); - // CHECK:STDERR: fail_extend_undefined_interface.carbon:[[@LINE+14]]:3: error: member access into incomplete facet type `I` [QualifiedExprInIncompleteFacetTypeScope] - // CHECK:STDERR: c.F(); - // CHECK:STDERR: ^~~ - // CHECK:STDERR: fail_extend_undefined_interface.carbon:[[@LINE-28]]:1: note: interface was forward declared here [InterfaceForwardDeclaredHere] - // CHECK:STDERR: interface I; - // CHECK:STDERR: ^~~~~~~~~~~~ - // CHECK:STDERR: fail_extend_undefined_interface.carbon:[[@LINE-21]]:18: note: declared as an extended scope here [FromExtendHere] - // CHECK:STDERR: extend impl as I; - // CHECK:STDERR: ^ - // CHECK:STDERR: - // CHECK:STDERR: fail_extend_undefined_interface.carbon:[[@LINE-25]]:3: error: impl declared but not defined [ImplMissingDefinition] - // CHECK:STDERR: extend impl as I; - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ - // CHECK:STDERR: c.F(); } @@ -55,6 +35,7 @@ fn F(c: C) { // CHECK:STDOUT: constants { // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] // CHECK:STDOUT: %C: type = class_type @C [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] // CHECK:STDOUT: %F.type: type = fn_type @F [concrete] @@ -83,7 +64,7 @@ fn F(c: C) { // CHECK:STDOUT: %c.param_patt: %C = value_param_pattern %c.patt, call_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %c.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc24: type = name_ref C, file.%C.decl [concrete = constants.%C] +// CHECK:STDOUT: %C.ref.loc28: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %c: %C = bind_name c, %c.param // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -97,6 +78,7 @@ fn F(c: C) { // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C] // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type] // CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: @@ -104,16 +86,15 @@ fn F(c: C) { // CHECK:STDOUT: .Self = constants.%C // CHECK:STDOUT: .I = // CHECK:STDOUT: .F = -// CHECK:STDOUT: extend @impl.%I.ref // CHECK:STDOUT: has_error // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%c.param_patt: %C) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %C.ref.loc35: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %F.ref.loc35: = name_ref F, [concrete = ] +// CHECK:STDOUT: %C.ref.loc29: type = name_ref C, file.%C.decl [concrete = constants.%C] +// CHECK:STDOUT: %F.ref.loc29: = name_ref F, [concrete = ] // CHECK:STDOUT: %c.ref: %C = name_ref c, %c -// CHECK:STDOUT: %F.ref.loc50: = name_ref F, [concrete = ] +// CHECK:STDOUT: %F.ref.loc30: = name_ref F, [concrete = ] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon b/toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon index 1654b292ccc8..879cae5f2d82 100644 --- a/toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon +++ b/toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon @@ -18,16 +18,12 @@ class C { extend impl as I; } -fn F() -> i32 { - // CHECK:STDERR: fail_todo_undefined_impl.carbon:[[@LINE+8]]:10: error: accessing member from impl before the end of its definition [ImplAccessMemberBeforeComplete] - // CHECK:STDERR: return C.F(); - // CHECK:STDERR: ^~~ +fn F() { + // CHECK:STDERR: fail_todo_undefined_impl.carbon:[[@LINE+4]]:3: error: accessing member from impl before it has a defined value [ImplAccessMemberBeforeSet] + // CHECK:STDERR: C.F(); + // CHECK:STDERR: ^~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_undefined_impl.carbon:[[@LINE-8]]:3: error: impl declared but not defined [ImplMissingDefinition] - // CHECK:STDERR: extend impl as I; - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ - // CHECK:STDERR: - return C.F(); + C.F(); } // TODO: This should be written `impl C.(Self as I)` or `impl C.(as I)`, once @@ -36,6 +32,18 @@ impl C as I { fn F() {} } +fn G() { + // CHECK:STDERR: fail_todo_undefined_impl.carbon:[[@LINE+8]]:3: error: accessing member from impl before it has a defined value [ImplAccessMemberBeforeSet] + // CHECK:STDERR: C.F(); + // CHECK:STDERR: ^~~ + // CHECK:STDERR: + // CHECK:STDERR: fail_todo_undefined_impl.carbon:[[@LINE-22]]:3: error: impl declared but not defined [ImplMissingDefinition] + // CHECK:STDERR: extend impl as I; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + C.F(); +} + // CHECK:STDOUT: --- fail_todo_undefined_impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -46,24 +54,23 @@ impl C as I { // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type [concrete] // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%F.decl [concrete] // CHECK:STDOUT: %C: type = class_type @C [concrete] -// CHECK:STDOUT: %impl_witness.85b: = impl_witness () [concrete] +// CHECK:STDOUT: %impl_witness.1bc: = impl_witness () [concrete] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] -// CHECK:STDOUT: %complete_type.357: = complete_type_witness %empty_struct_type [concrete] -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] // CHECK:STDOUT: %F.type.b25: type = fn_type @F.2 [concrete] // CHECK:STDOUT: %F.c41: %F.type.b25 = struct_value () [concrete] -// CHECK:STDOUT: %I.facet.2df: %I.type = facet_value %C, (%impl_witness.85b) [concrete] -// CHECK:STDOUT: %.5b6: type = fn_type_with_self_type %F.type.cf0, %I.facet.2df [concrete] +// CHECK:STDOUT: %I.facet.998: %I.type = facet_value %C, (%impl_witness.1bc) [concrete] +// CHECK:STDOUT: %.995: type = fn_type_with_self_type %F.type.cf0, %I.facet.998 [concrete] // CHECK:STDOUT: %impl_witness.054: = impl_witness (@impl.770.%F.decl) [concrete] // CHECK:STDOUT: %F.type.5d6: type = fn_type @F.3 [concrete] // CHECK:STDOUT: %F.a2e: %F.type.5d6 = struct_value () [concrete] // CHECK:STDOUT: %I.facet.702: %I.type = facet_value %C, (%impl_witness.054) [concrete] +// CHECK:STDOUT: %G.type: type = fn_type @G [concrete] +// CHECK:STDOUT: %G: %G.type = struct_value () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: .Int = %Core.Int // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } @@ -75,24 +82,18 @@ impl C as I { // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {} // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} -// CHECK:STDOUT: %F.decl: %F.type.b25 = fn_decl @F.2 [concrete = constants.%F.c41] { -// CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern -// CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, call_param0 -// CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] -// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0 -// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param -// CHECK:STDOUT: } +// CHECK:STDOUT: %F.decl: %F.type.b25 = fn_decl @F.2 [concrete = constants.%F.c41] {} {} // CHECK:STDOUT: impl_decl @impl.770 [concrete] {} { // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type] // CHECK:STDOUT: } // CHECK:STDOUT: %impl_witness: = impl_witness (@impl.770.%F.decl) [concrete = constants.%impl_witness.054] +// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: interface @I { @@ -121,8 +122,8 @@ impl C as I { // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C] // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type] // CHECK:STDOUT: } -// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness.85b] -// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357] +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness.1bc] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: // CHECK:STDOUT: !members: @@ -136,12 +137,12 @@ impl C as I { // CHECK:STDOUT: fn(); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.2() -> %i32 { +// CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %F.ref: %I.assoc_type = name_ref F, @I.%assoc0 [concrete = constants.%assoc0] -// CHECK:STDOUT: %impl.elem0: %.5b6 = impl_witness_access constants.%impl_witness.85b, element0 [concrete = ] -// CHECK:STDOUT: return +// CHECK:STDOUT: %impl.elem0: %.995 = impl_witness_access constants.%impl_witness.1bc, element0 [concrete = ] +// CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.3() { @@ -149,6 +150,14 @@ impl C as I { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: fn @G() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] +// CHECK:STDOUT: %F.ref: %I.assoc_type = name_ref F, @I.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %impl.elem0: %.995 = impl_witness_access constants.%impl_witness.1bc, element0 [concrete = ] +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: specific @F.1(constants.%Self) {} // CHECK:STDOUT: // CHECK:STDOUT: specific @F.1(constants.%I.facet.702) {} diff --git a/toolchain/check/testdata/impl/min_prelude/forward_decls.carbon b/toolchain/check/testdata/impl/min_prelude/forward_decls.carbon new file mode 100644 index 000000000000..44baafd6f29f --- /dev/null +++ b/toolchain/check/testdata/impl/min_prelude/forward_decls.carbon @@ -0,0 +1,2460 @@ +// 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/min_prelude/facet_types.carbon +// EXTRA-ARGS: --custom-core +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/min_prelude/forward_decls.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/min_prelude/forward_decls.carbon + +// --- empty.carbon +library "[[@TEST_NAME]]"; + +interface I; +impl {} as I; + +interface I {} +impl {} as I {} + +// --- method.carbon +library "[[@TEST_NAME]]"; + +interface I; +impl {} as I; + +interface I { + fn G(); +} +impl {} as I { + fn G() {} +} + +// --- combine.carbon +library "[[@TEST_NAME]]"; + +interface I; +impl {} as I & I; + +interface I {} +impl {} as I & I {} + +// --- associated_const.carbon +library "[[@TEST_NAME]]"; + +interface I { + let T:! type; +} +impl {} as I where .T = (); + +impl {} as I where .T = () {} + +// --- associated_const_compound_member_access.carbon +library "[[@TEST_NAME]]"; + +interface I { + let T:! type; +} +class C {} +impl C as I where .T = (); + +let x: C.(I.T) = (); + +impl C as I where .T = () {} + +// --- associated_const_of_facet.carbon +library "[[@TEST_NAME]]"; + +interface I { + let T:! type; +} +class C {} +impl C as I where .T = (); + +let x: (C as I).T = (); + +impl C as I where .T = () {} + +// --- fail_unset_associated_const.carbon +library "[[@TEST_NAME]]"; + +interface I { + let T:! type; +} +class C {} +impl C as I; + +// CHECK:STDERR: fail_unset_associated_const.carbon:[[@LINE+11]]:8: error: accessing member from impl before it has a defined value [ImplAccessMemberBeforeSet] +// CHECK:STDERR: let x: (C as I).T = (); +// CHECK:STDERR: ^~~~~~~~~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_unset_associated_const.carbon:[[@LINE-6]]:11: error: associated constant T not given a value in impl of interface I [ImplAssociatedConstantNeedsValue] +// CHECK:STDERR: impl C as I; +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_unset_associated_const.carbon:[[@LINE-12]]:7: note: associated constant declared here [AssociatedConstantHere] +// CHECK:STDERR: let T:! type; +// CHECK:STDERR: ^~~~~~~~ +// CHECK:STDERR: +let x: (C as I).T = (); + +impl C as I {} + +// --- fail_associated_const_before_interface_definition.carbon +library "[[@TEST_NAME]]"; + +interface I; +class C; +class D {} +// CHECK:STDERR: fail_associated_const_before_interface_definition.carbon:[[@LINE+7]]:19: error: member access into object of incomplete type `I` [IncompleteTypeInMemberAccess] +// CHECK:STDERR: impl D as I where .T = C; +// CHECK:STDERR: ^~ +// CHECK:STDERR: fail_associated_const_before_interface_definition.carbon:[[@LINE-6]]:1: note: interface was forward declared here [InterfaceForwardDeclaredHere] +// CHECK:STDERR: interface I; +// CHECK:STDERR: ^~~~~~~~~~~~ +// CHECK:STDERR: +impl D as I where .T = C; + +interface I {} +class C {} +// CHECK:STDERR: fail_associated_const_before_interface_definition.carbon:[[@LINE+4]]:19: error: member name `T` not found in `I` [MemberNameNotFoundInInstScope] +// CHECK:STDERR: impl D as I where .T = C {} +// CHECK:STDERR: ^~ +// CHECK:STDERR: +impl D as I where .T = C {} + +// --- associated_const_of_parameterized.carbon +library "[[@TEST_NAME]]"; + +interface I(U:! type) { + let T:! type; +} +class C; +class D {} +impl D as I(C) where .T = C; + +class C {} +impl D as I(C) where .T = C {} + +// --- find_incomplete_impl.carbon +library "[[@TEST_NAME]]"; + +interface I; +class D {} +impl D as I; +class C(T:! I); + +fn F(x: C(D)); + +interface I {} +impl D as I {} +class C(T:! I) {} + +fn F(x: C(D)) {} + +// --- fail_todo_two_interfaces.carbon +library "[[@TEST_NAME]]"; + +interface I; +interface J; + +// TODO: Don't generate "impl declared but not defined" diagnostic +// here after a diagnostic has already been issued. + +// CHECK:STDERR: fail_todo_two_interfaces.carbon:[[@LINE+8]]:1: error: impl as 2 interfaces, expected 1 [ImplOfNotOneInterface] +// CHECK:STDERR: impl {} as I & J; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_todo_two_interfaces.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition] +// CHECK:STDERR: impl {} as I & J; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +impl {} as I & J; + +interface I {} +interface J {} + +// --- fail_todo_never_assigned_associated_const.carbon +library "[[@TEST_NAME]]"; + +interface I { + let T:! type; + let U:! type; +} +class C {} + +// TODO: Should accept this, once we support setting +// associated constants in the body of the impl definition. + +// CHECK:STDERR: fail_todo_never_assigned_associated_const.carbon:[[@LINE+7]]:11: error: associated constant U not given a value in impl of interface I [ImplAssociatedConstantNeedsValue] +// CHECK:STDERR: impl C as I where .T = (); +// CHECK:STDERR: ^~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_todo_never_assigned_associated_const.carbon:[[@LINE-10]]:7: note: associated constant declared here [AssociatedConstantHere] +// CHECK:STDERR: let U:! type; +// CHECK:STDERR: ^~~~~~~~ +// CHECK:STDERR: +impl C as I where .T = (); + +// TODO: This should fail instead, unless there is a +// `where U = ...` declaration in the body of the impl. +impl C as I where .T = () {} + +// --- example_from_proposal_5168.carbon +library "[[@TEST_NAME]]"; + +interface X; + +// Allowed to use incomplete interfaces in function declarations. +fn F(U:! X); +fn G[U:! X](u: U); + +class C; + +// Allowed to use incomplete types and interfaces in impl declarations. +impl C as X; + +interface Y; + +interface X { + // TODO: Should be allowed to use an incomplete interface here, + // but `require Self impls` is not supported yet. + // require Self impls Y; +} + +// Classes must be defined before being used in a function definition. +class C {} + +fn H(c: C) { + // Allowed since C is complete and we have a declaration `impl C as X;` + F(C); + G(c); +} + +// The above declarations require that `interface Y`, `fn F` (since it is +// generic), and `impl C as X` are defined in the same file. +interface Y {} +fn F(U:! X) {} +fn G[U:! X](u: U) {} +impl C as Y; +impl C as X {} +impl C as Y {} + +// --- fail_todo_impl_in_interface_definition.carbon +library "[[@TEST_NAME]]"; + +// This test uses many unsupported features, and is expected to change. +interface I { + // CHECK:STDERR: fail_todo_impl_in_interface_definition.carbon:[[@LINE+4]]:3: error: semantics TODO: `interface modifier` [SemanticsTodo] + // CHECK:STDERR: default fn F() { + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: + default fn F() { + class C {} + // CHECK:STDERR: fail_todo_impl_in_interface_definition.carbon:[[@LINE+8]]:5: error: `impl` with unused generic binding [ImplUnusedBinding] + // CHECK:STDERR: impl C as I; + // CHECK:STDERR: ^~~~~~~~~~~~ + // CHECK:STDERR: + // CHECK:STDERR: fail_todo_impl_in_interface_definition.carbon:[[@LINE+4]]:5: error: impl declared but not defined [ImplMissingDefinition] + // CHECK:STDERR: impl C as I; + // CHECK:STDERR: ^~~~~~~~~~~~ + // CHECK:STDERR: + impl C as I; + } +} + +// --- fail_todo_impl_in_interface_definition_with_associated.carbon +library "[[@TEST_NAME]]"; + +// This test uses many unsupported features, and is expected to change. +interface I { + let U:! type; + // CHECK:STDERR: fail_todo_impl_in_interface_definition_with_associated.carbon:[[@LINE+4]]:3: error: semantics TODO: `interface modifier` [SemanticsTodo] + // CHECK:STDERR: default fn F() { + // CHECK:STDERR: ^~~~~~~ + // CHECK:STDERR: + default fn F() { + class C {} + // CHECK:STDERR: fail_todo_impl_in_interface_definition_with_associated.carbon:[[@LINE+4]]:5: error: `impl` with unused generic binding [ImplUnusedBinding] + // CHECK:STDERR: impl C as I where .U = C; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + impl C as I where .U = C; + + impl C as I where .U = C {} + } +} + +// CHECK:STDOUT: --- empty.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl.loc3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl.loc3: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %.loc4_7.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc4_7.2: type = converted %.loc4_7.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type] +// CHECK:STDOUT: %I.ref.loc4: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness] +// CHECK:STDOUT: %I.decl.loc6: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %.loc7_7.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc7_7.2: type = converted %.loc7_7.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type] +// CHECK:STDOUT: %I.ref.loc7: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc4_7.2 as %I.ref.loc4 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- method.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness (@impl.%G.decl) [concrete] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %G.type.ccd: type = fn_type @G.1 [concrete] +// CHECK:STDOUT: %G.600: %G.type.ccd = struct_value () [concrete] +// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type [concrete] +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%G.decl [concrete] +// CHECK:STDOUT: %G.type.d6f: type = fn_type @G.2 [concrete] +// CHECK:STDOUT: %G.d07: %G.type.d6f = struct_value () [concrete] +// CHECK:STDOUT: %I.facet: %I.type = facet_value %empty_struct_type, (%impl_witness) [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl.loc3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl.loc3: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %.loc4_7.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc4_7.2: type = converted %.loc4_7.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type] +// CHECK:STDOUT: %I.ref.loc4: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (@impl.%G.decl) [concrete = constants.%impl_witness] +// CHECK:STDOUT: %I.decl.loc6: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %.loc9_7.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_7.2: type = converted %.loc9_7.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type] +// CHECK:STDOUT: %I.ref.loc9: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %G.decl: %G.type.ccd = fn_decl @G.1 [concrete = constants.%G.600] {} {} +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %G.decl [concrete = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .G = %assoc0 +// CHECK:STDOUT: witness = (%G.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc4_7.2 as %I.ref.loc4 { +// CHECK:STDOUT: %G.decl: %G.type.d6f = fn_decl @G.2 [concrete = constants.%G.d07] {} {} +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .G = %G.decl +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @G.1(@I.%Self: %I.type) { +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @G.2() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G.1(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G.1(constants.%I.facet) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- combine.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %BitAnd.type: type = facet_type <@BitAnd> [concrete] +// CHECK:STDOUT: %Self.25f: %BitAnd.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %BitAnd.assoc_type: type = assoc_entity_type %BitAnd.type [concrete] +// CHECK:STDOUT: %assoc0: %BitAnd.assoc_type = assoc_entity element0, imports.%Core.import_ref.a93 [concrete] +// CHECK:STDOUT: %Op.type.27a: type = fn_type @Op.1 [concrete] +// CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.25f [symbolic] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %impl_witness.db8: = impl_witness (imports.%Core.import_ref.1e6), @impl.f92(%T) [symbolic] +// CHECK:STDOUT: %Op.type.f99: type = fn_type @Op.2, @impl.f92(%T) [symbolic] +// CHECK:STDOUT: %Op.05a: %Op.type.f99 = struct_value () [symbolic] +// CHECK:STDOUT: %require_complete: = require_complete_type %T [symbolic] +// CHECK:STDOUT: %impl_witness.3ea: = impl_witness (imports.%Core.import_ref.1e6), @impl.f92(type) [concrete] +// CHECK:STDOUT: %impl_witness.b81: = impl_witness (imports.%Core.import_ref.bd4), @impl.f92(%T) [symbolic] +// CHECK:STDOUT: %Op.type.eb8: type = fn_type @Op.2, @impl.f92(type) [concrete] +// CHECK:STDOUT: %Op.444: %Op.type.eb8 = struct_value () [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness type [concrete] +// CHECK:STDOUT: %BitAnd.facet: %BitAnd.type = facet_value type, (%impl_witness.3ea) [concrete] +// CHECK:STDOUT: %.2ac: type = fn_type_with_self_type %Op.type.27a, %BitAnd.facet [concrete] +// CHECK:STDOUT: %Op.bound: = bound_method %I.type, %Op.444 [concrete] +// CHECK:STDOUT: %Op.specific_fn: = specific_function %Op.444, @Op.2(type) [concrete] +// CHECK:STDOUT: %bound_method: = bound_method %I.type, %Op.specific_fn [concrete] +// CHECK:STDOUT: %impl_witness.1bc: = impl_witness () [concrete] +// CHECK:STDOUT: %Self.826: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: .BitAnd = %Core.BitAnd +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import_ref.ad0 = import_ref Core//prelude, inst101 [no loc], unloaded +// CHECK:STDOUT: %Core.import_ref.08d: %BitAnd.assoc_type = import_ref Core//prelude, loc18_41, loaded [concrete = constants.%assoc0] +// CHECK:STDOUT: %Core.Op = import_ref Core//prelude, Op, unloaded +// CHECK:STDOUT: %Core.import_ref.040: %BitAnd.type = import_ref Core//prelude, inst101 [no loc], loaded [symbolic = constants.%Self.25f] +// CHECK:STDOUT: %Core.import_ref.51c: = import_ref Core//prelude, loc21_36, loaded [symbolic = @impl.f92.%impl_witness (constants.%impl_witness.b81)] +// CHECK:STDOUT: %Core.import_ref.5ab3ec.1: type = import_ref Core//prelude, loc21_14, loaded [symbolic = @impl.f92.%T (constants.%T)] +// CHECK:STDOUT: %Core.import_ref.583: type = import_ref Core//prelude, loc21_24, loaded [symbolic = @impl.f92.%T (constants.%T)] +// CHECK:STDOUT: %Core.import_ref.9c1: type = import_ref Core//prelude, loc21_29, loaded [concrete = constants.%BitAnd.type] +// CHECK:STDOUT: %Core.import_ref.1e6: @impl.f92.%Op.type (%Op.type.f99) = import_ref Core//prelude, loc22_42, loaded [symbolic = @impl.f92.%Op (constants.%Op.05a)] +// CHECK:STDOUT: %Core.import_ref.5ab3ec.2: type = import_ref Core//prelude, loc21_14, loaded [symbolic = @impl.f92.%T (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl.loc3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl.loc3: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: %.loc4_14.1: type = value_of_initializer @impl.8dc.%type.and.loc4 [concrete = constants.%I.type] +// CHECK:STDOUT: %.loc4_14.2: type = converted @impl.8dc.%type.and.loc4, %.loc4_14.1 [concrete = constants.%I.type] +// CHECK:STDOUT: impl_decl @impl.8dc [concrete] {} { +// CHECK:STDOUT: %.loc4_7.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc4_7.2: type = converted %.loc4_7.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type] +// CHECK:STDOUT: %I.ref.loc4_12: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: %I.ref.loc4_16: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: %impl.elem0.loc4: %.2ac = impl_witness_access constants.%impl_witness.3ea, element0 [concrete = constants.%Op.444] +// CHECK:STDOUT: %bound_method.loc4_14.1: = bound_method %I.ref.loc4_12, %impl.elem0.loc4 [concrete = constants.%Op.bound] +// CHECK:STDOUT: %specific_fn.loc4: = specific_function %impl.elem0.loc4, @Op.2(type) [concrete = constants.%Op.specific_fn] +// CHECK:STDOUT: %bound_method.loc4_14.2: = bound_method %I.ref.loc4_12, %specific_fn.loc4 [concrete = constants.%bound_method] +// CHECK:STDOUT: %type.and.loc4: init type = call %bound_method.loc4_14.2(%I.ref.loc4_12, %I.ref.loc4_16) [concrete = constants.%I.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness.1bc] +// CHECK:STDOUT: %I.decl.loc6: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: %.loc7_14.1: type = value_of_initializer @impl.8dc.%type.and.loc7 [concrete = constants.%I.type] +// CHECK:STDOUT: %.loc7_14.2: type = converted @impl.8dc.%type.and.loc7, %.loc7_14.1 [concrete = constants.%I.type] +// CHECK:STDOUT: impl_decl @impl.8dc [concrete] {} { +// CHECK:STDOUT: %.loc7_7.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc7_7.2: type = converted %.loc7_7.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type] +// CHECK:STDOUT: %I.ref.loc7_12: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: %I.ref.loc7_16: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: %impl.elem0.loc7: %.2ac = impl_witness_access constants.%impl_witness.3ea, element0 [concrete = constants.%Op.444] +// CHECK:STDOUT: %bound_method.loc7_14.1: = bound_method %I.ref.loc7_12, %impl.elem0.loc7 [concrete = constants.%Op.bound] +// CHECK:STDOUT: %specific_fn.loc7: = specific_function %impl.elem0.loc7, @Op.2(type) [concrete = constants.%Op.specific_fn] +// CHECK:STDOUT: %bound_method.loc7_14.2: = bound_method %I.ref.loc7_12, %specific_fn.loc7 [concrete = constants.%bound_method] +// CHECK:STDOUT: %type.and.loc7: init type = call %bound_method.loc7_14.2(%I.ref.loc7_12, %I.ref.loc7_16) [concrete = constants.%I.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.826] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @BitAnd [from "include_files/facet_types.carbon"] { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%Core.import_ref.ad0 +// CHECK:STDOUT: .Op = imports.%Core.import_ref.08d +// CHECK:STDOUT: witness = (imports.%Core.Op) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic impl @impl.f92(imports.%Core.import_ref.5ab3ec.1: type) [from "include_files/facet_types.carbon"] { +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)] +// CHECK:STDOUT: %impl_witness: = impl_witness (imports.%Core.import_ref.1e6), @impl.f92(%T) [symbolic = %impl_witness (constants.%impl_witness.db8)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Op.type: type = fn_type @Op.2, @impl.f92(%T) [symbolic = %Op.type (constants.%Op.type.f99)] +// CHECK:STDOUT: %Op: @impl.f92.%Op.type (%Op.type.f99) = struct_value () [symbolic = %Op (constants.%Op.05a)] +// CHECK:STDOUT: %require_complete: = require_complete_type @impl.f92.%T (%T) [symbolic = %require_complete (constants.%require_complete)] +// CHECK:STDOUT: +// CHECK:STDOUT: impl: imports.%Core.import_ref.583 as imports.%Core.import_ref.9c1 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%Core.import_ref.51c +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.8dc: %.loc4_7.2 as file.%.loc4_14.2 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Op.1(imports.%Core.import_ref.040: %BitAnd.type) [from "include_files/facet_types.carbon"] { +// CHECK:STDOUT: %Self: %BitAnd.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.25f)] +// CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic = %Self.as_type (constants.%Self.as_type)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self.param_patt: @Op.1.%Self.as_type (%Self.as_type)](%other.param_patt: @Op.1.%Self.as_type (%Self.as_type)) -> @Op.1.%Self.as_type (%Self.as_type); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Op.2(imports.%Core.import_ref.5ab3ec.2: type) [from "include_files/facet_types.carbon"] { +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self.param_patt: @Op.2.%T (%T)](%other.param_patt: @Op.2.%T (%T)) -> @Op.2.%T (%T) = "type.and"; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Op.1(constants.%Self.25f) { +// CHECK:STDOUT: %Self => constants.%Self.25f +// CHECK:STDOUT: %Self.as_type => constants.%Self.as_type +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @impl.f92(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %impl_witness => constants.%impl_witness.db8 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @impl.f92(%T) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Op.2(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @impl.f92(type) { +// CHECK:STDOUT: %T => type +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %impl_witness => constants.%impl_witness.3ea +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Op.type => constants.%Op.type.eb8 +// CHECK:STDOUT: %Op => constants.%Op.444 +// CHECK:STDOUT: %require_complete => constants.%complete_type +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Op.2(type) { +// CHECK:STDOUT: %T => type +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- associated_const.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type [concrete] +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self] +// CHECK:STDOUT: %.Self.as_wit.iface0: = facet_access_witness %.Self, element0 [symbolic_self] +// CHECK:STDOUT: %I.facet: %I.type = facet_value %.Self.as_type, (%.Self.as_wit.iface0) [symbolic_self] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit.iface0, element0 [symbolic_self] +// CHECK:STDOUT: %I_where.type: type = facet_type <@I where %impl.elem0 = %empty_tuple.type> [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness (%empty_tuple.type) [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %.loc6_7.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc6_7.2: type = converted %.loc6_7.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type] +// CHECK:STDOUT: %I.ref.loc6: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %.Self.1: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc6: %I.type = name_ref .Self, %.Self.1 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %T.ref.loc6: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_type.loc6: type = facet_access_type %.Self.ref.loc6 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc6_20: type = converted %.Self.ref.loc6, %.Self.as_type.loc6 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.Self.as_wit.iface0.loc6: = facet_access_witness %.Self.ref.loc6, element0 [symbolic_self = constants.%.Self.as_wit.iface0] +// CHECK:STDOUT: %impl.elem0.loc6: type = impl_witness_access %.Self.as_wit.iface0.loc6, element0 [symbolic_self = constants.%impl.elem0] +// CHECK:STDOUT: %.loc6_26.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_26.2: type = converted %.loc6_26.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc6_14: type = where_expr %.Self.1 [concrete = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc6, %.loc6_26.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%empty_tuple.type) [concrete = constants.%impl_witness] +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %.loc8_7.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc8_7.2: type = converted %.loc8_7.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type] +// CHECK:STDOUT: %I.ref.loc8: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %.Self.2: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc8: %I.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %T.ref.loc8: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_type.loc8: type = facet_access_type %.Self.ref.loc8 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc8_20: type = converted %.Self.ref.loc8, %.Self.as_type.loc8 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.Self.as_wit.iface0.loc8: = facet_access_witness %.Self.ref.loc8, element0 [symbolic_self = constants.%.Self.as_wit.iface0] +// CHECK:STDOUT: %impl.elem0.loc8: type = impl_witness_access %.Self.as_wit.iface0.loc8, element0 [symbolic_self = constants.%impl.elem0] +// CHECK:STDOUT: %.loc8_26.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc8_26.2: type = converted %.loc8_26.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc8_14: type = where_expr %.Self.2 [concrete = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc8, %.loc8_26.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] { +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete = constants.%assoc0] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .T = @T.%assoc0 +// CHECK:STDOUT: witness = (%T) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic assoc_const @T(@I.%Self: %I.type) { +// CHECK:STDOUT: assoc_const T:! type; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc6_7.2 as %.loc6_14 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%I.facet) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- associated_const_compound_member_access.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type [concrete] +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete] +// CHECK:STDOUT: %C: type = class_type @C [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] +// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self] +// CHECK:STDOUT: %.Self.as_wit.iface0: = facet_access_witness %.Self, element0 [symbolic_self] +// CHECK:STDOUT: %I.facet.d87: %I.type = facet_value %.Self.as_type, (%.Self.as_wit.iface0) [symbolic_self] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit.iface0, element0 [symbolic_self] +// CHECK:STDOUT: %I_where.type: type = facet_type <@I where %impl.elem0 = %empty_tuple.type> [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness (%empty_tuple.type) [concrete] +// CHECK:STDOUT: %I.facet.a7f: %I.type = facet_value %C, (%impl_witness) [concrete] +// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .x = %x +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, file.%C.decl [concrete = constants.%C] +// CHECK:STDOUT: %I.ref.loc7: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %.Self.1: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc7: %I.type = name_ref .Self, %.Self.1 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %T.ref.loc7: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_type.loc7: type = facet_access_type %.Self.ref.loc7 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc7_19: type = converted %.Self.ref.loc7, %.Self.as_type.loc7 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.Self.as_wit.iface0.loc7: = facet_access_witness %.Self.ref.loc7, element0 [symbolic_self = constants.%.Self.as_wit.iface0] +// CHECK:STDOUT: %impl.elem0.loc7: type = impl_witness_access %.Self.as_wit.iface0.loc7, element0 [symbolic_self = constants.%impl.elem0] +// CHECK:STDOUT: %.loc7_25.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc7_25.2: type = converted %.loc7_25.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc7_13: type = where_expr %.Self.1 [concrete = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc7, %.loc7_25.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%empty_tuple.type) [concrete = constants.%impl_witness] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc9_9.1: type = splice_block %impl.elem0 [concrete = constants.%empty_tuple.type] { +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [concrete = constants.%C] +// CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %T.ref: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %I.facet: %I.type = facet_value constants.%C, (constants.%impl_witness) [concrete = constants.%I.facet.a7f] +// CHECK:STDOUT: %.loc9_9.2: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet.a7f] +// CHECK:STDOUT: %as_wit.iface0: = facet_access_witness %.loc9_9.2, element0 [concrete = constants.%impl_witness] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %as_wit.iface0, element0 [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc9_19: %empty_tuple.type = converted @__global_init.%.loc9, %empty_tuple [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %x: %empty_tuple.type = bind_name x, %.loc9_19 +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %C.ref.loc11: type = name_ref C, file.%C.decl [concrete = constants.%C] +// CHECK:STDOUT: %I.ref.loc11: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %.Self.2: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc11: %I.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %T.ref.loc11: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_type.loc11: type = facet_access_type %.Self.ref.loc11 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc11_19: type = converted %.Self.ref.loc11, %.Self.as_type.loc11 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.Self.as_wit.iface0.loc11: = facet_access_witness %.Self.ref.loc11, element0 [symbolic_self = constants.%.Self.as_wit.iface0] +// CHECK:STDOUT: %impl.elem0.loc11: type = impl_witness_access %.Self.as_wit.iface0.loc11, element0 [symbolic_self = constants.%impl.elem0] +// CHECK:STDOUT: %.loc11_25.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc11_25.2: type = converted %.loc11_25.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc11_13: type = where_expr %.Self.2 [concrete = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc11, %.loc11_25.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] { +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete = constants.%assoc0] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .T = @T.%assoc0 +// CHECK:STDOUT: witness = (%T) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic assoc_const @T(@I.%Self: %I.type) { +// CHECK:STDOUT: assoc_const T:! type; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %C.ref.loc7 as %.loc7_13 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc9: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%I.facet.d87) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%I.facet.a7f) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- associated_const_of_facet.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type [concrete] +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete] +// CHECK:STDOUT: %C: type = class_type @C [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] +// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self] +// CHECK:STDOUT: %.Self.as_wit.iface0: = facet_access_witness %.Self, element0 [symbolic_self] +// CHECK:STDOUT: %I.facet.d87: %I.type = facet_value %.Self.as_type, (%.Self.as_wit.iface0) [symbolic_self] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit.iface0, element0 [symbolic_self] +// CHECK:STDOUT: %I_where.type: type = facet_type <@I where %impl.elem0 = %empty_tuple.type> [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness (%empty_tuple.type) [concrete] +// CHECK:STDOUT: %I.facet.a7f: %I.type = facet_value %C, (%impl_witness) [concrete] +// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .x = %x +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, file.%C.decl [concrete = constants.%C] +// CHECK:STDOUT: %I.ref.loc7: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %.Self.1: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc7: %I.type = name_ref .Self, %.Self.1 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %T.ref.loc7: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_type.loc7: type = facet_access_type %.Self.ref.loc7 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc7_19: type = converted %.Self.ref.loc7, %.Self.as_type.loc7 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.Self.as_wit.iface0.loc7: = facet_access_witness %.Self.ref.loc7, element0 [symbolic_self = constants.%.Self.as_wit.iface0] +// CHECK:STDOUT: %impl.elem0.loc7: type = impl_witness_access %.Self.as_wit.iface0.loc7, element0 [symbolic_self = constants.%impl.elem0] +// CHECK:STDOUT: %.loc7_25.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc7_25.2: type = converted %.loc7_25.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc7_13: type = where_expr %.Self.1 [concrete = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc7, %.loc7_25.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%empty_tuple.type) [concrete = constants.%impl_witness] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc9_16.1: type = splice_block %impl.elem0 [concrete = constants.%empty_tuple.type] { +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [concrete = constants.%C] +// CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %I.facet: %I.type = facet_value constants.%C, (constants.%impl_witness) [concrete = constants.%I.facet.a7f] +// CHECK:STDOUT: %.loc9_11: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet.a7f] +// CHECK:STDOUT: %T.ref: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %as_type: type = facet_access_type %.loc9_11 [concrete = constants.%C] +// CHECK:STDOUT: %.loc9_16.2: type = converted %.loc9_11, %as_type [concrete = constants.%C] +// CHECK:STDOUT: %as_wit.iface0: = facet_access_witness %.loc9_11, element0 [concrete = constants.%impl_witness] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %as_wit.iface0, element0 [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc9_22: %empty_tuple.type = converted @__global_init.%.loc9, %empty_tuple [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %x: %empty_tuple.type = bind_name x, %.loc9_22 +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %C.ref.loc11: type = name_ref C, file.%C.decl [concrete = constants.%C] +// CHECK:STDOUT: %I.ref.loc11: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %.Self.2: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc11: %I.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %T.ref.loc11: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_type.loc11: type = facet_access_type %.Self.ref.loc11 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc11_19: type = converted %.Self.ref.loc11, %.Self.as_type.loc11 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.Self.as_wit.iface0.loc11: = facet_access_witness %.Self.ref.loc11, element0 [symbolic_self = constants.%.Self.as_wit.iface0] +// CHECK:STDOUT: %impl.elem0.loc11: type = impl_witness_access %.Self.as_wit.iface0.loc11, element0 [symbolic_self = constants.%impl.elem0] +// CHECK:STDOUT: %.loc11_25.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc11_25.2: type = converted %.loc11_25.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc11_13: type = where_expr %.Self.2 [concrete = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc11, %.loc11_25.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] { +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete = constants.%assoc0] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .T = @T.%assoc0 +// CHECK:STDOUT: witness = (%T) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic assoc_const @T(@I.%Self: %I.type) { +// CHECK:STDOUT: assoc_const T:! type; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %C.ref.loc7 as %.loc7_13 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc9: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%I.facet.d87) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%I.facet.a7f) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_unset_associated_const.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type [concrete] +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete] +// CHECK:STDOUT: %C: type = class_type @C [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete] +// CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%impl_witness) [concrete] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .x = %x +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, file.%C.decl [concrete = constants.%C] +// CHECK:STDOUT: %I.ref.loc7: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: = binding_pattern x +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc20_16.1: type = splice_block %impl.elem0 [concrete = ] { +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [concrete = constants.%C] +// CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %I.facet: %I.type = facet_value constants.%C, (constants.%impl_witness) [concrete = constants.%I.facet] +// CHECK:STDOUT: %.loc20_11: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet] +// CHECK:STDOUT: %T.ref: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %as_type: type = facet_access_type %.loc20_11 [concrete = constants.%C] +// CHECK:STDOUT: %.loc20_16.2: type = converted %.loc20_11, %as_type [concrete = constants.%C] +// CHECK:STDOUT: %as_wit.iface0: = facet_access_witness %.loc20_11, element0 [concrete = constants.%impl_witness] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %as_wit.iface0, element0 [concrete = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: = bind_name x, +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %C.ref.loc22: type = name_ref C, file.%C.decl [concrete = constants.%C] +// CHECK:STDOUT: %I.ref.loc22: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] { +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete = constants.%assoc0] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .T = @T.%assoc0 +// CHECK:STDOUT: witness = (%T) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic assoc_const @T(@I.%Self: %I.type) { +// CHECK:STDOUT: assoc_const T:! type; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %C.ref.loc7 as %I.ref.loc7 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc20: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%I.facet) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_associated_const_before_interface_definition.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %C: type = class_type @C [concrete] +// CHECK:STDOUT: %D: type = class_type @D [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] +// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl.loc3 +// CHECK:STDOUT: .C = %C.decl.loc4 +// CHECK:STDOUT: .D = %D.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl.loc3: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: %C.decl.loc4: type = class_decl @C [concrete = constants.%C] {} {} +// CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %D.ref.loc13: type = name_ref D, file.%D.decl [concrete = constants.%D] +// CHECK:STDOUT: %I.ref.loc13: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: %.Self.1: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc13: %I.type = name_ref .Self, %.Self.1 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %C.ref.loc13: type = name_ref C, file.%C.decl.loc4 [concrete = constants.%C] +// CHECK:STDOUT: %.loc13: type = where_expr %.Self.1 [concrete = ] { +// CHECK:STDOUT: requirement_rewrite , +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %I.decl.loc15: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: %C.decl.loc16: type = class_decl @C [concrete = constants.%C] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %D.ref.loc21: type = name_ref D, file.%D.decl [concrete = constants.%D] +// CHECK:STDOUT: %I.ref.loc21: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: %.Self.2: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc21: %I.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %T.ref: = name_ref T, [concrete = ] +// CHECK:STDOUT: %C.ref.loc21: type = name_ref C, file.%C.decl.loc4 [concrete = constants.%C] +// CHECK:STDOUT: %.loc21: type = where_expr %.Self.2 [concrete = ] { +// CHECK:STDOUT: requirement_rewrite %T.ref, +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .T = +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %D.ref.loc13 as %.loc13 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @D { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%D +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- associated_const_of_parameterized.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %U: type = bind_symbolic_name U, 0 [symbolic] +// CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 0 [symbolic] +// CHECK:STDOUT: %I.type.dac: type = generic_interface_type @I [concrete] +// CHECK:STDOUT: %I.generic: %I.type.dac = struct_value () [concrete] +// CHECK:STDOUT: %I.type.325: type = facet_type <@I, @I(%U)> [symbolic] +// CHECK:STDOUT: %Self.209: %I.type.325 = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %I.assoc_type.955: type = assoc_entity_type %I.type.325 [symbolic] +// CHECK:STDOUT: %assoc0.807: %I.assoc_type.955 = assoc_entity element0, @I.%T [symbolic] +// CHECK:STDOUT: %C: type = class_type @C [concrete] +// CHECK:STDOUT: %D: type = class_type @D [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] +// CHECK:STDOUT: %I.type.e7a: type = facet_type <@I, @I(%C)> [concrete] +// CHECK:STDOUT: %.Self: %I.type.e7a = bind_symbolic_name .Self [symbolic_self] +// CHECK:STDOUT: %Self.b1d: %I.type.e7a = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %I.assoc_type.aa7: type = assoc_entity_type %I.type.e7a [concrete] +// CHECK:STDOUT: %assoc0.3ba: %I.assoc_type.aa7 = assoc_entity element0, @I.%T [concrete] +// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self] +// CHECK:STDOUT: %.Self.as_wit.iface0: = facet_access_witness %.Self, element0 [symbolic_self] +// CHECK:STDOUT: %I.facet: %I.type.e7a = facet_value %.Self.as_type, (%.Self.as_wit.iface0) [symbolic_self] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit.iface0, element0 [symbolic_self] +// CHECK:STDOUT: %I_where.type: type = facet_type <@I, @I(%C) where %impl.elem0 = %C> [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness (%C) [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl +// CHECK:STDOUT: .C = %C.decl.loc6 +// CHECK:STDOUT: .D = %D.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl: %I.type.dac = interface_decl @I [concrete = constants.%I.generic] { +// CHECK:STDOUT: %U.patt.loc3_13.1: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc3_13.2 (constants.%U.patt)] +// CHECK:STDOUT: } { +// CHECK:STDOUT: %U.loc3_13.1: type = bind_symbolic_name U, 0 [symbolic = %U.loc3_13.2 (constants.%U)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl.loc6: type = class_decl @C [concrete = constants.%C] {} {} +// CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %D.ref.loc8: type = name_ref D, file.%D.decl [concrete = constants.%D] +// CHECK:STDOUT: %I.ref.loc8: %I.type.dac = name_ref I, file.%I.decl [concrete = constants.%I.generic] +// CHECK:STDOUT: %C.ref.loc8_13: type = name_ref C, file.%C.decl.loc6 [concrete = constants.%C] +// CHECK:STDOUT: %I.type.loc8: type = facet_type <@I, @I(constants.%C)> [concrete = constants.%I.type.e7a] +// CHECK:STDOUT: %.Self.1: %I.type.e7a = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc8: %I.type.e7a = name_ref .Self, %.Self.1 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.loc8_22.1: %I.assoc_type.aa7 = specific_constant @T.%assoc0, @I(constants.%C) [concrete = constants.%assoc0.3ba] +// CHECK:STDOUT: %T.ref.loc8: %I.assoc_type.aa7 = name_ref T, %.loc8_22.1 [concrete = constants.%assoc0.3ba] +// CHECK:STDOUT: %.Self.as_type.loc8: type = facet_access_type %.Self.ref.loc8 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc8_22.2: type = converted %.Self.ref.loc8, %.Self.as_type.loc8 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.Self.as_wit.iface0.loc8: = facet_access_witness %.Self.ref.loc8, element0 [symbolic_self = constants.%.Self.as_wit.iface0] +// CHECK:STDOUT: %impl.elem0.loc8: type = impl_witness_access %.Self.as_wit.iface0.loc8, element0 [symbolic_self = constants.%impl.elem0] +// CHECK:STDOUT: %C.ref.loc8_27: type = name_ref C, file.%C.decl.loc6 [concrete = constants.%C] +// CHECK:STDOUT: %.loc8_16: type = where_expr %.Self.1 [concrete = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc8, %C.ref.loc8_27 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%C) [concrete = constants.%impl_witness] +// CHECK:STDOUT: %C.decl.loc10: type = class_decl @C [concrete = constants.%C] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %D.ref.loc11: type = name_ref D, file.%D.decl [concrete = constants.%D] +// CHECK:STDOUT: %I.ref.loc11: %I.type.dac = name_ref I, file.%I.decl [concrete = constants.%I.generic] +// CHECK:STDOUT: %C.ref.loc11_13: type = name_ref C, file.%C.decl.loc6 [concrete = constants.%C] +// CHECK:STDOUT: %I.type.loc11: type = facet_type <@I, @I(constants.%C)> [concrete = constants.%I.type.e7a] +// CHECK:STDOUT: %.Self.2: %I.type.e7a = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc11: %I.type.e7a = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.loc11_22.1: %I.assoc_type.aa7 = specific_constant @T.%assoc0, @I(constants.%C) [concrete = constants.%assoc0.3ba] +// CHECK:STDOUT: %T.ref.loc11: %I.assoc_type.aa7 = name_ref T, %.loc11_22.1 [concrete = constants.%assoc0.3ba] +// CHECK:STDOUT: %.Self.as_type.loc11: type = facet_access_type %.Self.ref.loc11 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc11_22.2: type = converted %.Self.ref.loc11, %.Self.as_type.loc11 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.Self.as_wit.iface0.loc11: = facet_access_witness %.Self.ref.loc11, element0 [symbolic_self = constants.%.Self.as_wit.iface0] +// CHECK:STDOUT: %impl.elem0.loc11: type = impl_witness_access %.Self.as_wit.iface0.loc11, element0 [symbolic_self = constants.%impl.elem0] +// CHECK:STDOUT: %C.ref.loc11_27: type = name_ref C, file.%C.decl.loc6 [concrete = constants.%C] +// CHECK:STDOUT: %.loc11_16: type = where_expr %.Self.2 [concrete = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc11, %C.ref.loc11_27 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic interface @I(%U.loc3_13.1: type) { +// CHECK:STDOUT: %U.loc3_13.2: type = bind_symbolic_name U, 0 [symbolic = %U.loc3_13.2 (constants.%U)] +// CHECK:STDOUT: %U.patt.loc3_13.2: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc3_13.2 (constants.%U.patt)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%U.loc3_13.2)> [symbolic = %I.type (constants.%I.type.325)] +// CHECK:STDOUT: %Self.2: @I.%I.type (%I.type.325) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.209)] +// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I.%I.type (%I.type.325) [symbolic = %I.assoc_type (constants.%I.assoc_type.955)] +// CHECK:STDOUT: %assoc0: @I.%I.assoc_type (%I.assoc_type.955) = assoc_entity element0, %T [symbolic = %assoc0 (constants.%assoc0.807)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @I.%I.type (%I.type.325) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.209)] +// CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] { +// CHECK:STDOUT: %assoc0: @I.%I.assoc_type (%I.assoc_type.955) = assoc_entity element0, @I.%T [symbolic = @I.%assoc0 (constants.%assoc0.807)] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: .T = @T.%assoc0 +// CHECK:STDOUT: witness = (%T) +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic assoc_const @T(@I.%U.loc3_13.1: type, @I.%Self.1: @I.%I.type (%I.type.325)) { +// CHECK:STDOUT: assoc_const T:! type; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %D.ref.loc8 as %.loc8_16 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @D { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%D +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%U) { +// CHECK:STDOUT: %U.loc3_13.2 => constants.%U +// CHECK:STDOUT: %U.patt.loc3_13.2 => constants.%U.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%U, constants.%Self.209) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(%U.loc3_13.2) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%C) { +// CHECK:STDOUT: %U.loc3_13.2 => constants.%C +// CHECK:STDOUT: %U.patt.loc3_13.2 => constants.%U.patt +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %I.type => constants.%I.type.e7a +// CHECK:STDOUT: %Self.2 => constants.%Self.b1d +// CHECK:STDOUT: %I.assoc_type => constants.%I.assoc_type.aa7 +// CHECK:STDOUT: %assoc0 => constants.%assoc0.3ba +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%C, constants.%I.facet) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- find_incomplete_impl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %D: type = class_type @D [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete] +// CHECK:STDOUT: %T: %I.type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: %I.type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %C.type: type = generic_class_type @C [concrete] +// CHECK:STDOUT: %C.generic: %C.type = struct_value () [concrete] +// CHECK:STDOUT: %C.54e: type = class_type @C, @C(%T) [symbolic] +// CHECK:STDOUT: %I.facet: %I.type = facet_value %D, (%impl_witness) [concrete] +// CHECK:STDOUT: %C.a9d: type = class_type @C, @C(%I.facet) [concrete] +// CHECK:STDOUT: %F.type: type = fn_type @F [concrete] +// CHECK:STDOUT: %F: %F.type = struct_value () [concrete] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl.loc3 +// CHECK:STDOUT: .D = %D.decl +// CHECK:STDOUT: .C = %C.decl.loc6 +// CHECK:STDOUT: .F = %F.decl.loc8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl.loc3: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %D.ref.loc5: type = name_ref D, file.%D.decl [concrete = constants.%D] +// CHECK:STDOUT: %I.ref.loc5: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete = constants.%impl_witness] +// CHECK:STDOUT: %C.decl.loc6: %C.type = class_decl @C [concrete = constants.%C.generic] { +// CHECK:STDOUT: %T.patt.loc12: %I.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6 (constants.%T.patt)] +// CHECK:STDOUT: } { +// CHECK:STDOUT: %I.ref.loc6: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: %T.loc6_9.1: %I.type = bind_symbolic_name T, 0 [symbolic = %T.loc6_9.2 (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %F.decl.loc8: %F.type = fn_decl @F [concrete = constants.%F] { +// CHECK:STDOUT: %x.patt: %C.a9d = binding_pattern x +// CHECK:STDOUT: %x.param_patt: %C.a9d = value_param_pattern %x.patt, call_param0 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %x.param.loc8: %C.a9d = value_param call_param0 +// CHECK:STDOUT: %.loc8_12.1: type = splice_block %C.loc8 [concrete = constants.%C.a9d] { +// CHECK:STDOUT: %C.ref.loc8: %C.type = name_ref C, file.%C.decl.loc6 [concrete = constants.%C.generic] +// CHECK:STDOUT: %D.ref.loc8: type = name_ref D, file.%D.decl [concrete = constants.%D] +// CHECK:STDOUT: %I.facet.loc8: %I.type = facet_value constants.%D, (constants.%impl_witness) [concrete = constants.%I.facet] +// CHECK:STDOUT: %.loc8_12.2: %I.type = converted %D.ref.loc8, %I.facet.loc8 [concrete = constants.%I.facet] +// CHECK:STDOUT: %C.loc8: type = class_type @C, @C(constants.%I.facet) [concrete = constants.%C.a9d] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x.loc8: %C.a9d = bind_name x, %x.param.loc8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %I.decl.loc10: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %D.ref.loc11: type = name_ref D, file.%D.decl [concrete = constants.%D] +// CHECK:STDOUT: %I.ref.loc11: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl.loc12: %C.type = class_decl @C [concrete = constants.%C.generic] { +// CHECK:STDOUT: %T.patt.loc12: %I.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6 (constants.%T.patt)] +// CHECK:STDOUT: } { +// CHECK:STDOUT: %I.ref.loc12: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: %T.loc12: %I.type = bind_symbolic_name T, 0 [symbolic = %T.loc6_9.2 (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %F.decl.loc14: %F.type = fn_decl @F [concrete = constants.%F] { +// CHECK:STDOUT: %x.patt: %C.a9d = binding_pattern x +// CHECK:STDOUT: %x.param_patt: %C.a9d = value_param_pattern %x.patt, call_param0 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %x.param.loc14: %C.a9d = value_param call_param0 +// CHECK:STDOUT: %.loc14_12.1: type = splice_block %C.loc14 [concrete = constants.%C.a9d] { +// CHECK:STDOUT: %C.ref.loc14: %C.type = name_ref C, file.%C.decl.loc6 [concrete = constants.%C.generic] +// CHECK:STDOUT: %D.ref.loc14: type = name_ref D, file.%D.decl [concrete = constants.%D] +// CHECK:STDOUT: %I.facet.loc14: %I.type = facet_value constants.%D, (constants.%impl_witness) [concrete = constants.%I.facet] +// CHECK:STDOUT: %.loc14_12.2: %I.type = converted %D.ref.loc14, %I.facet.loc14 [concrete = constants.%I.facet] +// CHECK:STDOUT: %C.loc14: type = class_type @C, @C(constants.%I.facet) [concrete = constants.%C.a9d] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x.loc14: %C.a9d = bind_name x, %x.param.loc14 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %D.ref.loc5 as %I.ref.loc5 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @D { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%D +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @C(%T.loc6_9.1: %I.type) { +// CHECK:STDOUT: %T.loc6_9.2: %I.type = bind_symbolic_name T, 0 [symbolic = %T.loc6_9.2 (constants.%T)] +// CHECK:STDOUT: %T.patt.loc6: %I.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6 (constants.%T.patt)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C.54e +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F(%x.param_patt: %C.a9d) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%T) { +// CHECK:STDOUT: %T.loc6_9.2 => constants.%T +// CHECK:STDOUT: %T.patt.loc6 => constants.%T.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%I.facet) { +// CHECK:STDOUT: %T.loc6_9.2 => constants.%I.facet +// CHECK:STDOUT: %T.patt.loc6 => constants.%T.patt +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_two_interfaces.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %J.type: type = facet_type <@J> [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %BitAnd.type: type = facet_type <@BitAnd> [concrete] +// CHECK:STDOUT: %Self.25f: %BitAnd.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %BitAnd.assoc_type: type = assoc_entity_type %BitAnd.type [concrete] +// CHECK:STDOUT: %assoc0: %BitAnd.assoc_type = assoc_entity element0, imports.%Core.import_ref.a93 [concrete] +// CHECK:STDOUT: %Op.type.27a: type = fn_type @Op.1 [concrete] +// CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.25f [symbolic] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %impl_witness.db8: = impl_witness (imports.%Core.import_ref.1e6), @impl.f92(%T) [symbolic] +// CHECK:STDOUT: %Op.type.f99: type = fn_type @Op.2, @impl.f92(%T) [symbolic] +// CHECK:STDOUT: %Op.05a: %Op.type.f99 = struct_value () [symbolic] +// CHECK:STDOUT: %require_complete: = require_complete_type %T [symbolic] +// CHECK:STDOUT: %impl_witness.3ea: = impl_witness (imports.%Core.import_ref.1e6), @impl.f92(type) [concrete] +// CHECK:STDOUT: %impl_witness.b81: = impl_witness (imports.%Core.import_ref.bd4), @impl.f92(%T) [symbolic] +// CHECK:STDOUT: %Op.type.eb8: type = fn_type @Op.2, @impl.f92(type) [concrete] +// CHECK:STDOUT: %Op.444: %Op.type.eb8 = struct_value () [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness type [concrete] +// CHECK:STDOUT: %BitAnd.facet: %BitAnd.type = facet_value type, (%impl_witness.3ea) [concrete] +// CHECK:STDOUT: %.2ac: type = fn_type_with_self_type %Op.type.27a, %BitAnd.facet [concrete] +// CHECK:STDOUT: %Op.bound: = bound_method %I.type, %Op.444 [concrete] +// CHECK:STDOUT: %Op.specific_fn: = specific_function %Op.444, @Op.2(type) [concrete] +// CHECK:STDOUT: %bound_method: = bound_method %I.type, %Op.specific_fn [concrete] +// CHECK:STDOUT: %facet_type: type = facet_type <@I & @J> [concrete] +// CHECK:STDOUT: %Self.826: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %Self.ccd: %J.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: .BitAnd = %Core.BitAnd +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import_ref.ad0 = import_ref Core//prelude, inst101 [no loc], unloaded +// CHECK:STDOUT: %Core.import_ref.08d: %BitAnd.assoc_type = import_ref Core//prelude, loc18_41, loaded [concrete = constants.%assoc0] +// CHECK:STDOUT: %Core.Op = import_ref Core//prelude, Op, unloaded +// CHECK:STDOUT: %Core.import_ref.040: %BitAnd.type = import_ref Core//prelude, inst101 [no loc], loaded [symbolic = constants.%Self.25f] +// CHECK:STDOUT: %Core.import_ref.51c: = import_ref Core//prelude, loc21_36, loaded [symbolic = @impl.f92.%impl_witness (constants.%impl_witness.b81)] +// CHECK:STDOUT: %Core.import_ref.5ab3ec.1: type = import_ref Core//prelude, loc21_14, loaded [symbolic = @impl.f92.%T (constants.%T)] +// CHECK:STDOUT: %Core.import_ref.583: type = import_ref Core//prelude, loc21_24, loaded [symbolic = @impl.f92.%T (constants.%T)] +// CHECK:STDOUT: %Core.import_ref.9c1: type = import_ref Core//prelude, loc21_29, loaded [concrete = constants.%BitAnd.type] +// CHECK:STDOUT: %Core.import_ref.1e6: @impl.f92.%Op.type (%Op.type.f99) = import_ref Core//prelude, loc22_42, loaded [symbolic = @impl.f92.%Op (constants.%Op.05a)] +// CHECK:STDOUT: %Core.import_ref.5ab3ec.2: type = import_ref Core//prelude, loc21_14, loaded [symbolic = @impl.f92.%T (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl.loc3 +// CHECK:STDOUT: .J = %J.decl.loc4 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl.loc3: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: %J.decl.loc4: type = interface_decl @J [concrete = constants.%J.type] {} {} +// CHECK:STDOUT: %.loc17_14.1: type = value_of_initializer @impl.be3.%type.and [concrete = constants.%facet_type] +// CHECK:STDOUT: %.loc17_14.2: type = converted @impl.be3.%type.and, %.loc17_14.1 [concrete = constants.%facet_type] +// CHECK:STDOUT: impl_decl @impl.be3 [concrete] {} { +// CHECK:STDOUT: %.loc17_7.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc17_7.2: type = converted %.loc17_7.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type] +// CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl.loc3 [concrete = constants.%I.type] +// CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl.loc4 [concrete = constants.%J.type] +// CHECK:STDOUT: %impl.elem0: %.2ac = impl_witness_access constants.%impl_witness.3ea, element0 [concrete = constants.%Op.444] +// CHECK:STDOUT: %bound_method.loc17_14.1: = bound_method %I.ref, %impl.elem0 [concrete = constants.%Op.bound] +// CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0, @Op.2(type) [concrete = constants.%Op.specific_fn] +// CHECK:STDOUT: %bound_method.loc17_14.2: = bound_method %I.ref, %specific_fn [concrete = constants.%bound_method] +// CHECK:STDOUT: %type.and: init type = call %bound_method.loc17_14.2(%I.ref, %J.ref) [concrete = constants.%facet_type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %I.decl.loc19: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: %J.decl.loc20: type = interface_decl @J [concrete = constants.%J.type] {} {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.826] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @J { +// CHECK:STDOUT: %Self: %J.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.ccd] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @BitAnd [from "include_files/facet_types.carbon"] { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%Core.import_ref.ad0 +// CHECK:STDOUT: .Op = imports.%Core.import_ref.08d +// CHECK:STDOUT: witness = (imports.%Core.Op) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic impl @impl.f92(imports.%Core.import_ref.5ab3ec.1: type) [from "include_files/facet_types.carbon"] { +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)] +// CHECK:STDOUT: %impl_witness: = impl_witness (imports.%Core.import_ref.1e6), @impl.f92(%T) [symbolic = %impl_witness (constants.%impl_witness.db8)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Op.type: type = fn_type @Op.2, @impl.f92(%T) [symbolic = %Op.type (constants.%Op.type.f99)] +// CHECK:STDOUT: %Op: @impl.f92.%Op.type (%Op.type.f99) = struct_value () [symbolic = %Op (constants.%Op.05a)] +// CHECK:STDOUT: %require_complete: = require_complete_type @impl.f92.%T (%T) [symbolic = %require_complete (constants.%require_complete)] +// CHECK:STDOUT: +// CHECK:STDOUT: impl: imports.%Core.import_ref.583 as imports.%Core.import_ref.9c1 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%Core.import_ref.51c +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.be3: %.loc17_7.2 as file.%.loc17_14.2; +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Op.1(imports.%Core.import_ref.040: %BitAnd.type) [from "include_files/facet_types.carbon"] { +// CHECK:STDOUT: %Self: %BitAnd.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.25f)] +// CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic = %Self.as_type (constants.%Self.as_type)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self.param_patt: @Op.1.%Self.as_type (%Self.as_type)](%other.param_patt: @Op.1.%Self.as_type (%Self.as_type)) -> @Op.1.%Self.as_type (%Self.as_type); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Op.2(imports.%Core.import_ref.5ab3ec.2: type) [from "include_files/facet_types.carbon"] { +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self.param_patt: @Op.2.%T (%T)](%other.param_patt: @Op.2.%T (%T)) -> @Op.2.%T (%T) = "type.and"; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Op.1(constants.%Self.25f) { +// CHECK:STDOUT: %Self => constants.%Self.25f +// CHECK:STDOUT: %Self.as_type => constants.%Self.as_type +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @impl.f92(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %impl_witness => constants.%impl_witness.db8 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @impl.f92(%T) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Op.2(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @impl.f92(type) { +// CHECK:STDOUT: %T => type +// CHECK:STDOUT: %T.patt => constants.%T.patt +// CHECK:STDOUT: %impl_witness => constants.%impl_witness.3ea +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Op.type => constants.%Op.type.eb8 +// CHECK:STDOUT: %Op => constants.%Op.444 +// CHECK:STDOUT: %require_complete => constants.%complete_type +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Op.2(type) { +// CHECK:STDOUT: %T => type +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_never_assigned_associated_const.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type [concrete] +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete] +// CHECK:STDOUT: %assoc1: %I.assoc_type = assoc_entity element1, @I.%U [concrete] +// CHECK:STDOUT: %C: type = class_type @C [concrete] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] +// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self] +// CHECK:STDOUT: %.Self.as_wit.iface0: = facet_access_witness %.Self, element0 [symbolic_self] +// CHECK:STDOUT: %I.facet: %I.type = facet_value %.Self.as_type, (%.Self.as_wit.iface0) [symbolic_self] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit.iface0, element0 [symbolic_self] +// CHECK:STDOUT: %I_where.type: type = facet_type <@I where %impl.elem0 = %empty_tuple.type> [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness (%empty_tuple.type, ) [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %C.ref.loc19: type = name_ref C, file.%C.decl [concrete = constants.%C] +// CHECK:STDOUT: %I.ref.loc19: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %.Self.1: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc19: %I.type = name_ref .Self, %.Self.1 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %T.ref.loc19: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_type.loc19: type = facet_access_type %.Self.ref.loc19 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc19_19: type = converted %.Self.ref.loc19, %.Self.as_type.loc19 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.Self.as_wit.iface0.loc19: = facet_access_witness %.Self.ref.loc19, element0 [symbolic_self = constants.%.Self.as_wit.iface0] +// CHECK:STDOUT: %impl.elem0.loc19: type = impl_witness_access %.Self.as_wit.iface0.loc19, element0 [symbolic_self = constants.%impl.elem0] +// CHECK:STDOUT: %.loc19_25.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc19_25.2: type = converted %.loc19_25.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc19_13: type = where_expr %.Self.1 [concrete = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc19, %.loc19_25.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%empty_tuple.type, ) [concrete = constants.%impl_witness] +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %C.ref.loc23: type = name_ref C, file.%C.decl [concrete = constants.%C] +// CHECK:STDOUT: %I.ref.loc23: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %.Self.2: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc23: %I.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %T.ref.loc23: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_type.loc23: type = facet_access_type %.Self.ref.loc23 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc23_19: type = converted %.Self.ref.loc23, %.Self.as_type.loc23 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.Self.as_wit.iface0.loc23: = facet_access_witness %.Self.ref.loc23, element0 [symbolic_self = constants.%.Self.as_wit.iface0] +// CHECK:STDOUT: %impl.elem0.loc23: type = impl_witness_access %.Self.as_wit.iface0.loc23, element0 [symbolic_self = constants.%impl.elem0] +// CHECK:STDOUT: %.loc23_25.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc23_25.2: type = converted %.loc23_25.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc23_13: type = where_expr %.Self.2 [concrete = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc23, %.loc23_25.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] { +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete = constants.%assoc0] +// CHECK:STDOUT: } +// CHECK:STDOUT: %U: type = assoc_const_decl @U [concrete] { +// CHECK:STDOUT: %assoc1: %I.assoc_type = assoc_entity element1, @I.%U [concrete = constants.%assoc1] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .T = @T.%assoc0 +// CHECK:STDOUT: .U = @U.%assoc1 +// CHECK:STDOUT: witness = (%T, %U) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic assoc_const @T(@I.%Self: %I.type) { +// CHECK:STDOUT: assoc_const T:! type; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic assoc_const @U(@I.%Self: %I.type) { +// CHECK:STDOUT: assoc_const U:! type; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %C.ref.loc19 as %.loc19_13 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @U(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @T(constants.%I.facet) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- example_from_proposal_5168.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %X.type: type = facet_type <@X> [concrete] +// CHECK:STDOUT: %U: %X.type = bind_symbolic_name U, 0 [symbolic] +// CHECK:STDOUT: %U.patt: %X.type = symbolic_binding_pattern U, 0 [symbolic] +// CHECK:STDOUT: %F.type: type = fn_type @F [concrete] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %F: %F.type = struct_value () [concrete] +// CHECK:STDOUT: %U.as_type: type = facet_access_type %U [symbolic] +// CHECK:STDOUT: %G.type: type = fn_type @G [concrete] +// CHECK:STDOUT: %G: %G.type = struct_value () [concrete] +// CHECK:STDOUT: %C: type = class_type @C [concrete] +// CHECK:STDOUT: %impl_witness.1bcebf.1: = impl_witness () [concrete] +// CHECK:STDOUT: %Y.type: type = facet_type <@Y> [concrete] +// CHECK:STDOUT: %Self.e5e: %X.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] +// CHECK:STDOUT: %H.type: type = fn_type @H [concrete] +// CHECK:STDOUT: %H: %H.type = struct_value () [concrete] +// CHECK:STDOUT: %X.facet: %X.type = facet_value %C, (%impl_witness.1bcebf.1) [concrete] +// CHECK:STDOUT: %F.specific_fn: = specific_function %F, @F(%X.facet) [concrete] +// CHECK:STDOUT: %G.specific_fn: = specific_function %G, @G(%X.facet) [concrete] +// CHECK:STDOUT: %Self.b29: %Y.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %require_complete: = require_complete_type %U.as_type [symbolic] +// CHECK:STDOUT: %impl_witness.1bcebf.2: = impl_witness () [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .X = %X.decl.loc3 +// CHECK:STDOUT: .F = %F.decl.loc6 +// CHECK:STDOUT: .G = %G.decl.loc7 +// CHECK:STDOUT: .C = %C.decl.loc9 +// CHECK:STDOUT: .Y = %Y.decl.loc14 +// CHECK:STDOUT: .H = %H.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %X.decl.loc3: type = interface_decl @X [concrete = constants.%X.type] {} {} +// CHECK:STDOUT: %F.decl.loc6: %F.type = fn_decl @F [concrete = constants.%F] { +// CHECK:STDOUT: %U.patt.loc34: %X.type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc6 (constants.%U.patt)] +// CHECK:STDOUT: } { +// CHECK:STDOUT: %X.ref.loc6: type = name_ref X, file.%X.decl.loc3 [concrete = constants.%X.type] +// CHECK:STDOUT: %U.loc6_6.1: %X.type = bind_symbolic_name U, 0 [symbolic = %U.loc6_6.2 (constants.%U)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %G.decl.loc7: %G.type = fn_decl @G [concrete = constants.%G] { +// CHECK:STDOUT: %U.patt.loc35: %X.type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc7 (constants.%U.patt)] +// CHECK:STDOUT: %u.patt: @G.%U.as_type.loc7_16.2 (%U.as_type) = binding_pattern u +// CHECK:STDOUT: %u.param_patt: @G.%U.as_type.loc7_16.2 (%U.as_type) = value_param_pattern %u.patt, call_param0 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %X.ref.loc7: type = name_ref X, file.%X.decl.loc3 [concrete = constants.%X.type] +// CHECK:STDOUT: %U.loc7_6.1: %X.type = bind_symbolic_name U, 0 [symbolic = %U.loc7_6.2 (constants.%U)] +// CHECK:STDOUT: %u.param.loc7: @G.%U.as_type.loc7_16.2 (%U.as_type) = value_param call_param0 +// CHECK:STDOUT: %.loc7_16.1: type = splice_block %.loc7_16.2 [symbolic = %U.as_type.loc7_16.2 (constants.%U.as_type)] { +// CHECK:STDOUT: %U.ref.loc7: %X.type = name_ref U, %U.loc7_6.1 [symbolic = %U.loc7_6.2 (constants.%U)] +// CHECK:STDOUT: %U.as_type.loc7_16.1: type = facet_access_type %U.ref.loc7 [symbolic = %U.as_type.loc7_16.2 (constants.%U.as_type)] +// CHECK:STDOUT: %.loc7_16.2: type = converted %U.ref.loc7, %U.as_type.loc7_16.1 [symbolic = %U.as_type.loc7_16.2 (constants.%U.as_type)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %u.loc7: @G.%U.as_type.loc7_16.2 (%U.as_type) = bind_name u, %u.param.loc7 +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl.loc9: type = class_decl @C [concrete = constants.%C] {} {} +// CHECK:STDOUT: impl_decl @impl.10e [concrete] {} { +// CHECK:STDOUT: %C.ref.loc12: type = name_ref C, file.%C.decl.loc9 [concrete = constants.%C] +// CHECK:STDOUT: %X.ref.loc12: type = name_ref X, file.%X.decl.loc3 [concrete = constants.%X.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness.loc12: = impl_witness () [concrete = constants.%impl_witness.1bcebf.1] +// CHECK:STDOUT: %Y.decl.loc14: type = interface_decl @Y [concrete = constants.%Y.type] {} {} +// CHECK:STDOUT: %X.decl.loc16: type = interface_decl @X [concrete = constants.%X.type] {} {} +// CHECK:STDOUT: %C.decl.loc23: type = class_decl @C [concrete = constants.%C] {} {} +// CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [concrete = constants.%H] { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %c.param_patt: %C = value_param_pattern %c.patt, call_param0 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %c.param: %C = value_param call_param0 +// CHECK:STDOUT: %C.ref.loc25: type = name_ref C, file.%C.decl.loc9 [concrete = constants.%C] +// CHECK:STDOUT: %c: %C = bind_name c, %c.param +// CHECK:STDOUT: } +// CHECK:STDOUT: %Y.decl.loc33: type = interface_decl @Y [concrete = constants.%Y.type] {} {} +// CHECK:STDOUT: %F.decl.loc34: %F.type = fn_decl @F [concrete = constants.%F] { +// CHECK:STDOUT: %U.patt.loc34: %X.type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc6 (constants.%U.patt)] +// CHECK:STDOUT: } { +// CHECK:STDOUT: %X.ref.loc34: type = name_ref X, file.%X.decl.loc3 [concrete = constants.%X.type] +// CHECK:STDOUT: %U.loc34: %X.type = bind_symbolic_name U, 0 [symbolic = %U.loc6_6.2 (constants.%U)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %G.decl.loc35: %G.type = fn_decl @G [concrete = constants.%G] { +// CHECK:STDOUT: %U.patt.loc35: %X.type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc7 (constants.%U.patt)] +// CHECK:STDOUT: %u.patt: @G.%U.as_type.loc7_16.2 (%U.as_type) = binding_pattern u +// CHECK:STDOUT: %u.param_patt: @G.%U.as_type.loc7_16.2 (%U.as_type) = value_param_pattern %u.patt, call_param0 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %X.ref.loc35: type = name_ref X, file.%X.decl.loc3 [concrete = constants.%X.type] +// CHECK:STDOUT: %U.loc35: %X.type = bind_symbolic_name U, 0 [symbolic = %U.loc7_6.2 (constants.%U)] +// CHECK:STDOUT: %u.param.loc35: @G.%U.as_type.loc7_16.2 (%U.as_type) = value_param call_param0 +// CHECK:STDOUT: %.loc35_16.1: type = splice_block %.loc35_16.2 [symbolic = %U.as_type.loc7_16.2 (constants.%U.as_type)] { +// CHECK:STDOUT: %U.ref.loc35: %X.type = name_ref U, %U.loc35 [symbolic = %U.loc7_6.2 (constants.%U)] +// CHECK:STDOUT: %U.as_type.loc35: type = facet_access_type %U.ref.loc35 [symbolic = %U.as_type.loc7_16.2 (constants.%U.as_type)] +// CHECK:STDOUT: %.loc35_16.2: type = converted %U.ref.loc35, %U.as_type.loc35 [symbolic = %U.as_type.loc7_16.2 (constants.%U.as_type)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %u.loc35: @G.%U.as_type.loc7_16.2 (%U.as_type) = bind_name u, %u.param.loc35 +// CHECK:STDOUT: } +// CHECK:STDOUT: impl_decl @impl.a85 [concrete] {} { +// CHECK:STDOUT: %C.ref.loc36: type = name_ref C, file.%C.decl.loc9 [concrete = constants.%C] +// CHECK:STDOUT: %Y.ref.loc36: type = name_ref Y, file.%Y.decl.loc14 [concrete = constants.%Y.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness.loc36: = impl_witness () [concrete = constants.%impl_witness.1bcebf.2] +// CHECK:STDOUT: impl_decl @impl.10e [concrete] {} { +// CHECK:STDOUT: %C.ref.loc37: type = name_ref C, file.%C.decl.loc9 [concrete = constants.%C] +// CHECK:STDOUT: %X.ref.loc37: type = name_ref X, file.%X.decl.loc3 [concrete = constants.%X.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: impl_decl @impl.a85 [concrete] {} { +// CHECK:STDOUT: %C.ref.loc38: type = name_ref C, file.%C.decl.loc9 [concrete = constants.%C] +// CHECK:STDOUT: %Y.ref.loc38: type = name_ref Y, file.%Y.decl.loc14 [concrete = constants.%Y.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @X { +// CHECK:STDOUT: %Self: %X.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.e5e] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Y { +// CHECK:STDOUT: %Self: %Y.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.b29] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.10e: %C.ref.loc12 as %X.ref.loc12 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness.loc12 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.a85: %C.ref.loc36 as %Y.ref.loc36 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness.loc36 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F(%U.loc6_6.1: %X.type) { +// CHECK:STDOUT: %U.loc6_6.2: %X.type = bind_symbolic_name U, 0 [symbolic = %U.loc6_6.2 (constants.%U)] +// CHECK:STDOUT: %U.patt.loc6: %X.type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc6 (constants.%U.patt)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%U.patt.loc34: %X.type) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @G(%U.loc7_6.1: %X.type) { +// CHECK:STDOUT: %U.loc7_6.2: %X.type = bind_symbolic_name U, 0 [symbolic = %U.loc7_6.2 (constants.%U)] +// CHECK:STDOUT: %U.patt.loc7: %X.type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc7 (constants.%U.patt)] +// CHECK:STDOUT: %U.as_type.loc7_16.2: type = facet_access_type %U.loc7_6.2 [symbolic = %U.as_type.loc7_16.2 (constants.%U.as_type)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %require_complete: = require_complete_type @G.%U.as_type.loc7_16.2 (%U.as_type) [symbolic = %require_complete (constants.%require_complete)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%U.patt.loc35: %X.type](%u.param_patt: @G.%U.as_type.loc7_16.2 (%U.as_type)) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @H(%c.param_patt: %C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl.loc6 [concrete = constants.%F] +// CHECK:STDOUT: %C.ref.loc27: type = name_ref C, file.%C.decl.loc9 [concrete = constants.%C] +// CHECK:STDOUT: %X.facet.loc27: %X.type = facet_value constants.%C, (constants.%impl_witness.1bcebf.1) [concrete = constants.%X.facet] +// CHECK:STDOUT: %.loc27: %X.type = converted %C.ref.loc27, %X.facet.loc27 [concrete = constants.%X.facet] +// CHECK:STDOUT: %F.specific_fn: = specific_function %F.ref, @F(constants.%X.facet) [concrete = constants.%F.specific_fn] +// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.specific_fn() +// CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl.loc7 [concrete = constants.%G] +// CHECK:STDOUT: %c.ref: %C = name_ref c, %c +// CHECK:STDOUT: %X.facet.loc28_6.1: %X.type = facet_value constants.%C, (constants.%impl_witness.1bcebf.1) [concrete = constants.%X.facet] +// CHECK:STDOUT: %.loc28_6.1: %X.type = converted constants.%C, %X.facet.loc28_6.1 [concrete = constants.%X.facet] +// CHECK:STDOUT: %X.facet.loc28_6.2: %X.type = facet_value constants.%C, (constants.%impl_witness.1bcebf.1) [concrete = constants.%X.facet] +// CHECK:STDOUT: %.loc28_6.2: %X.type = converted constants.%C, %X.facet.loc28_6.2 [concrete = constants.%X.facet] +// CHECK:STDOUT: %G.specific_fn: = specific_function %G.ref, @G(constants.%X.facet) [concrete = constants.%G.specific_fn] +// CHECK:STDOUT: %G.call: init %empty_tuple.type = call %G.specific_fn(%c.ref) +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%U) { +// CHECK:STDOUT: %U.loc6_6.2 => constants.%U +// CHECK:STDOUT: %U.patt.loc6 => constants.%U.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G(constants.%U) { +// CHECK:STDOUT: %U.loc7_6.2 => constants.%U +// CHECK:STDOUT: %U.patt.loc7 => constants.%U.patt +// CHECK:STDOUT: %U.as_type.loc7_16.2 => constants.%U.as_type +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%X.facet) { +// CHECK:STDOUT: %U.loc6_6.2 => constants.%X.facet +// CHECK:STDOUT: %U.patt.loc6 => constants.%U.patt +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G(constants.%X.facet) { +// CHECK:STDOUT: %U.loc7_6.2 => constants.%X.facet +// CHECK:STDOUT: %U.patt.loc7 => constants.%U.patt +// CHECK:STDOUT: %U.as_type.loc7_16.2 => constants.%C +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %require_complete => constants.%complete_type +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_impl_in_interface_definition.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %F.type: type = fn_type @F [concrete] +// CHECK:STDOUT: %F: %F.type = struct_value () [concrete] +// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type [concrete] +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%F.decl [concrete] +// CHECK:STDOUT: %C.a2d: type = class_type @C [concrete] +// CHECK:STDOUT: %C.023: type = class_type @C, @C(%Self) [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness (), @impl(%Self) [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {} +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %F.decl [concrete = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .F = %assoc0 +// CHECK:STDOUT: .I = +// CHECK:STDOUT: witness = (%F.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic impl @impl(@I.%Self: %I.type) { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: %impl_witness: = impl_witness (), @impl(%Self) [symbolic = %impl_witness (constants.%impl_witness)] +// CHECK:STDOUT: +// CHECK:STDOUT: impl: %C.ref as %I.ref; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @C(@I.%Self: %I.type) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C.023 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F(@I.%Self: %I.type) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C.a2d] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %C.ref: type = name_ref C, @F.%C.decl [concrete = constants.%C.a2d] +// CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (), @impl(constants.%Self) [symbolic = @impl.%impl_witness (constants.%impl_witness)] +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @impl(constants.%Self) { +// CHECK:STDOUT: %Self => constants.%Self +// CHECK:STDOUT: %impl_witness => constants.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @impl(%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_impl_in_interface_definition_with_associated.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type [concrete] +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%U [concrete] +// CHECK:STDOUT: %F.type: type = fn_type @F [concrete] +// CHECK:STDOUT: %F: %F.type = struct_value () [concrete] +// CHECK:STDOUT: %assoc1: %I.assoc_type = assoc_entity element1, @I.%F.decl [concrete] +// CHECK:STDOUT: %C.a2d: type = class_type @C [concrete] +// CHECK:STDOUT: %C.023: type = class_type @C, @C(%Self) [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] +// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self] +// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self] +// CHECK:STDOUT: %.Self.as_wit.iface0: = facet_access_witness %.Self, element0 [symbolic_self] +// CHECK:STDOUT: %I.facet: %I.type = facet_value %.Self.as_type, (%.Self.as_wit.iface0) [symbolic_self] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit.iface0, element0 [symbolic_self] +// CHECK:STDOUT: %I_where.type: type = facet_type <@I where %impl.elem0 = %C.a2d> [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness (%C.a2d, invalid), @impl(%Self) [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .I = %I.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %U: type = assoc_const_decl @U [concrete] { +// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%U [concrete = constants.%assoc0] +// CHECK:STDOUT: } +// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {} +// CHECK:STDOUT: %assoc1: %I.assoc_type = assoc_entity element1, %F.decl [concrete = constants.%assoc1] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .U = @U.%assoc0 +// CHECK:STDOUT: .F = %assoc1 +// CHECK:STDOUT: .I = +// CHECK:STDOUT: witness = (%U, %F.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic assoc_const @U(@I.%Self: %I.type) { +// CHECK:STDOUT: assoc_const U:! type; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic impl @impl(@I.%Self: %I.type) { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%C.a2d, invalid), @impl(%Self) [symbolic = %impl_witness (constants.%impl_witness)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: impl: %C.ref.loc16_10 as %.loc16_17 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @C(@I.%Self: %I.type) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C.023 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F(@I.%Self: %I.type) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C.a2d] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %C.ref.loc16_10: type = name_ref C, @F.%C.decl [concrete = constants.%C.a2d] +// CHECK:STDOUT: %I.ref.loc16: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %.Self.1: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc16: %I.type = name_ref .Self, %.Self.1 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %U.ref.loc16: %I.assoc_type = name_ref U, @U.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_type.loc16: type = facet_access_type %.Self.ref.loc16 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc16_23: type = converted %.Self.ref.loc16, %.Self.as_type.loc16 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.Self.as_wit.iface0.loc16: = facet_access_witness %.Self.ref.loc16, element0 [symbolic_self = constants.%.Self.as_wit.iface0] +// CHECK:STDOUT: %impl.elem0.loc16: type = impl_witness_access %.Self.as_wit.iface0.loc16, element0 [symbolic_self = constants.%impl.elem0] +// CHECK:STDOUT: %C.ref.loc16_28: type = name_ref C, @F.%C.decl [concrete = constants.%C.a2d] +// CHECK:STDOUT: %.loc16_17: type = where_expr %.Self.1 [concrete = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc16, %C.ref.loc16_28 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%C.a2d, invalid), @impl(constants.%Self) [symbolic = @impl.%impl_witness (constants.%impl_witness)] +// CHECK:STDOUT: impl_decl @impl [concrete] {} { +// CHECK:STDOUT: %C.ref.loc18_10: type = name_ref C, @F.%C.decl [concrete = constants.%C.a2d] +// CHECK:STDOUT: %I.ref.loc18: type = name_ref I, file.%I.decl [concrete = constants.%I.type] +// CHECK:STDOUT: %.Self.2: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc18: %I.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %U.ref.loc18: %I.assoc_type = name_ref U, @U.%assoc0 [concrete = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_type.loc18: type = facet_access_type %.Self.ref.loc18 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc18_23: type = converted %.Self.ref.loc18, %.Self.as_type.loc18 [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.Self.as_wit.iface0.loc18: = facet_access_witness %.Self.ref.loc18, element0 [symbolic_self = constants.%.Self.as_wit.iface0] +// CHECK:STDOUT: %impl.elem0.loc18: type = impl_witness_access %.Self.as_wit.iface0.loc18, element0 [symbolic_self = constants.%impl.elem0] +// CHECK:STDOUT: %C.ref.loc18_28: type = name_ref C, @F.%C.decl [concrete = constants.%C.a2d] +// CHECK:STDOUT: %.loc18_17: type = where_expr %.Self.2 [concrete = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc18, %C.ref.loc18_28 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @U(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @U(constants.%I.facet) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @impl(constants.%Self) { +// CHECK:STDOUT: %Self => constants.%Self +// CHECK:STDOUT: %impl_witness => constants.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @impl(%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- include_files/facet_types.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic] +// CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic] +// CHECK:STDOUT: %As.type.b51: type = generic_interface_type @As [concrete] +// CHECK:STDOUT: %As.generic: %As.type.b51 = struct_value () [concrete] +// CHECK:STDOUT: %As.type.8ba: type = facet_type <@As, @As(%Dest)> [symbolic] +// CHECK:STDOUT: %Self.b4e: %As.type.8ba = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %Self.as_type.7f0: type = facet_access_type %Self.b4e [symbolic] +// CHECK:STDOUT: %Convert.type.ad1: type = fn_type @Convert.1, @As(%Dest) [symbolic] +// CHECK:STDOUT: %Convert.0ed: %Convert.type.ad1 = struct_value () [symbolic] +// CHECK:STDOUT: %As.assoc_type: type = assoc_entity_type %As.type.8ba [symbolic] +// CHECK:STDOUT: %assoc0.ac5: %As.assoc_type = assoc_entity element0, @As.%Convert.decl [symbolic] +// CHECK:STDOUT: %ImplicitAs.type.96f: type = generic_interface_type @ImplicitAs [concrete] +// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.96f = struct_value () [concrete] +// CHECK:STDOUT: %ImplicitAs.type.07f: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic] +// CHECK:STDOUT: %Self.0f3: %ImplicitAs.type.07f = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %Self.as_type.419: type = facet_access_type %Self.0f3 [symbolic] +// CHECK:STDOUT: %Convert.type.4cf: type = fn_type @Convert.2, @ImplicitAs(%Dest) [symbolic] +// CHECK:STDOUT: %Convert.147: %Convert.type.4cf = struct_value () [symbolic] +// CHECK:STDOUT: %ImplicitAs.assoc_type: type = assoc_entity_type %ImplicitAs.type.07f [symbolic] +// CHECK:STDOUT: %assoc0.a50: %ImplicitAs.assoc_type = assoc_entity element0, @ImplicitAs.%Convert.decl [symbolic] +// CHECK:STDOUT: %BitAnd.type: type = facet_type <@BitAnd> [concrete] +// CHECK:STDOUT: %Self.e44: %BitAnd.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %Self.as_type.560: type = facet_access_type %Self.e44 [symbolic] +// CHECK:STDOUT: %Op.type.613: type = fn_type @Op.1 [concrete] +// CHECK:STDOUT: %Op.d98: %Op.type.613 = struct_value () [concrete] +// CHECK:STDOUT: %BitAnd.assoc_type: type = assoc_entity_type %BitAnd.type [concrete] +// CHECK:STDOUT: %assoc0.121: %BitAnd.assoc_type = assoc_entity element0, @BitAnd.%Op.decl [concrete] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %impl_witness: = impl_witness (@impl.%Op.decl), @impl(%T) [symbolic] +// CHECK:STDOUT: %Op.type.28d: type = fn_type @Op.2, @impl(%T) [symbolic] +// CHECK:STDOUT: %Op.902: %Op.type.28d = struct_value () [symbolic] +// CHECK:STDOUT: %require_complete: = require_complete_type %T [symbolic] +// CHECK:STDOUT: %BitAnd.facet: %BitAnd.type = facet_value %T, (%impl_witness) [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [concrete] { +// CHECK:STDOUT: .As = %As.decl +// CHECK:STDOUT: .ImplicitAs = %ImplicitAs.decl +// CHECK:STDOUT: .BitAnd = %BitAnd.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %As.decl: %As.type.b51 = interface_decl @As [concrete = constants.%As.generic] { +// CHECK:STDOUT: %Dest.patt.loc9_14.1: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt.loc9_14.2 (constants.%Dest.patt)] +// CHECK:STDOUT: } { +// CHECK:STDOUT: %Dest.loc9_14.1: type = bind_symbolic_name Dest, 0 [symbolic = %Dest.loc9_14.2 (constants.%Dest)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %ImplicitAs.decl: %ImplicitAs.type.96f = interface_decl @ImplicitAs [concrete = constants.%ImplicitAs.generic] { +// CHECK:STDOUT: %Dest.patt.loc13_22.1: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt.loc13_22.2 (constants.%Dest.patt)] +// CHECK:STDOUT: } { +// CHECK:STDOUT: %Dest.loc13_22.1: type = bind_symbolic_name Dest, 0 [symbolic = %Dest.loc13_22.2 (constants.%Dest)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %BitAnd.decl: type = interface_decl @BitAnd [concrete = constants.%BitAnd.type] {} {} +// CHECK:STDOUT: impl_decl @impl [concrete] { +// CHECK:STDOUT: %T.patt.loc21_14.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc21_14.2 (constants.%T.patt)] +// CHECK:STDOUT: } { +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc21_14.1 [symbolic = %T.loc21_14.2 (constants.%T)] +// CHECK:STDOUT: %BitAnd.ref: type = name_ref BitAnd, file.%BitAnd.decl [concrete = constants.%BitAnd.type] +// CHECK:STDOUT: %T.loc21_14.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc21_14.2 (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (@impl.%Op.decl), @impl(constants.%T) [symbolic = @impl.%impl_witness (constants.%impl_witness)] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic interface @As(%Dest.loc9_14.1: type) { +// CHECK:STDOUT: %Dest.loc9_14.2: type = bind_symbolic_name Dest, 0 [symbolic = %Dest.loc9_14.2 (constants.%Dest)] +// CHECK:STDOUT: %Dest.patt.loc9_14.2: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt.loc9_14.2 (constants.%Dest.patt)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %As.type: type = facet_type <@As, @As(%Dest.loc9_14.2)> [symbolic = %As.type (constants.%As.type.8ba)] +// CHECK:STDOUT: %Self.2: @As.%As.type (%As.type.8ba) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.b4e)] +// CHECK:STDOUT: %Convert.type: type = fn_type @Convert.1, @As(%Dest.loc9_14.2) [symbolic = %Convert.type (constants.%Convert.type.ad1)] +// CHECK:STDOUT: %Convert: @As.%Convert.type (%Convert.type.ad1) = struct_value () [symbolic = %Convert (constants.%Convert.0ed)] +// CHECK:STDOUT: %As.assoc_type: type = assoc_entity_type @As.%As.type (%As.type.8ba) [symbolic = %As.assoc_type (constants.%As.assoc_type)] +// CHECK:STDOUT: %assoc0.loc10_35.2: @As.%As.assoc_type (%As.assoc_type) = assoc_entity element0, %Convert.decl [symbolic = %assoc0.loc10_35.2 (constants.%assoc0.ac5)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @As.%As.type (%As.type.8ba) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.b4e)] +// CHECK:STDOUT: %Convert.decl: @As.%Convert.type (%Convert.type.ad1) = fn_decl @Convert.1 [symbolic = @As.%Convert (constants.%Convert.0ed)] { +// CHECK:STDOUT: %self.patt: @Convert.1.%Self.as_type.loc10_20.1 (%Self.as_type.7f0) = binding_pattern self +// CHECK:STDOUT: %self.param_patt: @Convert.1.%Self.as_type.loc10_20.1 (%Self.as_type.7f0) = value_param_pattern %self.patt, call_param0 +// CHECK:STDOUT: %return.patt: @Convert.1.%Dest (%Dest) = return_slot_pattern +// CHECK:STDOUT: %return.param_patt: @Convert.1.%Dest (%Dest) = out_param_pattern %return.patt, call_param1 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %Dest.ref: type = name_ref Dest, @As.%Dest.loc9_14.1 [symbolic = %Dest (constants.%Dest)] +// CHECK:STDOUT: %self.param: @Convert.1.%Self.as_type.loc10_20.1 (%Self.as_type.7f0) = value_param call_param0 +// CHECK:STDOUT: %.loc10_20.1: type = splice_block %.loc10_20.3 [symbolic = %Self.as_type.loc10_20.1 (constants.%Self.as_type.7f0)] { +// CHECK:STDOUT: %.loc10_20.2: @Convert.1.%As.type (%As.type.8ba) = specific_constant @As.%Self.1, @As(constants.%Dest) [symbolic = %Self (constants.%Self.b4e)] +// CHECK:STDOUT: %Self.ref: @Convert.1.%As.type (%As.type.8ba) = name_ref Self, %.loc10_20.2 [symbolic = %Self (constants.%Self.b4e)] +// CHECK:STDOUT: %Self.as_type.loc10_20.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc10_20.1 (constants.%Self.as_type.7f0)] +// CHECK:STDOUT: %.loc10_20.3: type = converted %Self.ref, %Self.as_type.loc10_20.2 [symbolic = %Self.as_type.loc10_20.1 (constants.%Self.as_type.7f0)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %self: @Convert.1.%Self.as_type.loc10_20.1 (%Self.as_type.7f0) = bind_name self, %self.param +// CHECK:STDOUT: %return.param: ref @Convert.1.%Dest (%Dest) = out_param call_param1 +// CHECK:STDOUT: %return: ref @Convert.1.%Dest (%Dest) = return_slot %return.param +// CHECK:STDOUT: } +// CHECK:STDOUT: %assoc0.loc10_35.1: @As.%As.assoc_type (%As.assoc_type) = assoc_entity element0, %Convert.decl [symbolic = %assoc0.loc10_35.2 (constants.%assoc0.ac5)] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: .Dest = +// CHECK:STDOUT: .Convert = %assoc0.loc10_35.1 +// CHECK:STDOUT: witness = (%Convert.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic interface @ImplicitAs(%Dest.loc13_22.1: type) { +// CHECK:STDOUT: %Dest.loc13_22.2: type = bind_symbolic_name Dest, 0 [symbolic = %Dest.loc13_22.2 (constants.%Dest)] +// CHECK:STDOUT: %Dest.patt.loc13_22.2: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt.loc13_22.2 (constants.%Dest.patt)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest.loc13_22.2)> [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.07f)] +// CHECK:STDOUT: %Self.2: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.07f) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.0f3)] +// CHECK:STDOUT: %Convert.type: type = fn_type @Convert.2, @ImplicitAs(%Dest.loc13_22.2) [symbolic = %Convert.type (constants.%Convert.type.4cf)] +// CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.4cf) = struct_value () [symbolic = %Convert (constants.%Convert.147)] +// CHECK:STDOUT: %ImplicitAs.assoc_type: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.07f) [symbolic = %ImplicitAs.assoc_type (constants.%ImplicitAs.assoc_type)] +// CHECK:STDOUT: %assoc0.loc14_35.2: @ImplicitAs.%ImplicitAs.assoc_type (%ImplicitAs.assoc_type) = assoc_entity element0, %Convert.decl [symbolic = %assoc0.loc14_35.2 (constants.%assoc0.a50)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.07f) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.0f3)] +// CHECK:STDOUT: %Convert.decl: @ImplicitAs.%Convert.type (%Convert.type.4cf) = fn_decl @Convert.2 [symbolic = @ImplicitAs.%Convert (constants.%Convert.147)] { +// CHECK:STDOUT: %self.patt: @Convert.2.%Self.as_type.loc14_20.1 (%Self.as_type.419) = binding_pattern self +// CHECK:STDOUT: %self.param_patt: @Convert.2.%Self.as_type.loc14_20.1 (%Self.as_type.419) = value_param_pattern %self.patt, call_param0 +// CHECK:STDOUT: %return.patt: @Convert.2.%Dest (%Dest) = return_slot_pattern +// CHECK:STDOUT: %return.param_patt: @Convert.2.%Dest (%Dest) = out_param_pattern %return.patt, call_param1 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %Dest.ref: type = name_ref Dest, @ImplicitAs.%Dest.loc13_22.1 [symbolic = %Dest (constants.%Dest)] +// CHECK:STDOUT: %self.param: @Convert.2.%Self.as_type.loc14_20.1 (%Self.as_type.419) = value_param call_param0 +// CHECK:STDOUT: %.loc14_20.1: type = splice_block %.loc14_20.3 [symbolic = %Self.as_type.loc14_20.1 (constants.%Self.as_type.419)] { +// CHECK:STDOUT: %.loc14_20.2: @Convert.2.%ImplicitAs.type (%ImplicitAs.type.07f) = specific_constant @ImplicitAs.%Self.1, @ImplicitAs(constants.%Dest) [symbolic = %Self (constants.%Self.0f3)] +// CHECK:STDOUT: %Self.ref: @Convert.2.%ImplicitAs.type (%ImplicitAs.type.07f) = name_ref Self, %.loc14_20.2 [symbolic = %Self (constants.%Self.0f3)] +// CHECK:STDOUT: %Self.as_type.loc14_20.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc14_20.1 (constants.%Self.as_type.419)] +// CHECK:STDOUT: %.loc14_20.3: type = converted %Self.ref, %Self.as_type.loc14_20.2 [symbolic = %Self.as_type.loc14_20.1 (constants.%Self.as_type.419)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %self: @Convert.2.%Self.as_type.loc14_20.1 (%Self.as_type.419) = bind_name self, %self.param +// CHECK:STDOUT: %return.param: ref @Convert.2.%Dest (%Dest) = out_param call_param1 +// CHECK:STDOUT: %return: ref @Convert.2.%Dest (%Dest) = return_slot %return.param +// CHECK:STDOUT: } +// CHECK:STDOUT: %assoc0.loc14_35.1: @ImplicitAs.%ImplicitAs.assoc_type (%ImplicitAs.assoc_type) = assoc_entity element0, %Convert.decl [symbolic = %assoc0.loc14_35.2 (constants.%assoc0.a50)] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: .Dest = +// CHECK:STDOUT: .Convert = %assoc0.loc14_35.1 +// CHECK:STDOUT: witness = (%Convert.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @BitAnd { +// CHECK:STDOUT: %Self: %BitAnd.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.e44] +// CHECK:STDOUT: %Op.decl: %Op.type.613 = fn_decl @Op.1 [concrete = constants.%Op.d98] { +// CHECK:STDOUT: %self.patt: @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560) = binding_pattern self +// CHECK:STDOUT: %self.param_patt: @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560) = value_param_pattern %self.patt, call_param0 +// CHECK:STDOUT: %other.patt: @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560) = binding_pattern other +// CHECK:STDOUT: %other.param_patt: @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560) = value_param_pattern %other.patt, call_param1 +// CHECK:STDOUT: %return.patt: @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560) = return_slot_pattern +// CHECK:STDOUT: %return.param_patt: @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560) = out_param_pattern %return.patt, call_param2 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %Self.ref.loc18_37: %BitAnd.type = name_ref Self, @BitAnd.%Self [symbolic = %Self (constants.%Self.e44)] +// CHECK:STDOUT: %Self.as_type.loc18_37: type = facet_access_type %Self.ref.loc18_37 [symbolic = %Self.as_type.loc18_15.1 (constants.%Self.as_type.560)] +// CHECK:STDOUT: %.loc18_37: type = converted %Self.ref.loc18_37, %Self.as_type.loc18_37 [symbolic = %Self.as_type.loc18_15.1 (constants.%Self.as_type.560)] +// CHECK:STDOUT: %self.param: @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560) = value_param call_param0 +// CHECK:STDOUT: %.loc18_15.1: type = splice_block %.loc18_15.2 [symbolic = %Self.as_type.loc18_15.1 (constants.%Self.as_type.560)] { +// CHECK:STDOUT: %Self.ref.loc18_15: %BitAnd.type = name_ref Self, @BitAnd.%Self [symbolic = %Self (constants.%Self.e44)] +// CHECK:STDOUT: %Self.as_type.loc18_15.2: type = facet_access_type %Self.ref.loc18_15 [symbolic = %Self.as_type.loc18_15.1 (constants.%Self.as_type.560)] +// CHECK:STDOUT: %.loc18_15.2: type = converted %Self.ref.loc18_15, %Self.as_type.loc18_15.2 [symbolic = %Self.as_type.loc18_15.1 (constants.%Self.as_type.560)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %self: @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560) = bind_name self, %self.param +// CHECK:STDOUT: %other.param: @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560) = value_param call_param1 +// CHECK:STDOUT: %.loc18_28.1: type = splice_block %.loc18_28.2 [symbolic = %Self.as_type.loc18_15.1 (constants.%Self.as_type.560)] { +// CHECK:STDOUT: %Self.ref.loc18_28: %BitAnd.type = name_ref Self, @BitAnd.%Self [symbolic = %Self (constants.%Self.e44)] +// CHECK:STDOUT: %Self.as_type.loc18_28: type = facet_access_type %Self.ref.loc18_28 [symbolic = %Self.as_type.loc18_15.1 (constants.%Self.as_type.560)] +// CHECK:STDOUT: %.loc18_28.2: type = converted %Self.ref.loc18_28, %Self.as_type.loc18_28 [symbolic = %Self.as_type.loc18_15.1 (constants.%Self.as_type.560)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %other: @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560) = bind_name other, %other.param +// CHECK:STDOUT: %return.param: ref @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560) = out_param call_param2 +// CHECK:STDOUT: %return: ref @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560) = return_slot %return.param +// CHECK:STDOUT: } +// CHECK:STDOUT: %assoc0: %BitAnd.assoc_type = assoc_entity element0, %Op.decl [concrete = constants.%assoc0.121] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .Op = %assoc0 +// CHECK:STDOUT: witness = (%Op.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic impl @impl(%T.loc21_14.1: type) { +// CHECK:STDOUT: %T.loc21_14.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc21_14.2 (constants.%T)] +// CHECK:STDOUT: %T.patt.loc21_14.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc21_14.2 (constants.%T.patt)] +// CHECK:STDOUT: %impl_witness: = impl_witness (%Op.decl), @impl(%T.loc21_14.2) [symbolic = %impl_witness (constants.%impl_witness)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Op.type: type = fn_type @Op.2, @impl(%T.loc21_14.2) [symbolic = %Op.type (constants.%Op.type.28d)] +// CHECK:STDOUT: %Op: @impl.%Op.type (%Op.type.28d) = struct_value () [symbolic = %Op (constants.%Op.902)] +// CHECK:STDOUT: %require_complete: = require_complete_type @impl.%T.loc21_14.2 (%T) [symbolic = %require_complete (constants.%require_complete)] +// CHECK:STDOUT: +// CHECK:STDOUT: impl: %T.ref as %BitAnd.ref { +// CHECK:STDOUT: %Op.decl: @impl.%Op.type (%Op.type.28d) = fn_decl @Op.2 [symbolic = @impl.%Op (constants.%Op.902)] { +// CHECK:STDOUT: %self.patt: @Op.2.%T (%T) = binding_pattern self +// CHECK:STDOUT: %self.param_patt: @Op.2.%T (%T) = value_param_pattern %self.patt, call_param0 +// CHECK:STDOUT: %other.patt: @Op.2.%T (%T) = binding_pattern other +// CHECK:STDOUT: %other.param_patt: @Op.2.%T (%T) = value_param_pattern %other.patt, call_param1 +// CHECK:STDOUT: %return.patt: @Op.2.%T (%T) = return_slot_pattern +// CHECK:STDOUT: %return.param_patt: @Op.2.%T (%T) = out_param_pattern %return.patt, call_param2 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %Self.ref.loc22_37: type = name_ref Self, @impl.%T.ref [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %self.param: @Op.2.%T (%T) = value_param call_param0 +// CHECK:STDOUT: %Self.ref.loc22_15: type = name_ref Self, @impl.%T.ref [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %self: @Op.2.%T (%T) = bind_name self, %self.param +// CHECK:STDOUT: %other.param: @Op.2.%T (%T) = value_param call_param1 +// CHECK:STDOUT: %Self.ref.loc22_28: type = name_ref Self, @impl.%T.ref [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %other: @Op.2.%T (%T) = bind_name other, %other.param +// CHECK:STDOUT: %return.param: ref @Op.2.%T (%T) = out_param call_param2 +// CHECK:STDOUT: %return: ref @Op.2.%T (%T) = return_slot %return.param +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Op = %Op.decl +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Convert.1(@As.%Dest.loc9_14.1: type, @As.%Self.1: @As.%As.type (%As.type.8ba)) { +// CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)] +// CHECK:STDOUT: %As.type: type = facet_type <@As, @As(%Dest)> [symbolic = %As.type (constants.%As.type.8ba)] +// CHECK:STDOUT: %Self: @Convert.1.%As.type (%As.type.8ba) = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.b4e)] +// CHECK:STDOUT: %Self.as_type.loc10_20.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc10_20.1 (constants.%Self.as_type.7f0)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self.param_patt: @Convert.1.%Self.as_type.loc10_20.1 (%Self.as_type.7f0)]() -> @Convert.1.%Dest (%Dest); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Convert.2(@ImplicitAs.%Dest.loc13_22.1: type, @ImplicitAs.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.07f)) { +// CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)] +// CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.07f)] +// CHECK:STDOUT: %Self: @Convert.2.%ImplicitAs.type (%ImplicitAs.type.07f) = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.0f3)] +// CHECK:STDOUT: %Self.as_type.loc14_20.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc14_20.1 (constants.%Self.as_type.419)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self.param_patt: @Convert.2.%Self.as_type.loc14_20.1 (%Self.as_type.419)]() -> @Convert.2.%Dest (%Dest); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Op.1(@BitAnd.%Self: %BitAnd.type) { +// CHECK:STDOUT: %Self: %BitAnd.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.e44)] +// CHECK:STDOUT: %Self.as_type.loc18_15.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc18_15.1 (constants.%Self.as_type.560)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self.param_patt: @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560)](%other.param_patt: @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560)) -> @Op.1.%Self.as_type.loc18_15.1 (%Self.as_type.560); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Op.2(@impl.%T.loc21_14.1: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self.param_patt: @Op.2.%T (%T)](%other.param_patt: @Op.2.%T (%T)) -> @Op.2.%T (%T) = "type.and"; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @As(constants.%Dest) { +// CHECK:STDOUT: %Dest.loc9_14.2 => constants.%Dest +// CHECK:STDOUT: %Dest.patt.loc9_14.2 => constants.%Dest.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Convert.1(constants.%Dest, constants.%Self.b4e) { +// CHECK:STDOUT: %Dest => constants.%Dest +// CHECK:STDOUT: %As.type => constants.%As.type.8ba +// CHECK:STDOUT: %Self => constants.%Self.b4e +// CHECK:STDOUT: %Self.as_type.loc10_20.1 => constants.%Self.as_type.7f0 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @As(@Convert.1.%Dest) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @As(%Dest.loc9_14.2) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) { +// CHECK:STDOUT: %Dest.loc13_22.2 => constants.%Dest +// CHECK:STDOUT: %Dest.patt.loc13_22.2 => constants.%Dest.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Convert.2(constants.%Dest, constants.%Self.0f3) { +// CHECK:STDOUT: %Dest => constants.%Dest +// CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.07f +// CHECK:STDOUT: %Self => constants.%Self.0f3 +// CHECK:STDOUT: %Self.as_type.loc14_20.1 => constants.%Self.as_type.419 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ImplicitAs(@Convert.2.%Dest) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ImplicitAs(%Dest.loc13_22.2) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Op.1(constants.%Self.e44) { +// CHECK:STDOUT: %Self => constants.%Self.e44 +// CHECK:STDOUT: %Self.as_type.loc18_15.1 => constants.%Self.as_type.560 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @impl(constants.%T) { +// CHECK:STDOUT: %T.loc21_14.2 => constants.%T +// CHECK:STDOUT: %T.patt.loc21_14.2 => constants.%T.patt +// CHECK:STDOUT: %impl_witness => constants.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @impl(%T.loc21_14.2) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Op.2(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Op.1(constants.%BitAnd.facet) { +// CHECK:STDOUT: %Self => constants.%BitAnd.facet +// CHECK:STDOUT: %Self.as_type.loc18_15.1 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/no_prelude/fail_extend_impl_scope.carbon b/toolchain/check/testdata/impl/no_prelude/fail_extend_impl_scope.carbon index 731e422ee6eb..0b0d6e0b2f8f 100644 --- a/toolchain/check/testdata/impl/no_prelude/fail_extend_impl_scope.carbon +++ b/toolchain/check/testdata/impl/no_prelude/fail_extend_impl_scope.carbon @@ -38,17 +38,10 @@ library "[[@TEST_NAME]]"; interface Z { fn Zero(); - // CHECK:STDERR: fail_extend_impl_self_interface.carbon:[[@LINE+11]]:15: error: `impl as` can only be used in a class [ImplAsOutsideClass] + // CHECK:STDERR: fail_extend_impl_self_interface.carbon:[[@LINE+4]]:15: error: `impl as` can only be used in a class [ImplAsOutsideClass] // CHECK:STDERR: extend impl as Z { // CHECK:STDERR: ^~ // CHECK:STDERR: - // CHECK:STDERR: fail_extend_impl_self_interface.carbon:[[@LINE+7]]:3: error: impl as incomplete facet type `Z` [ImplAsIncompleteFacetType] - // CHECK:STDERR: extend impl as Z { - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~ - // CHECK:STDERR: fail_extend_impl_self_interface.carbon:[[@LINE-10]]:1: note: interface is currently being defined [InterfaceIncompleteWithinDefinition] - // CHECK:STDERR: interface Z { - // CHECK:STDERR: ^~~~~~~~~~~~~ - // CHECK:STDERR: extend impl as Z { fn Zero() {} } @@ -257,12 +250,12 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc32_5.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc25_5.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %Point.ref: type = name_ref Point, file.%Point.decl [concrete = constants.%Point] -// CHECK:STDOUT: %.loc32_5.2: ref %Point = temporary_storage -// CHECK:STDOUT: %.loc32_5.3: init %Point = class_init (), %.loc32_5.2 [concrete = constants.%Point.val] -// CHECK:STDOUT: %.loc32_5.4: ref %Point = temporary %.loc32_5.2, %.loc32_5.3 -// CHECK:STDOUT: %.loc32_7: ref %Point = converted %.loc32_5.1, %.loc32_5.4 +// CHECK:STDOUT: %.loc25_5.2: ref %Point = temporary_storage +// CHECK:STDOUT: %.loc25_5.3: init %Point = class_init (), %.loc25_5.2 [concrete = constants.%Point.val] +// CHECK:STDOUT: %.loc25_5.4: ref %Point = temporary %.loc25_5.2, %.loc25_5.3 +// CHECK:STDOUT: %.loc25_7: ref %Point = converted %.loc25_5.1, %.loc25_5.4 // CHECK:STDOUT: %Zero.ref: %Z.assoc_type = name_ref Zero, @Z.%assoc0 [concrete = constants.%assoc0] // CHECK:STDOUT: %impl.elem0: %.728 = impl_witness_access constants.%impl_witness, element0 [concrete = constants.%Zero.dec] // CHECK:STDOUT: %Zero.call: init %empty_tuple.type = call %impl.elem0() diff --git a/toolchain/check/testdata/impl/no_prelude/fail_impl_as_scope.carbon b/toolchain/check/testdata/impl/no_prelude/fail_impl_as_scope.carbon index 891719f14a74..f855bbe8ebc5 100644 --- a/toolchain/check/testdata/impl/no_prelude/fail_impl_as_scope.carbon +++ b/toolchain/check/testdata/impl/no_prelude/fail_impl_as_scope.carbon @@ -46,17 +46,10 @@ interface Z { fn Zero(); fn Method[self: Self](); - // CHECK:STDERR: fail_impl_as_self_interface.carbon:[[@LINE+11]]:9: error: `impl as` can only be used in a class [ImplAsOutsideClass] + // CHECK:STDERR: fail_impl_as_self_interface.carbon:[[@LINE+4]]:9: error: `impl as` can only be used in a class [ImplAsOutsideClass] // CHECK:STDERR: impl as Z { // CHECK:STDERR: ^~ // CHECK:STDERR: - // CHECK:STDERR: fail_impl_as_self_interface.carbon:[[@LINE+7]]:4: error: impl as incomplete facet type `Z` [ImplAsIncompleteFacetType] - // CHECK:STDERR: impl as Z { - // CHECK:STDERR: ^~~~~~~~~~~ - // CHECK:STDERR: fail_impl_as_self_interface.carbon:[[@LINE-11]]:1: note: interface is currently being defined [InterfaceIncompleteWithinDefinition] - // CHECK:STDERR: interface Z { - // CHECK:STDERR: ^~~~~~~~~~~~~ - // CHECK:STDERR: impl as Z { fn Zero() {} fn Method[self: Self]() {} @@ -293,16 +286,16 @@ class X { // CHECK:STDOUT: impl: %Self.ref as %Z.ref { // CHECK:STDOUT: %Zero.decl: @impl.6b5.%Zero.type (%Zero.type.db4) = fn_decl @Zero.2 [symbolic = @impl.6b5.%Zero (constants.%Zero.8fb)] {} {} // CHECK:STDOUT: %Method.decl: @impl.6b5.%Method.type (%Method.type.163) = fn_decl @Method.2 [symbolic = @impl.6b5.%Method (constants.%Method.84d)] { -// CHECK:STDOUT: %self.patt: @Method.2.%Self.as_type.loc20_21.1 (%Self.as_type) = binding_pattern self -// CHECK:STDOUT: %self.param_patt: @Method.2.%Self.as_type.loc20_21.1 (%Self.as_type) = value_param_pattern %self.patt, call_param0 +// CHECK:STDOUT: %self.patt: @Method.2.%Self.as_type.loc13_21.1 (%Self.as_type) = binding_pattern self +// CHECK:STDOUT: %self.param_patt: @Method.2.%Self.as_type.loc13_21.1 (%Self.as_type) = value_param_pattern %self.patt, call_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %self.param: @Method.2.%Self.as_type.loc20_21.1 (%Self.as_type) = value_param call_param0 -// CHECK:STDOUT: %.loc20_21.1: type = splice_block %.loc20_21.2 [symbolic = %Self.as_type.loc20_21.1 (constants.%Self.as_type)] { +// CHECK:STDOUT: %self.param: @Method.2.%Self.as_type.loc13_21.1 (%Self.as_type) = value_param call_param0 +// CHECK:STDOUT: %.loc13_21.1: type = splice_block %.loc13_21.2 [symbolic = %Self.as_type.loc13_21.1 (constants.%Self.as_type)] { // CHECK:STDOUT: %Self.ref: %Z.type = name_ref Self, @Z.%Self [symbolic = %Self (constants.%Self)] -// CHECK:STDOUT: %Self.as_type.loc20_21.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc20_21.1 (constants.%Self.as_type)] -// CHECK:STDOUT: %.loc20_21.2: type = converted %Self.ref, %Self.as_type.loc20_21.2 [symbolic = %Self.as_type.loc20_21.1 (constants.%Self.as_type)] +// CHECK:STDOUT: %Self.as_type.loc13_21.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc13_21.1 (constants.%Self.as_type)] +// CHECK:STDOUT: %.loc13_21.2: type = converted %Self.ref, %Self.as_type.loc13_21.2 [symbolic = %Self.as_type.loc13_21.1 (constants.%Self.as_type)] // CHECK:STDOUT: } -// CHECK:STDOUT: %self: @Method.2.%Self.as_type.loc20_21.1 (%Self.as_type) = bind_name self, %self.param +// CHECK:STDOUT: %self: @Method.2.%Self.as_type.loc13_21.1 (%Self.as_type) = bind_name self, %self.param // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !members: @@ -365,12 +358,12 @@ class X { // CHECK:STDOUT: // CHECK:STDOUT: generic fn @Method.2(@Z.%Self: %Z.type) { // CHECK:STDOUT: %Self: %Z.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)] -// CHECK:STDOUT: %Self.as_type.loc20_21.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc20_21.1 (constants.%Self.as_type)] +// CHECK:STDOUT: %Self.as_type.loc13_21.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc13_21.1 (constants.%Self.as_type)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %require_complete: = require_complete_type @Method.2.%Self.as_type.loc20_21.1 (%Self.as_type) [symbolic = %require_complete (constants.%require_complete)] +// CHECK:STDOUT: %require_complete: = require_complete_type @Method.2.%Self.as_type.loc13_21.1 (%Self.as_type) [symbolic = %require_complete (constants.%require_complete)] // CHECK:STDOUT: -// CHECK:STDOUT: fn[%self.param_patt: @Method.2.%Self.as_type.loc20_21.1 (%Self.as_type)]() { +// CHECK:STDOUT: fn[%self.param_patt: @Method.2.%Self.as_type.loc13_21.1 (%Self.as_type)]() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -388,26 +381,26 @@ class X { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Point.ref.loc35: type = name_ref Point, file.%Point.decl [concrete = constants.%Point] -// CHECK:STDOUT: %Z.ref.loc35: type = name_ref Z, file.%Z.decl [concrete = constants.%Z.type] +// CHECK:STDOUT: %Point.ref.loc28: type = name_ref Point, file.%Point.decl [concrete = constants.%Point] +// CHECK:STDOUT: %Z.ref.loc28: type = name_ref Z, file.%Z.decl [concrete = constants.%Z.type] // CHECK:STDOUT: %Zero.ref: %Z.assoc_type = name_ref Zero, @Z.%assoc0 [concrete = constants.%assoc0] // CHECK:STDOUT: %Z.facet: %Z.type = facet_value constants.%Point, (constants.%impl_witness) [concrete = constants.%Z.facet] -// CHECK:STDOUT: %.loc35: %Z.type = converted %Point.ref.loc35, %Z.facet [concrete = constants.%Z.facet] -// CHECK:STDOUT: %as_wit.iface0: = facet_access_witness %.loc35, element0 [concrete = constants.%impl_witness] +// CHECK:STDOUT: %.loc28: %Z.type = converted %Point.ref.loc28, %Z.facet [concrete = constants.%Z.facet] +// CHECK:STDOUT: %as_wit.iface0: = facet_access_witness %.loc28, element0 [concrete = constants.%impl_witness] // CHECK:STDOUT: %impl.elem0: %.071 = impl_witness_access %as_wit.iface0, element0 [concrete = constants.%Zero.dec] // CHECK:STDOUT: %Zero.call: init %empty_tuple.type = call %impl.elem0() -// CHECK:STDOUT: %.loc36_5.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %Point.ref.loc36: type = name_ref Point, file.%Point.decl [concrete = constants.%Point] -// CHECK:STDOUT: %.loc36_5.2: ref %Point = temporary_storage -// CHECK:STDOUT: %.loc36_5.3: init %Point = class_init (), %.loc36_5.2 [concrete = constants.%Point.val] -// CHECK:STDOUT: %.loc36_5.4: ref %Point = temporary %.loc36_5.2, %.loc36_5.3 -// CHECK:STDOUT: %.loc36_7.1: ref %Point = converted %.loc36_5.1, %.loc36_5.4 -// CHECK:STDOUT: %Z.ref.loc36: type = name_ref Z, file.%Z.decl [concrete = constants.%Z.type] +// CHECK:STDOUT: %.loc29_5.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %Point.ref.loc29: type = name_ref Point, file.%Point.decl [concrete = constants.%Point] +// CHECK:STDOUT: %.loc29_5.2: ref %Point = temporary_storage +// CHECK:STDOUT: %.loc29_5.3: init %Point = class_init (), %.loc29_5.2 [concrete = constants.%Point.val] +// CHECK:STDOUT: %.loc29_5.4: ref %Point = temporary %.loc29_5.2, %.loc29_5.3 +// CHECK:STDOUT: %.loc29_7.1: ref %Point = converted %.loc29_5.1, %.loc29_5.4 +// CHECK:STDOUT: %Z.ref.loc29: type = name_ref Z, file.%Z.decl [concrete = constants.%Z.type] // CHECK:STDOUT: %Method.ref: %Z.assoc_type = name_ref Method, @Z.%assoc1 [concrete = constants.%assoc1] // CHECK:STDOUT: %impl.elem1: %.2c0 = impl_witness_access constants.%impl_witness, element1 [concrete = constants.%Method.2c2] -// CHECK:STDOUT: %bound_method: = bound_method %.loc36_7.1, %impl.elem1 -// CHECK:STDOUT: %.loc36_7.2: %Point = bind_value %.loc36_7.1 -// CHECK:STDOUT: %Method.call: init %empty_tuple.type = call %bound_method(%.loc36_7.2) +// CHECK:STDOUT: %bound_method: = bound_method %.loc29_7.1, %impl.elem1 +// CHECK:STDOUT: %.loc29_7.2: %Point = bind_value %.loc29_7.1 +// CHECK:STDOUT: %Method.call: init %empty_tuple.type = call %bound_method(%.loc29_7.2) // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -431,7 +424,7 @@ class X { // CHECK:STDOUT: // CHECK:STDOUT: specific @Method.2(constants.%Self) { // CHECK:STDOUT: %Self => constants.%Self -// CHECK:STDOUT: %Self.as_type.loc20_21.1 => constants.%Self.as_type +// CHECK:STDOUT: %Self.as_type.loc13_21.1 => constants.%Self.as_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @impl.6b5(%Self) {} diff --git a/toolchain/check/testdata/impl/no_prelude/fail_undefined_interface.carbon b/toolchain/check/testdata/impl/no_prelude/fail_undefined_interface.carbon index 6a854ba7f1ce..2084c8892f56 100644 --- a/toolchain/check/testdata/impl/no_prelude/fail_undefined_interface.carbon +++ b/toolchain/check/testdata/impl/no_prelude/fail_undefined_interface.carbon @@ -13,7 +13,7 @@ library "[[@TEST_NAME]]"; interface I; -// CHECK:STDERR: fail_empty_struct.carbon:[[@LINE+7]]:1: error: impl as incomplete facet type `I` [ImplAsIncompleteFacetType] +// CHECK:STDERR: fail_empty_struct.carbon:[[@LINE+7]]:1: error: definition of impl as incomplete facet type `I` [ImplAsIncompleteFacetTypeDefinition] // CHECK:STDERR: impl {} as I {} // CHECK:STDERR: ^~~~~~~~~~~~~~ // CHECK:STDERR: fail_empty_struct.carbon:[[@LINE-4]]:1: note: interface was forward declared here [InterfaceForwardDeclaredHere] @@ -28,7 +28,7 @@ library "[[@TEST_NAME]]"; interface J; class C {} -// CHECK:STDERR: fail_class.carbon:[[@LINE+7]]:1: error: impl as incomplete facet type `J` [ImplAsIncompleteFacetType] +// CHECK:STDERR: fail_class.carbon:[[@LINE+7]]:1: error: definition of impl as incomplete facet type `J` [ImplAsIncompleteFacetTypeDefinition] // CHECK:STDERR: impl C as J {} // CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: fail_class.carbon:[[@LINE-5]]:1: note: interface was forward declared here [InterfaceForwardDeclaredHere] diff --git a/toolchain/check/testdata/impl/no_prelude/impl_assoc_const.carbon b/toolchain/check/testdata/impl/no_prelude/impl_assoc_const.carbon index 6f51ac164e94..b872516c7222 100644 --- a/toolchain/check/testdata/impl/no_prelude/impl_assoc_const.carbon +++ b/toolchain/check/testdata/impl/no_prelude/impl_assoc_const.carbon @@ -339,7 +339,7 @@ impl CD as IF where .F = 0 { // CHECK:STDOUT: %I3.assoc_type: type = assoc_entity_type %I3.type [concrete] // CHECK:STDOUT: %assoc0: %I3.assoc_type = assoc_entity element0, @I3.%T3 [concrete] // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] -// CHECK:STDOUT: %impl_witness.85b: = impl_witness () [concrete] +// CHECK:STDOUT: %impl_witness.1bc: = impl_witness () [concrete] // CHECK:STDOUT: %.Self: %I3.type = bind_symbolic_name .Self [symbolic_self] // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self] // CHECK:STDOUT: %.Self.as_wit.iface0: = facet_access_witness %.Self, element0 [symbolic_self] @@ -360,7 +360,7 @@ impl CD as IF where .F = 0 { // CHECK:STDOUT: %.loc9_7.2: type = converted %.loc9_7.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: %I3.ref: type = name_ref I3, file.%I3.decl [concrete = constants.%I3.type] // CHECK:STDOUT: } -// CHECK:STDOUT: %impl_witness.loc9: = impl_witness () [concrete = constants.%impl_witness.85b] +// CHECK:STDOUT: %impl_witness.loc9: = impl_witness () [concrete = constants.%impl_witness.1bc] // CHECK:STDOUT: impl_decl @impl.2b6 [concrete] {} { // CHECK:STDOUT: %.loc10_7.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc10_7.2: type = converted %.loc10_7.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] diff --git a/toolchain/check/testdata/impl/no_prelude/import_generic.carbon b/toolchain/check/testdata/impl/no_prelude/import_generic.carbon index bea322db9152..cf6f1a4e0f12 100644 --- a/toolchain/check/testdata/impl/no_prelude/import_generic.carbon +++ b/toolchain/check/testdata/impl/no_prelude/import_generic.carbon @@ -109,8 +109,8 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %I.generic: %I.type.dac = struct_value () [concrete] // CHECK:STDOUT: %I.type.325: type = facet_type <@I, @I(%T)> [symbolic] // CHECK:STDOUT: %Self.209: %I.type.325 = bind_symbolic_name Self, 1 [symbolic] -// CHECK:STDOUT: %require_complete.cfe: = require_complete_type %I.type.325 [symbolic] // CHECK:STDOUT: %impl_witness.eff: = impl_witness (), @impl.084(%T) [symbolic] +// CHECK:STDOUT: %require_complete.cfe: = require_complete_type %I.type.325 [symbolic] // CHECK:STDOUT: %ptr: type = ptr_type %T [symbolic] // CHECK:STDOUT: %I.type.0e2: type = facet_type <@I, @I(%ptr)> [symbolic] // CHECK:STDOUT: %Self.fb4: %I.type.0e2 = bind_symbolic_name Self, 1 [symbolic] @@ -182,10 +182,10 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.loc8_14.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_14.2 (constants.%T)] // CHECK:STDOUT: %T.patt.loc8_14.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_14.2 (constants.%T.patt)] // CHECK:STDOUT: %I.type.loc8_32.2: type = facet_type <@I, @I(%T.loc8_14.2)> [symbolic = %I.type.loc8_32.2 (constants.%I.type.325)] -// CHECK:STDOUT: %require_complete: = require_complete_type @impl.084.%I.type.loc8_32.2 (%I.type.325) [symbolic = %require_complete (constants.%require_complete.cfe)] // CHECK:STDOUT: %impl_witness: = impl_witness (), @impl.084(%T.loc8_14.2) [symbolic = %impl_witness (constants.%impl_witness.eff)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: +// CHECK:STDOUT: %require_complete: = require_complete_type @impl.084.%I.type.loc8_32.2 (%I.type.325) [symbolic = %require_complete (constants.%require_complete.cfe)] // CHECK:STDOUT: // CHECK:STDOUT: impl: %C.ref.loc8 as %I.type.loc8_32.1 { // CHECK:STDOUT: !members: @@ -232,7 +232,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.loc8_14.2 => constants.%T // CHECK:STDOUT: %T.patt.loc8_14.2 => constants.%T.patt // CHECK:STDOUT: %I.type.loc8_32.2 => constants.%I.type.325 -// CHECK:STDOUT: %require_complete => constants.%require_complete.cfe // CHECK:STDOUT: %impl_witness => constants.%impl_witness.eff // CHECK:STDOUT: } // CHECK:STDOUT: @@ -274,8 +273,8 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %C: type = class_type @C [concrete] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] -// CHECK:STDOUT: %require_complete.cfe: = require_complete_type %I.type.325 [symbolic] // CHECK:STDOUT: %impl_witness.eff58b.1: = impl_witness (), @impl.08450a.1(%T) [symbolic] +// CHECK:STDOUT: %require_complete.cfe: = require_complete_type %I.type.325 [symbolic] // CHECK:STDOUT: %ptr: type = ptr_type %T [symbolic] // CHECK:STDOUT: %I.type.0e2: type = facet_type <@I, @I(%ptr)> [symbolic] // CHECK:STDOUT: %require_complete.0e6: = require_complete_type %I.type.0e2 [symbolic] @@ -374,10 +373,10 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)] // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)] // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%T)> [symbolic = %I.type (constants.%I.type.325)] -// CHECK:STDOUT: %require_complete: = require_complete_type @impl.08450a.1.%I.type (%I.type.325) [symbolic = %require_complete (constants.%require_complete.cfe)] // CHECK:STDOUT: %impl_witness: = impl_witness (), @impl.08450a.1(%T) [symbolic = %impl_witness (constants.%impl_witness.eff58b.1)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: +// CHECK:STDOUT: %require_complete: = require_complete_type @impl.08450a.1.%I.type (%I.type.325) [symbolic = %require_complete (constants.%require_complete.cfe)] // CHECK:STDOUT: // CHECK:STDOUT: impl: imports.%Main.import_ref.29aca8.1 as imports.%Main.import_ref.4be { // CHECK:STDOUT: !members: @@ -405,7 +404,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.loc8_14.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_14.2 (constants.%T)] // CHECK:STDOUT: %T.patt.loc8_14.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_14.2 (constants.%T.patt)] // CHECK:STDOUT: %I.type.loc8_32.2: type = facet_type <@I, @I(%T.loc8_14.2)> [symbolic = %I.type.loc8_32.2 (constants.%I.type.325)] -// CHECK:STDOUT: %require_complete: = require_complete_type @impl.08450a.2.%I.type.loc8_32.2 (%I.type.325) [symbolic = %require_complete (constants.%require_complete.cfe)] // CHECK:STDOUT: %impl_witness: = impl_witness (), @impl.08450a.2(%T.loc8_14.2) [symbolic = %impl_witness (constants.%impl_witness.eff58b.2)] // CHECK:STDOUT: // CHECK:STDOUT: impl: %C.ref as %I.type.loc8_32.1; @@ -431,7 +429,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.patt.loc20_14.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc20_14.2 (constants.%T.patt)] // CHECK:STDOUT: %ptr.loc20_32.2: type = ptr_type @impl.cd2fdc.2.%T.loc20_14.2 (%T) [symbolic = %ptr.loc20_32.2 (constants.%ptr)] // CHECK:STDOUT: %I.type.loc20_33.2: type = facet_type <@I, @I(%ptr.loc20_32.2)> [symbolic = %I.type.loc20_33.2 (constants.%I.type.0e2)] -// CHECK:STDOUT: %require_complete: = require_complete_type @impl.cd2fdc.2.%I.type.loc20_33.2 (%I.type.0e2) [symbolic = %require_complete (constants.%require_complete.0e6)] // CHECK:STDOUT: %impl_witness: = impl_witness (), @impl.cd2fdc.2(%T.loc20_14.2) [symbolic = %impl_witness (constants.%impl_witness.46542c.2)] // CHECK:STDOUT: // CHECK:STDOUT: impl: %C.ref as %I.type.loc20_33.1; @@ -475,7 +472,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: %T.patt => constants.%T.patt // CHECK:STDOUT: %I.type => constants.%I.type.325 -// CHECK:STDOUT: %require_complete => constants.%require_complete.cfe // CHECK:STDOUT: %impl_witness => constants.%impl_witness.eff58b.1 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -509,7 +505,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.loc8_14.2 => constants.%T // CHECK:STDOUT: %T.patt.loc8_14.2 => constants.%T.patt // CHECK:STDOUT: %I.type.loc8_32.2 => constants.%I.type.325 -// CHECK:STDOUT: %require_complete => constants.%require_complete.cfe // CHECK:STDOUT: %impl_witness => constants.%impl_witness.eff58b.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -534,7 +529,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.patt.loc20_14.2 => constants.%T.patt // CHECK:STDOUT: %ptr.loc20_32.2 => constants.%ptr // CHECK:STDOUT: %I.type.loc20_33.2 => constants.%I.type.0e2 -// CHECK:STDOUT: %require_complete => constants.%require_complete.0e6 // CHECK:STDOUT: %impl_witness => constants.%impl_witness.46542c.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -566,13 +560,10 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %J.type.2b8: type = generic_interface_type @J [concrete] // CHECK:STDOUT: %J.generic: %J.type.2b8 = struct_value () [concrete] // CHECK:STDOUT: %J.type.b72: type = facet_type <@J, @J(%T)> [symbolic] -// CHECK:STDOUT: %Self.252: %J.type.b72 = bind_symbolic_name Self, 1 [symbolic] -// CHECK:STDOUT: %require_complete.287: = require_complete_type %J.type.b72 [symbolic] +// CHECK:STDOUT: %Self: %J.type.b72 = bind_symbolic_name Self, 1 [symbolic] // CHECK:STDOUT: %impl_witness.0ef: = impl_witness (), @impl.199(%T) [symbolic] // CHECK:STDOUT: %ptr: type = ptr_type %T [symbolic] // CHECK:STDOUT: %J.type.628: type = facet_type <@J, @J(%ptr)> [symbolic] -// CHECK:STDOUT: %Self.fbe: %J.type.628 = bind_symbolic_name Self, 1 [symbolic] -// CHECK:STDOUT: %require_complete.c60: = require_complete_type %J.type.628 [symbolic] // CHECK:STDOUT: %impl_witness.b80: = impl_witness (), @impl.dfd(%T) [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -616,10 +607,10 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %J.type: type = facet_type <@J, @J(%T.loc5_13.2)> [symbolic = %J.type (constants.%J.type.b72)] -// CHECK:STDOUT: %Self.2: @J.%J.type (%J.type.b72) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.252)] +// CHECK:STDOUT: %Self.2: @J.%J.type (%J.type.b72) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)] // CHECK:STDOUT: // CHECK:STDOUT: interface { -// CHECK:STDOUT: %Self.1: @J.%J.type (%J.type.b72) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.252)] +// CHECK:STDOUT: %Self.1: @J.%J.type (%J.type.b72) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self.1 @@ -631,7 +622,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.loc11_14.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc11_14.2 (constants.%T)] // CHECK:STDOUT: %T.patt.loc11_14.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_14.2 (constants.%T.patt)] // CHECK:STDOUT: %J.type.loc11_32.2: type = facet_type <@J, @J(%T.loc11_14.2)> [symbolic = %J.type.loc11_32.2 (constants.%J.type.b72)] -// CHECK:STDOUT: %require_complete: = require_complete_type @impl.199.%J.type.loc11_32.2 (%J.type.b72) [symbolic = %require_complete (constants.%require_complete.287)] // CHECK:STDOUT: %impl_witness: = impl_witness (), @impl.199(%T.loc11_14.2) [symbolic = %impl_witness (constants.%impl_witness.0ef)] // CHECK:STDOUT: // CHECK:STDOUT: impl: %D.ref as %J.type.loc11_32.1; @@ -642,7 +632,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.patt.loc17_14.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc17_14.2 (constants.%T.patt)] // CHECK:STDOUT: %ptr.loc17_32.2: type = ptr_type @impl.dfd.%T.loc17_14.2 (%T) [symbolic = %ptr.loc17_32.2 (constants.%ptr)] // CHECK:STDOUT: %J.type.loc17_33.2: type = facet_type <@J, @J(%ptr.loc17_32.2)> [symbolic = %J.type.loc17_33.2 (constants.%J.type.628)] -// CHECK:STDOUT: %require_complete: = require_complete_type @impl.dfd.%J.type.loc17_33.2 (%J.type.628) [symbolic = %require_complete (constants.%require_complete.c60)] // CHECK:STDOUT: %impl_witness: = impl_witness (), @impl.dfd(%T.loc17_14.2) [symbolic = %impl_witness (constants.%impl_witness.b80)] // CHECK:STDOUT: // CHECK:STDOUT: impl: %D.ref as %J.type.loc17_33.1; @@ -659,10 +648,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: specific @J(constants.%T) { // CHECK:STDOUT: %T.loc5_13.2 => constants.%T // CHECK:STDOUT: %T.patt.loc5_13.2 => constants.%T.patt -// CHECK:STDOUT: -// CHECK:STDOUT: !definition: -// CHECK:STDOUT: %J.type => constants.%J.type.b72 -// CHECK:STDOUT: %Self.2 => constants.%Self.252 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @J(%T.loc5_13.2) {} @@ -671,7 +656,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.loc11_14.2 => constants.%T // CHECK:STDOUT: %T.patt.loc11_14.2 => constants.%T.patt // CHECK:STDOUT: %J.type.loc11_32.2 => constants.%J.type.b72 -// CHECK:STDOUT: %require_complete => constants.%require_complete.287 // CHECK:STDOUT: %impl_witness => constants.%impl_witness.0ef // CHECK:STDOUT: } // CHECK:STDOUT: @@ -682,10 +666,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: specific @J(constants.%ptr) { // CHECK:STDOUT: %T.loc5_13.2 => constants.%ptr // CHECK:STDOUT: %T.patt.loc5_13.2 => constants.%T.patt -// CHECK:STDOUT: -// CHECK:STDOUT: !definition: -// CHECK:STDOUT: %J.type => constants.%J.type.628 -// CHECK:STDOUT: %Self.2 => constants.%Self.fbe // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @impl.dfd(constants.%T) { @@ -693,7 +673,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.patt.loc17_14.2 => constants.%T.patt // CHECK:STDOUT: %ptr.loc17_32.2 => constants.%ptr // CHECK:STDOUT: %J.type.loc17_33.2 => constants.%J.type.628 -// CHECK:STDOUT: %require_complete => constants.%require_complete.c60 // CHECK:STDOUT: %impl_witness => constants.%impl_witness.b80 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -713,16 +692,16 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %D: type = class_type @D [concrete] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] -// CHECK:STDOUT: %require_complete.287: = require_complete_type %J.type.b72 [symbolic] // CHECK:STDOUT: %impl_witness.0ef94b.1: = impl_witness (), @impl.199bba.1(%T) [symbolic] // CHECK:STDOUT: %ptr: type = ptr_type %T [symbolic] // CHECK:STDOUT: %J.type.628: type = facet_type <@J, @J(%ptr)> [symbolic] -// CHECK:STDOUT: %require_complete.c60: = require_complete_type %J.type.628 [symbolic] // CHECK:STDOUT: %impl_witness.b80f53.1: = impl_witness (), @impl.dfd2f7.1(%T) [symbolic] -// CHECK:STDOUT: %Self.fbe: %J.type.628 = bind_symbolic_name Self, 1 [symbolic] // CHECK:STDOUT: %impl_witness.0ef94b.2: = impl_witness (), @impl.199bba.2(%T) [symbolic] +// CHECK:STDOUT: %require_complete.287: = require_complete_type %J.type.b72 [symbolic] // CHECK:STDOUT: %impl_witness.0ef94b.3: = impl_witness (), @impl.199bba.3(%T) [symbolic] // CHECK:STDOUT: %impl_witness.b80f53.2: = impl_witness (), @impl.dfd2f7.2(%T) [symbolic] +// CHECK:STDOUT: %Self.fbe: %J.type.628 = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %require_complete.c60: = require_complete_type %J.type.628 [symbolic] // CHECK:STDOUT: %impl_witness.b80f53.3: = impl_witness (), @impl.dfd2f7.3(%T) [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -811,7 +790,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)] // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)] // CHECK:STDOUT: %J.type: type = facet_type <@J, @J(%T)> [symbolic = %J.type (constants.%J.type.b72)] -// CHECK:STDOUT: %require_complete: = require_complete_type @impl.199bba.1.%J.type (%J.type.b72) [symbolic = %require_complete (constants.%require_complete.287)] // CHECK:STDOUT: %impl_witness: = impl_witness (), @impl.199bba.1(%T) [symbolic = %impl_witness (constants.%impl_witness.0ef94b.1)] // CHECK:STDOUT: // CHECK:STDOUT: impl: imports.%Main.import_ref.aa9f8a.1 as imports.%Main.import_ref.ded; @@ -822,7 +800,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)] // CHECK:STDOUT: %ptr: type = ptr_type @impl.dfd2f7.1.%T (%T) [symbolic = %ptr (constants.%ptr)] // CHECK:STDOUT: %J.type: type = facet_type <@J, @J(%ptr)> [symbolic = %J.type (constants.%J.type.628)] -// CHECK:STDOUT: %require_complete: = require_complete_type @impl.dfd2f7.1.%J.type (%J.type.628) [symbolic = %require_complete (constants.%require_complete.c60)] // CHECK:STDOUT: %impl_witness: = impl_witness (), @impl.dfd2f7.1(%T) [symbolic = %impl_witness (constants.%impl_witness.b80f53.1)] // CHECK:STDOUT: // CHECK:STDOUT: impl: imports.%Main.import_ref.aa9f8a.2 as imports.%Main.import_ref.0d3; @@ -832,7 +809,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.loc8_14.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_14.2 (constants.%T)] // CHECK:STDOUT: %T.patt.loc8_14.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_14.2 (constants.%T.patt)] // CHECK:STDOUT: %J.type.loc8_32.2: type = facet_type <@J, @J(%T.loc8_14.2)> [symbolic = %J.type.loc8_32.2 (constants.%J.type.b72)] -// CHECK:STDOUT: %require_complete: = require_complete_type @impl.199bba.2.%J.type.loc8_32.2 (%J.type.b72) [symbolic = %require_complete (constants.%require_complete.287)] // CHECK:STDOUT: %impl_witness: = impl_witness (), @impl.199bba.2(%T.loc8_14.2) [symbolic = %impl_witness (constants.%impl_witness.0ef94b.2)] // CHECK:STDOUT: // CHECK:STDOUT: impl: %D.ref as %J.type.loc8_32.1; @@ -858,7 +834,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.patt.loc20_14.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc20_14.2 (constants.%T.patt)] // CHECK:STDOUT: %ptr.loc20_32.2: type = ptr_type @impl.dfd2f7.2.%T.loc20_14.2 (%T) [symbolic = %ptr.loc20_32.2 (constants.%ptr)] // CHECK:STDOUT: %J.type.loc20_33.2: type = facet_type <@J, @J(%ptr.loc20_32.2)> [symbolic = %J.type.loc20_33.2 (constants.%J.type.628)] -// CHECK:STDOUT: %require_complete: = require_complete_type @impl.dfd2f7.2.%J.type.loc20_33.2 (%J.type.628) [symbolic = %require_complete (constants.%require_complete.c60)] // CHECK:STDOUT: %impl_witness: = impl_witness (), @impl.dfd2f7.2(%T.loc20_14.2) [symbolic = %impl_witness (constants.%impl_witness.b80f53.2)] // CHECK:STDOUT: // CHECK:STDOUT: impl: %D.ref as %J.type.loc20_33.1; @@ -902,7 +877,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: %T.patt => constants.%T.patt // CHECK:STDOUT: %J.type => constants.%J.type.b72 -// CHECK:STDOUT: %require_complete => constants.%require_complete.287 // CHECK:STDOUT: %impl_witness => constants.%impl_witness.0ef94b.1 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -924,7 +898,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.patt => constants.%T.patt // CHECK:STDOUT: %ptr => constants.%ptr // CHECK:STDOUT: %J.type => constants.%J.type.628 -// CHECK:STDOUT: %require_complete => constants.%require_complete.c60 // CHECK:STDOUT: %impl_witness => constants.%impl_witness.b80f53.1 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -936,7 +909,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.loc8_14.2 => constants.%T // CHECK:STDOUT: %T.patt.loc8_14.2 => constants.%T.patt // CHECK:STDOUT: %J.type.loc8_32.2 => constants.%J.type.b72 -// CHECK:STDOUT: %require_complete => constants.%require_complete.287 // CHECK:STDOUT: %impl_witness => constants.%impl_witness.0ef94b.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -961,7 +933,6 @@ impl forall [T:! type] D as J(T*) {} // CHECK:STDOUT: %T.patt.loc20_14.2 => constants.%T.patt // CHECK:STDOUT: %ptr.loc20_32.2 => constants.%ptr // CHECK:STDOUT: %J.type.loc20_33.2 => constants.%J.type.628 -// CHECK:STDOUT: %require_complete => constants.%require_complete.c60 // CHECK:STDOUT: %impl_witness => constants.%impl_witness.b80f53.2 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/no_prelude/import_interface_assoc_const.carbon b/toolchain/check/testdata/impl/no_prelude/import_interface_assoc_const.carbon index 83bd5f97d356..ed029ca60c4f 100644 --- a/toolchain/check/testdata/impl/no_prelude/import_interface_assoc_const.carbon +++ b/toolchain/check/testdata/impl/no_prelude/import_interface_assoc_const.carbon @@ -503,7 +503,7 @@ impl CD as IF where .F = 0 { // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete] // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] -// CHECK:STDOUT: %impl_witness.85b: = impl_witness () [concrete] +// CHECK:STDOUT: %impl_witness.1bc: = impl_witness () [concrete] // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self] // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type [concrete] // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.652 [concrete] @@ -538,7 +538,7 @@ impl CD as IF where .F = 0 { // CHECK:STDOUT: %C3.ref: type = name_ref C3, file.%C3.decl [concrete = constants.%C3] // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type] // CHECK:STDOUT: } -// CHECK:STDOUT: %impl_witness.loc9: = impl_witness () [concrete = constants.%impl_witness.85b] +// CHECK:STDOUT: %impl_witness.loc9: = impl_witness () [concrete = constants.%impl_witness.1bc] // CHECK:STDOUT: impl_decl @impl.5ad [concrete] {} { // CHECK:STDOUT: %C3.ref: type = name_ref C3, file.%C3.decl [concrete = constants.%C3] // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type] diff --git a/toolchain/check/testdata/impl/no_prelude/no_definition_in_impl_file.carbon b/toolchain/check/testdata/impl/no_prelude/no_definition_in_impl_file.carbon index 6814fbb38a82..225ca52f1316 100644 --- a/toolchain/check/testdata/impl/no_prelude/no_definition_in_impl_file.carbon +++ b/toolchain/check/testdata/impl/no_prelude/no_definition_in_impl_file.carbon @@ -137,7 +137,8 @@ impl () as D; // CHECK:STDOUT: constants { // CHECK:STDOUT: %A.type: type = facet_type <@A> [concrete] // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] -// CHECK:STDOUT: %impl_witness: = impl_witness () [concrete] +// CHECK:STDOUT: %impl_witness.1bcebf.1: = impl_witness () [concrete] +// CHECK:STDOUT: %impl_witness.1bcebf.2: = impl_witness () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -158,13 +159,13 @@ impl () as D; // CHECK:STDOUT: %.loc8_7.2: type = converted %.loc8_7.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: %A.ref: type = name_ref A, imports.%Main.A [concrete = constants.%A.type] // CHECK:STDOUT: } -// CHECK:STDOUT: %impl_witness.loc8: = impl_witness () [concrete = constants.%impl_witness] +// CHECK:STDOUT: %impl_witness.loc8: = impl_witness () [concrete = constants.%impl_witness.1bcebf.1] // CHECK:STDOUT: impl_decl @impl.064930.3 [concrete] {} { // CHECK:STDOUT: %.loc14_7.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc14_7.2: type = converted %.loc14_7.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: %A.ref: type = name_ref A, imports.%Main.A [concrete = constants.%A.type] // CHECK:STDOUT: } -// CHECK:STDOUT: %impl_witness.loc14: = impl_witness () [concrete = constants.%impl_witness] +// CHECK:STDOUT: %impl_witness.loc14: = impl_witness () [concrete = constants.%impl_witness.1bcebf.2] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: interface @A [from "fail_decl_in_api_definition_in_impl.carbon"] { diff --git a/toolchain/check/type_completion.cpp b/toolchain/check/type_completion.cpp index b25b3a021194..564a1e6d6dd5 100644 --- a/toolchain/check/type_completion.cpp +++ b/toolchain/check/type_completion.cpp @@ -286,21 +286,12 @@ auto TypeCompleter::AddNestedIncompleteTypes(SemIR::Inst type_inst) -> bool { break; } case CARBON_KIND(SemIR::FacetType inst): { - if (context_->complete_facet_types() - .TryGetId(inst.facet_type_id) - .has_value()) { - break; - } - const auto& facet_type_info = - context_->facet_types().Get(inst.facet_type_id); - - SemIR::CompleteFacetType result; - result.required_interfaces.reserve( - facet_type_info.impls_constraints.size()); - // Every mentioned interface needs to be defined. - for (auto impl_interface : facet_type_info.impls_constraints) { - // TODO: expand named constraints - auto interface_id = impl_interface.interface_id; + auto identified_id = RequireIdentifiedFacetType(*context_, inst); + const auto& identified = + context_->identified_facet_types().Get(identified_id); + // Every mentioned interface needs to be complete. + for (auto req_interface : identified.required_interfaces()) { + auto interface_id = req_interface.interface_id; const auto& interface = context_->interfaces().Get(interface_id); if (!interface.is_complete()) { if (diagnoser_) { @@ -311,22 +302,10 @@ auto TypeCompleter::AddNestedIncompleteTypes(SemIR::Inst type_inst) -> bool { return false; } - if (impl_interface.specific_id.has_value()) { - ResolveSpecificDefinition(*context_, loc_, - impl_interface.specific_id); + if (req_interface.specific_id.has_value()) { + ResolveSpecificDefinition(*context_, loc_, req_interface.specific_id); } - result.required_interfaces.push_back( - {.interface_id = interface_id, - .specific_id = impl_interface.specific_id}); } - result.CanonicalizeRequiredInterfaces(); - - // TODO: Distinguish interfaces that are required but would not be - // implemented, such as those from `where .Self impls I`. - result.num_to_impl = result.required_interfaces.size(); - - // TODO: Process other kinds of requirements. - context_->complete_facet_types().Add(inst.facet_type_id, result); break; } @@ -625,16 +604,31 @@ auto RequireConcreteType(Context& context, SemIR::TypeId type_id, return true; } -auto RequireCompleteFacetType(Context& context, SemIR::TypeId type_id, - SemIR::LocId loc_id, - const SemIR::FacetType& facet_type, - MakeDiagnosticBuilderFn diagnoser) - -> SemIR::CompleteFacetTypeId { - if (!RequireCompleteType(context, type_id, loc_id, diagnoser)) { - return SemIR::CompleteFacetTypeId::None; +auto RequireIdentifiedFacetType(Context& context, + const SemIR::FacetType& facet_type) + -> SemIR::IdentifiedFacetTypeId { + if (auto identified_id = + context.identified_facet_types().TryGetId(facet_type.facet_type_id); + identified_id.has_value()) { + return identified_id; + } + const auto& facet_type_info = + context.facet_types().Get(facet_type.facet_type_id); + + SemIR::IdentifiedFacetType result; + // TODO: expand named constraints + result.set_required_interfaces(facet_type_info.impls_constraints); + + // TODO: Distinguish interfaces that are required but would not be + // implemented, such as those from `where .Self impls I`. + if (result.required_interfaces().size() == 1) { + result.set_interface_to_impl(result.required_interfaces().front()); + } else { + result.set_num_interfaces_to_impl(result.required_interfaces().size()); } - return context.complete_facet_types().TryGetId(facet_type.facet_type_id); + // TODO: Process other kinds of requirements. + return context.identified_facet_types().Add(facet_type.facet_type_id, result); } auto AsCompleteType(Context& context, SemIR::TypeId type_id, diff --git a/toolchain/check/type_completion.h b/toolchain/check/type_completion.h index cf554637d65e..aa1622e4113c 100644 --- a/toolchain/check/type_completion.h +++ b/toolchain/check/type_completion.h @@ -53,14 +53,6 @@ auto RequireConcreteType(Context& context, SemIR::TypeId type_id, SemIR::LocId loc_id, MakeDiagnosticBuilderFn diagnoser, MakeDiagnosticBuilderFn abstract_diagnoser) -> bool; -// Like `RequireCompleteType`, but only for facet types. If it uses some -// incomplete interface, diagnoses the problem and returns `None`. -auto RequireCompleteFacetType(Context& context, SemIR::TypeId type_id, - SemIR::LocId loc_id, - const SemIR::FacetType& facet_type, - MakeDiagnosticBuilderFn diagnoser) - -> SemIR::CompleteFacetTypeId; - // Returns the type `type_id` if it is a complete type, or produces an // incomplete type error and returns an error type. This is a convenience // wrapper around `RequireCompleteType`. @@ -76,6 +68,16 @@ auto AsConcreteType(Context& context, SemIR::TypeId type_id, MakeDiagnosticBuilderFn abstract_diagnoser) -> SemIR::TypeId; +// Requires the named constraints in the facet type to be complete, so that the +// set of interfaces the facet type requires is known. Since named constraints +// are not yet supported, this currently never fails. Eventually this function +// will be passed a diagnoser for facet types that use some incomplete named +// constraint, and return `None` in that case. If not `None`, the result will be +// present in context.identified_facet_type()`. +auto RequireIdentifiedFacetType(Context& context, + const SemIR::FacetType& facet_type) + -> SemIR::IdentifiedFacetTypeId; + // Adds a note to a diagnostic explaining that a class is incomplete. auto NoteIncompleteClass(Context& context, SemIR::ClassId class_id, DiagnosticBuilder& builder) -> void; diff --git a/toolchain/diagnostics/diagnostic_kind.def b/toolchain/diagnostics/diagnostic_kind.def index 794d13895572..0cdffcd43ff3 100644 --- a/toolchain/diagnostics/diagnostic_kind.def +++ b/toolchain/diagnostics/diagnostic_kind.def @@ -287,12 +287,13 @@ CARBON_DIAGNOSTIC_KIND(VarInInterfaceDecl) // Impl checking. CARBON_DIAGNOSTIC_KIND(AssociatedConstantHere) CARBON_DIAGNOSTIC_KIND(AssociatedFunctionHere) +CARBON_DIAGNOSTIC_KIND(ExtendImplAsIncomplete) CARBON_DIAGNOSTIC_KIND(ExtendImplForall) CARBON_DIAGNOSTIC_KIND(ExtendImplOutsideClass) CARBON_DIAGNOSTIC_KIND(ExtendImplSelfAs) CARBON_DIAGNOSTIC_KIND(ExtendImplSelfAsDefault) -CARBON_DIAGNOSTIC_KIND(ImplAccessMemberBeforeComplete) -CARBON_DIAGNOSTIC_KIND(ImplAsIncompleteFacetType) +CARBON_DIAGNOSTIC_KIND(ImplAccessMemberBeforeSet) +CARBON_DIAGNOSTIC_KIND(ImplAsIncompleteFacetTypeDefinition) CARBON_DIAGNOSTIC_KIND(ImplAsNonFacetType) CARBON_DIAGNOSTIC_KIND(ImplAsOutsideClass) CARBON_DIAGNOSTIC_KIND(ImplAssociatedConstantNeedsValue) @@ -325,7 +326,6 @@ CARBON_DIAGNOSTIC_KIND(QualifiedDeclInIncompleteClassScope) CARBON_DIAGNOSTIC_KIND(QualifiedDeclInUndefinedInterfaceScope) // Name lookup. -CARBON_DIAGNOSTIC_KIND(FromExtendHere) CARBON_DIAGNOSTIC_KIND(InCppNameLookup) CARBON_DIAGNOSTIC_KIND(InNameLookup) CARBON_DIAGNOSTIC_KIND(NameAmbiguousDueToExtend) diff --git a/toolchain/sem_ir/dump.cpp b/toolchain/sem_ir/dump.cpp index 6a1a3679c95b..81746627428c 100644 --- a/toolchain/sem_ir/dump.cpp +++ b/toolchain/sem_ir/dump.cpp @@ -125,9 +125,10 @@ LLVM_DUMP_METHOD auto Dump(const File& file, FacetTypeId facet_type_id) << " - " << DumpConstantSummary(file, rewrite.lhs_const_id) << "\n" << " - " << DumpConstantSummary(file, rewrite.rhs_const_id); } - if (auto complete_id = file.complete_facet_types().TryGetId(facet_type_id); - complete_id.has_value()) { - out << "\ncomplete: " << Dump(file, complete_id); + if (auto identified_id = + file.identified_facet_types().TryGetId(facet_type_id); + identified_id.has_value()) { + out << "\nidentified: " << Dump(file, identified_id); } return out.TakeStr(); } @@ -276,25 +277,29 @@ LLVM_DUMP_METHOD auto Dump(const File& file, NameScopeId name_scope_id) } LLVM_DUMP_METHOD auto Dump(const File& file, - CompleteFacetTypeId complete_facet_type_id) + IdentifiedFacetTypeId identified_facet_type_id) -> std::string { RawStringOstream out; - out << complete_facet_type_id; - if (!complete_facet_type_id.has_value()) { + out << identified_facet_type_id; + if (!identified_facet_type_id.has_value()) { return out.TakeStr(); } - const auto& complete_facet_type = - file.complete_facet_types().Get(complete_facet_type_id); + const auto& identified_facet_type = + file.identified_facet_types().Get(identified_facet_type_id); for (auto [i, req_interface] : - llvm::enumerate(complete_facet_type.required_interfaces)) { + llvm::enumerate(identified_facet_type.required_interfaces())) { out << "\n - " << Dump(file, req_interface.interface_id); if (req_interface.specific_id.has_value()) { out << "; " << DumpSpecificSummary(file, req_interface.specific_id); } - if (static_cast(i) < complete_facet_type.num_to_impl) { + if (req_interface == identified_facet_type.impl_as_target_interface()) { out << " (to impl)"; } + if (!identified_facet_type.is_valid_impl_as_target()) { + out << "\n - (" << identified_facet_type.num_interfaces_to_impl() + << " to impl)\n"; + } } return out.TakeStr(); } @@ -415,9 +420,9 @@ LLVM_DUMP_METHOD static auto MakeNameId(int id) -> NameId { return NameId(id); } LLVM_DUMP_METHOD static auto MakeNameScopeId(int id) -> NameScopeId { return NameScopeId(id); } -LLVM_DUMP_METHOD static auto MakeCompleteFacetTypeId(int id) - -> CompleteFacetTypeId { - return CompleteFacetTypeId(id); +LLVM_DUMP_METHOD static auto MakeIdentifiedFacetTypeId(int id) + -> IdentifiedFacetTypeId { + return IdentifiedFacetTypeId(id); } LLVM_DUMP_METHOD static auto MakeSpecificId(int id) -> SpecificId { return SpecificId(id); diff --git a/toolchain/sem_ir/dump.h b/toolchain/sem_ir/dump.h index 82e1b7a750b6..dca7700c8fe2 100644 --- a/toolchain/sem_ir/dump.h +++ b/toolchain/sem_ir/dump.h @@ -32,7 +32,7 @@ auto Dump(const File& file, InstId inst_id) -> std::string; auto Dump(const File& file, InterfaceId interface_id) -> std::string; auto Dump(const File& file, NameId name_id) -> std::string; auto Dump(const File& file, NameScopeId name_scope_id) -> std::string; -auto Dump(const File& file, CompleteFacetTypeId complete_facet_type_id) +auto Dump(const File& file, IdentifiedFacetTypeId identified_facet_type_id) -> std::string; auto Dump(const File& file, SpecificId specific_id) -> std::string; auto Dump(const File& file, SpecificInterfaceId specific_interface_id) diff --git a/toolchain/sem_ir/facet_type_info.cpp b/toolchain/sem_ir/facet_type_info.cpp index 132c9b13404c..4dcb0521f021 100644 --- a/toolchain/sem_ir/facet_type_info.cpp +++ b/toolchain/sem_ir/facet_type_info.cpp @@ -27,8 +27,8 @@ static auto RewriteLess(const FacetTypeInfo::RewriteConstraint& lhs, } // Canonically ordered by the numerical ids. -static auto RequiredLess(const CompleteFacetType::RequiredInterface& lhs, - const CompleteFacetType::RequiredInterface& rhs) +static auto RequiredLess(const IdentifiedFacetType::RequiredInterface& lhs, + const IdentifiedFacetType::RequiredInterface& rhs) -> bool { return std::tie(lhs.interface_id.index, lhs.specific_id.index) < std::tie(rhs.interface_id.index, rhs.specific_id.index); @@ -69,8 +69,8 @@ auto FacetTypeInfo::Print(llvm::raw_ostream& out) const -> void { out << "}"; } -auto CompleteFacetType::CanonicalizeRequiredInterfaces() -> void { - SortAndDeduplicate(required_interfaces, RequiredLess); +auto IdentifiedFacetType::CanonicalizeRequiredInterfaces() -> void { + SortAndDeduplicate(required_interfaces_, RequiredLess); } } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/facet_type_info.h b/toolchain/sem_ir/facet_type_info.h index 7cd168076ab1..c0942c30cd2e 100644 --- a/toolchain/sem_ir/facet_type_info.h +++ b/toolchain/sem_ir/facet_type_info.h @@ -100,25 +100,78 @@ constexpr FacetTypeInfo::RewriteConstraint FacetTypeInfo::RewriteConstraint::None = {.lhs_const_id = ConstantId::None, .rhs_const_id = ConstantId::None}; -struct CompleteFacetType { - // TODO: Add additional fields, for example to support types other than - // `.Self` implementation requirements. +struct IdentifiedFacetType { using RequiredInterface = SpecificInterface; - // Interfaces mentioned explicitly in the facet type expression, or - // transitively through a named constraint. - llvm::SmallVector required_interfaces; + IdentifiedFacetType() {} - // Number of interfaces from `interfaces` to implement if this is the facet - // type to the right of an `impl`...`as`. Invalid to use in that position - // unless this value is 1. - int num_to_impl; + auto required_interfaces() const -> llvm::ArrayRef { + return required_interfaces_; + } - // TODO: Which interfaces to perform name lookup into. + auto set_required_interfaces(const llvm::ArrayRef set_to) { + required_interfaces_.assign(set_to.begin(), set_to.end()); + CanonicalizeRequiredInterfaces(); + } + // Can this be used to the right of an `as` in an `impl` declaration? + auto is_valid_impl_as_target() const -> bool { + return interface_id_.has_value(); + } + + // The interface to implement when this facet type is used in an `impl` + // declaration. + auto impl_as_target_interface() const -> SpecificInterface { + if (is_valid_impl_as_target()) { + return {.interface_id = interface_id_, .specific_id = specific_id_}; + } else { + return SpecificInterface::None; + } + } + + auto num_interfaces_to_impl() const -> int { + if (is_valid_impl_as_target()) { + return 1; + } else { + return num_interface_to_impl_; + } + } + + // Call this function if num != 1, otherwise call `set_interface_to_impl`. + auto set_num_interfaces_to_impl(int num) -> void { + CARBON_CHECK(num != 1); + interface_id_ = InterfaceId::None; + num_interface_to_impl_ = num; + } + + // If there is a single interface to implement, specify which it is. + // Should be an element of `required_interfaces()`. + auto set_interface_to_impl(SpecificInterface interface) -> void { + CARBON_CHECK(interface.interface_id.has_value()); + interface_id_ = interface.interface_id; + specific_id_ = interface.specific_id; + } + + private: // Sorts and deduplicates `required_interfaces`. Call after building the sets - // of interfaces, and then don't mutate them value afterwards. + // of interfaces, and then don't mutate the value afterwards. auto CanonicalizeRequiredInterfaces() -> void; + + // Interfaces mentioned explicitly in the facet type expression, or + // transitively through a named constraint. Sorted and deduplicated. + llvm::SmallVector required_interfaces_; + + // The single interface from `required_interfaces` to implement if this is + // the facet type to the right of an `impl`...`as`, or `None` if no such + // single interface. + InterfaceId interface_id_ = InterfaceId::None; + union { + // If `interface_id` is `None`, the number of interfaces to report in a + // diagnostic about why this facet type can't be implemented. + int num_interface_to_impl_ = 0; + // If `interface_id` is not `None`, the specific for that interface. + SpecificId specific_id_; + }; }; // See common/hashing.h. diff --git a/toolchain/sem_ir/file.h b/toolchain/sem_ir/file.h index 3ded2cfeb62b..cf64e351e2ce 100644 --- a/toolchain/sem_ir/file.h +++ b/toolchain/sem_ir/file.h @@ -58,8 +58,8 @@ struct ExprRegion { // Provides semantic analysis on a Parse::Tree. class File : public Printable { public: - using CompleteFacetTypeStore = - RelationalValueStore; + using IdentifiedFacetTypeStore = + RelationalValueStore; // Starts a new file for Check::CheckParseTree. explicit File(const Parse::Tree* parse_tree, CheckIRId check_ir_id, @@ -161,11 +161,11 @@ class File : public Printable { auto facet_types() const -> const CanonicalValueStore& { return facet_types_; } - auto complete_facet_types() -> CompleteFacetTypeStore& { - return complete_facet_types_; + auto identified_facet_types() -> IdentifiedFacetTypeStore& { + return identified_facet_types_; } - auto complete_facet_types() const -> const CompleteFacetTypeStore& { - return complete_facet_types_; + auto identified_facet_types() const -> const IdentifiedFacetTypeStore& { + return identified_facet_types_; } auto impls() -> ImplStore& { return impls_; } auto impls() const -> const ImplStore& { return impls_; } @@ -292,8 +292,8 @@ class File : public Printable { // Storage for facet types. CanonicalValueStore facet_types_; - // Storage for complete facet types. - CompleteFacetTypeStore complete_facet_types_; + // Storage for identified facet types. + IdentifiedFacetTypeStore identified_facet_types_; // Storage for impls. ImplStore impls_; diff --git a/toolchain/sem_ir/ids.h b/toolchain/sem_ir/ids.h index b6f344f4649b..1bd3b9ef0147 100644 --- a/toolchain/sem_ir/ids.h +++ b/toolchain/sem_ir/ids.h @@ -25,7 +25,7 @@ struct ExprRegion; struct FacetTypeInfo; struct Function; struct Generic; -struct CompleteFacetType; +struct IdentifiedFacetType; struct Specific; struct SpecificInterface; struct ImportCpp; @@ -275,9 +275,9 @@ struct FacetTypeId : public IdBase { }; // The ID of an resolved facet type value. -struct CompleteFacetTypeId : public IdBase { - static constexpr llvm::StringLiteral Label = "complete_facet_type"; - using ValueType = CompleteFacetType; +struct IdentifiedFacetTypeId : public IdBase { + static constexpr llvm::StringLiteral Label = "identified_facet_type"; + using ValueType = IdentifiedFacetType; using IdBase::IdBase; }; diff --git a/toolchain/sem_ir/typed_insts.h b/toolchain/sem_ir/typed_insts.h index cf3a790b11d6..9f4efe5ada40 100644 --- a/toolchain/sem_ir/typed_insts.h +++ b/toolchain/sem_ir/typed_insts.h @@ -732,7 +732,7 @@ struct FacetValue { InstId type_inst_id; // The set of `ImplWitness` instructions for a `FacetType`. The witnesses are // in the same order as the set of `required_interfaces` in the - // `CompleteFacetType` of the `FacetType` from `type_id`, so that an index + // `IdentifiedFacetType` of the `FacetType` from `type_id`, so that an index // from one can be used with the other. InstBlockId witnesses_block_id; };