diff --git a/toolchain/check/check_unit.cpp b/toolchain/check/check_unit.cpp index 6f7e9189d1775..4470ae19de924 100644 --- a/toolchain/check/check_unit.cpp +++ b/toolchain/check/check_unit.cpp @@ -402,9 +402,9 @@ auto CheckUnit::CheckRequiredDefinitions() -> void { auto& impl = context_.impls().Get(impl_decl.impl_id); if (!impl.is_defined()) { FillImplWitnessWithErrors(context_, impl); - CARBON_DIAGNOSTIC(MissingImplDefinition, Error, + CARBON_DIAGNOSTIC(ImplMissingDefinition, Error, "impl declared but not defined"); - emitter_.Emit(decl_inst_id, MissingImplDefinition); + emitter_.Emit(decl_inst_id, ImplMissingDefinition); } break; } diff --git a/toolchain/check/handle_impl.cpp b/toolchain/check/handle_impl.cpp index 30367ceaa7e09..1450649848d07 100644 --- a/toolchain/check/handle_impl.cpp +++ b/toolchain/check/handle_impl.cpp @@ -321,7 +321,8 @@ static auto BuildImplDecl(Context& context, Parse::AnyImplDeclId node_id, // TODO: Check that its constant value is a constraint. auto [constraint_inst_id, constraint_type_id] = ExprAsType(context, constraint_node, constraint_id); - // TODO: Do facet type resolution here. + // TODO: Do facet type resolution here, and enforce that the constraint + // extends a single interface. // TODO: Determine `interface_id` and `specific_id` once and save it in the // resolved facet type, instead of in multiple functions called below. // TODO: Skip work below if facet type resolution fails, so we don't have a @@ -373,12 +374,16 @@ static auto BuildImplDecl(Context& context, Parse::AnyImplDeclId node_id, if (!impl_decl.impl_id.is_valid()) { impl_info.generic_id = BuildGeneric(context, impl_decl_id); impl_info.witness_id = ImplWitnessForDeclaration(context, impl_info); + AddConstantsToImplWitnessFromConstraint( + context, impl_info, impl_info.witness_id, impl_decl.impl_id); FinishGenericDecl(context, impl_decl_id, impl_info.generic_id); impl_decl.impl_id = context.impls().Add(impl_info); lookup_bucket_ref.push_back(impl_decl.impl_id); } else { - FinishGenericRedecl(context, impl_decl_id, - context.impls().Get(impl_decl.impl_id).generic_id); + const auto& first_impl = context.impls().Get(impl_decl.impl_id); + AddConstantsToImplWitnessFromConstraint( + context, impl_info, first_impl.witness_id, impl_decl.impl_id); + FinishGenericRedecl(context, impl_decl_id, first_impl.generic_id); } // Write the impl ID into the ImplDecl. diff --git a/toolchain/check/impl.cpp b/toolchain/check/impl.cpp index 1a714a73b3c81..20d05a2e21b20 100644 --- a/toolchain/check/impl.cpp +++ b/toolchain/check/impl.cpp @@ -23,13 +23,23 @@ namespace Carbon::Check { static auto NoteAssociatedFunction(Context& context, Context::DiagnosticBuilder& builder, SemIR::FunctionId function_id) -> void { - CARBON_DIAGNOSTIC(ImplAssociatedFunctionHere, Note, + CARBON_DIAGNOSTIC(AssociatedFunctionHere, Note, "associated function {0} declared here", SemIR::NameId); const auto& function = context.functions().Get(function_id); - builder.Note(function.latest_decl_id(), ImplAssociatedFunctionHere, + builder.Note(function.latest_decl_id(), AssociatedFunctionHere, function.name_id); } +// Adds the location of the previous declaration to a diagnostic. +static auto NotePreviousDecl(Context& context, + Context::DiagnosticBuilder& builder, + SemIR::ImplId impl_id) -> void { + CARBON_DIAGNOSTIC(ImplPreviousDeclHere, Note, + "impl previously declared here"); + const auto& impl = context.impls().Get(impl_id); + builder.Note(impl.latest_decl_id(), ImplPreviousDeclHere); +} + // Gets the self specific of a generic declaration that is an interface member, // given a specific for an enclosing generic, plus a type to use as `Self`. static auto GetSelfSpecificForInterfaceMemberWithSelfType( @@ -160,9 +170,7 @@ auto ImplWitnessForDeclaration(Context& context, const SemIR::Impl& impl) const auto& interface = context.interfaces().Get(interface_type->interface_id); - // TODO: This is going to try and define all the interfaces for this facet - // type, and so once we support impl of a facet type with more than one - // interface, it might give the wrong name in the diagnostic. + // TODO: This should be done as part of facet type resolution. if (!context.RequireDefinedType( facet_type_id, context.insts().GetLocId(impl.latest_decl_id()), [&] { CARBON_DIAGNOSTIC(ImplOfUndefinedInterface, Error, @@ -175,50 +183,14 @@ auto ImplWitnessForDeclaration(Context& context, const SemIR::Impl& impl) return SemIR::ErrorInst::SingletonInstId; } - llvm::SmallVector table; auto assoc_entities = context.inst_blocks().Get(interface.associated_entities_id); - table.reserve(assoc_entities.size()); - for (auto decl_id : assoc_entities) { LoadImportRef(context, decl_id); - decl_id = - context.constant_values().GetInstId(SemIR::GetConstantValueInSpecific( - context.sem_ir(), interface_type->specific_id, decl_id)); - CARBON_CHECK(decl_id.is_valid(), "Non-constant associated entity"); - auto decl = context.insts().Get(decl_id); - CARBON_KIND_SWITCH(decl) { - case CARBON_KIND(SemIR::StructValue struct_value): { - if (struct_value.type_id == SemIR::ErrorInst::SingletonTypeId) { - table.push_back(SemIR::ErrorInst::SingletonInstId); - break; - } - auto type_inst = context.types().GetAsInst(struct_value.type_id); - auto fn_type = type_inst.TryAs(); - if (!fn_type) { - CARBON_FATAL("Unexpected type: {0}", type_inst); - } - table.push_back(SemIR::InstId::Invalid); - break; - } - case CARBON_KIND(SemIR::AssociatedConstantDecl associated): { - // TODO: Allow these using: - // table.push_back(SemIR::InstId::Invalid); - // break; - context.TODO( - impl.latest_decl_id(), - "impl of interface with associated constant " + - context.names().GetFormatted(associated.name_id).str()); - return SemIR::ErrorInst::SingletonInstId; - } - default: - CARBON_CHECK(decl_id == SemIR::ErrorInst::SingletonInstId, - "Unexpected kind of associated entity {0}", decl); - table.push_back(SemIR::ErrorInst::SingletonInstId); - break; - } } + llvm::SmallVector table(assoc_entities.size(), + SemIR::InstId::Invalid); auto table_id = context.inst_blocks().Add(table); return context.AddInst( context.insts().GetLocId(impl.latest_decl_id()), @@ -227,17 +199,202 @@ auto ImplWitnessForDeclaration(Context& context, const SemIR::Impl& impl) .specific_id = context.generics().GetSelfSpecific(impl.generic_id)}); } -auto ImplWitnessStartDefinition(Context& /*context*/, SemIR::Impl& impl) +// Returns `true` if the `FacetAccessWitness` of `witness_id` matches +// `interface`. +static auto WitnessAccessMatchesInterface( + Context& context, SemIR::InstId witness_id, + SemIR::FacetTypeInfo::ImplsConstraint interface) -> bool { + auto access = context.insts().GetAs(witness_id); + auto type_id = context.insts().Get(access.facet_value_inst_id).type_id(); + auto facet_type = context.types().GetAs(type_id); + const auto& facet_info = context.facet_types().Get(facet_type.facet_type_id); + if (auto impls = facet_info.TryAsSingleInterface()) { + return *impls == interface; + } + return false; +} + +auto AddConstantsToImplWitnessFromConstraint(Context& context, + const SemIR::Impl& impl, + SemIR::InstId witness_id, + SemIR::ImplId prev_decl_id) -> void { + CARBON_CHECK(!impl.has_definition_started()); + CARBON_CHECK(witness_id.is_valid()); + if (witness_id == SemIR::ErrorInst::SingletonInstId) { + return; + } + auto facet_type_id = context.GetTypeIdForTypeInst(impl.constraint_id); + CARBON_CHECK(facet_type_id != SemIR::ErrorInst::SingletonTypeId); + auto facet_type = context.types().GetAs(facet_type_id); + const SemIR::FacetTypeInfo& facet_type_info = + context.facet_types().Get(facet_type.facet_type_id); + + auto interface_type = facet_type_info.TryAsSingleInterface(); + CARBON_CHECK(interface_type.has_value()); + const auto& interface = + context.interfaces().Get(interface_type->interface_id); + + auto witness = context.insts().GetAs(witness_id); + auto witness_block = context.inst_blocks().GetMutable(witness.elements_id); + auto assoc_entities = + context.inst_blocks().Get(interface.associated_entities_id); + CARBON_CHECK(witness_block.size() == assoc_entities.size()); + + // Scan through rewrites, produce map from element index to constant value. + // TODO: Perhaps move this into facet type resolution? + llvm::SmallVector rewrite_values( + assoc_entities.size(), SemIR::ConstantId::Invalid); + 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); + if (!WitnessAccessMatchesInterface(context, access.witness_id, + *interface_type)) { + // Skip rewrite constraints that apply to associated constants of + // a different interface than the one being implemented. + continue; + } + CARBON_CHECK(access.index.index >= 0); + CARBON_CHECK(access.index.index < + static_cast(rewrite_values.size())); + auto& rewrite_value = rewrite_values[access.index.index]; + if (rewrite_value.is_valid() && + rewrite_value != SemIR::ErrorInst::SingletonConstantId) { + if (rewrite_value != rewrite.rhs_const_id && + rewrite.rhs_const_id != SemIR::ErrorInst::SingletonConstantId) { + // TODO: Do at least this checking as part of facet type resolution + // instead. + + // TODO: Figure out how to print the two different values + // `rewrite_value` & `rewrite.rhs_const_id` in the diagnostic message. + CARBON_DIAGNOSTIC(AssociatedConstantWithDifferentValues, Error, + "associated constant {0} given two different values", + SemIR::NameId); + auto decl_id = assoc_entities[access.index.index]; + decl_id = context.constant_values().GetInstId( + SemIR::GetConstantValueInSpecific( + context.sem_ir(), interface_type->specific_id, decl_id)); + CARBON_CHECK(decl_id.is_valid(), "Non-constant associated entity"); + auto decl = + context.insts().GetAs(decl_id); + context.emitter().Emit(impl.constraint_id, + AssociatedConstantWithDifferentValues, + decl.name_id); + } + } else { + rewrite_value = rewrite.rhs_const_id; + } + } + + // For each non-function associated constant, update witness entry. + for (auto index : llvm::seq(assoc_entities.size())) { + auto decl_id = assoc_entities[index]; + decl_id = + context.constant_values().GetInstId(SemIR::GetConstantValueInSpecific( + context.sem_ir(), interface_type->specific_id, decl_id)); + CARBON_CHECK(decl_id.is_valid(), "Non-constant associated entity"); + if (auto decl = + context.insts().TryGetAs(decl_id)) { + auto& witness_value = witness_block[index]; + auto rewrite_value = rewrite_values[index]; + if (witness_value.is_valid() && + witness_value != SemIR::ErrorInst::SingletonInstId) { + // TODO: Support just using the witness values if the redeclaration uses + // `where _`, per proposal #1084. + if (!rewrite_value.is_valid()) { + CARBON_DIAGNOSTIC(AssociatedConstantMissingInRedecl, Error, + "associated constant {0} given value in " + "declaration but not redeclaration", + SemIR::NameId); + auto builder = context.emitter().Build( + impl.latest_decl_id(), AssociatedConstantMissingInRedecl, + decl->name_id); + NotePreviousDecl(context, builder, prev_decl_id); + builder.Emit(); + continue; + } + auto witness_const_id = context.constant_values().Get(witness_value); + if (witness_const_id != rewrite_value && + rewrite_value != SemIR::ErrorInst::SingletonConstantId) { + // TODO: Figure out how to print the two different values + CARBON_DIAGNOSTIC( + AssociatedConstantDifferentInRedecl, Error, + "redeclaration with different value for associated constant {0}", + SemIR::NameId); + auto builder = context.emitter().Build( + impl.latest_decl_id(), AssociatedConstantDifferentInRedecl, + decl->name_id); + NotePreviousDecl(context, builder, prev_decl_id); + builder.Emit(); + continue; + } + } else if (rewrite_value.is_valid()) { + witness_value = context.constant_values().GetInstId(rewrite_value); + } + } + } +} + +auto ImplWitnessStartDefinition(Context& context, SemIR::Impl& impl) -> void { CARBON_CHECK(impl.is_being_defined()); - // TODO: Check we have a value for all non-function associated constants in - // the constraint, and fill the witness with them. + CARBON_CHECK(impl.witness_id.is_valid()); + if (impl.witness_id == SemIR::ErrorInst::SingletonInstId) { + return; + } + + auto facet_type_id = context.GetTypeIdForTypeInst(impl.constraint_id); + CARBON_CHECK(facet_type_id != SemIR::ErrorInst::SingletonTypeId); + auto facet_type = context.types().GetAs(facet_type_id); + const SemIR::FacetTypeInfo& facet_type_info = + context.facet_types().Get(facet_type.facet_type_id); + + auto interface_type = facet_type_info.TryAsSingleInterface(); + CARBON_CHECK(interface_type.has_value()); + const auto& interface = + context.interfaces().Get(interface_type->interface_id); + + auto witness = context.insts().GetAs(impl.witness_id); + auto witness_block = context.inst_blocks().GetMutable(witness.elements_id); + auto assoc_entities = + context.inst_blocks().Get(interface.associated_entities_id); + CARBON_CHECK(witness_block.size() == assoc_entities.size()); + + // Check we have a value for all non-function associated constants in the + // witness. + for (auto index : llvm::seq(assoc_entities.size())) { + auto decl_id = assoc_entities[index]; + decl_id = + context.constant_values().GetInstId(SemIR::GetConstantValueInSpecific( + context.sem_ir(), interface_type->specific_id, decl_id)); + CARBON_CHECK(decl_id.is_valid(), "Non-constant associated entity"); + if (auto decl = + context.insts().TryGetAs(decl_id)) { + auto& witness_value = witness_block[index]; + if (!witness_value.is_valid()) { + CARBON_DIAGNOSTIC(ImplAssociatedConstantNeedsValue, Error, + "associated constant {0} not given a value in impl " + "of interface {1}", + SemIR::NameId, SemIR::NameId); + CARBON_DIAGNOSTIC(AssociatedConstantHere, Note, + "associated constant {0} declared here", + SemIR::NameId); + context.emitter() + .Build(impl.constraint_id, ImplAssociatedConstantNeedsValue, + decl->name_id, interface.name_id) + .Note(assoc_entities[index], AssociatedConstantHere, decl->name_id) + .Emit(); + + witness_value = SemIR::ErrorInst::SingletonInstId; + } + } + } } // Adds functions to the witness that the specified impl implements the given // interface. auto FinishImplWitness(Context& context, SemIR::Impl& impl) -> void { CARBON_CHECK(impl.is_being_defined()); + CARBON_CHECK(impl.witness_id.is_valid()); if (impl.witness_id == SemIR::ErrorInst::SingletonInstId) { return; } @@ -271,17 +428,21 @@ auto FinishImplWitness(Context& context, SemIR::Impl& impl) -> void { CARBON_KIND_SWITCH(decl) { case CARBON_KIND(SemIR::StructValue struct_value): { if (struct_value.type_id == SemIR::ErrorInst::SingletonTypeId) { + witness_block[index] = SemIR::ErrorInst::SingletonInstId; break; } auto type_inst = context.types().GetAsInst(struct_value.type_id); - auto fn_type = type_inst.As(); - auto& fn = context.functions().Get(fn_type.function_id); + auto fn_type = type_inst.TryAs(); + if (!fn_type) { + CARBON_FATAL("Unexpected type: {0}", type_inst); + } + auto& fn = context.functions().Get(fn_type->function_id); auto [impl_decl_id, _, is_poisoned] = context.LookupNameInExactScope( decl_id, fn.name_id, impl.scope_id, impl_scope); if (impl_decl_id.is_valid()) { used_decl_ids.push_back(impl_decl_id); witness_block[index] = CheckAssociatedFunctionImplementation( - context, fn_type, impl_decl_id, self_type_id, impl.witness_id); + context, *fn_type, impl_decl_id, self_type_id, impl.witness_id); } else { CARBON_DIAGNOSTIC( ImplMissingFunction, Error, @@ -290,7 +451,7 @@ auto FinishImplWitness(Context& context, SemIR::Impl& impl) -> void { auto builder = context.emitter().Build(impl.definition_id, ImplMissingFunction, fn.name_id, interface.name_id); - NoteAssociatedFunction(context, builder, fn_type.function_id); + NoteAssociatedFunction(context, builder, fn_type->function_id); builder.Emit(); witness_block[index] = SemIR::ErrorInst::SingletonInstId; @@ -304,7 +465,7 @@ auto FinishImplWitness(Context& context, SemIR::Impl& impl) -> void { default: CARBON_CHECK(decl_id == SemIR::ErrorInst::SingletonInstId, "Unexpected kind of associated entity {0}", decl); - // These are set to their final values already. + witness_block[index] = SemIR::ErrorInst::SingletonInstId; break; } } diff --git a/toolchain/check/impl.h b/toolchain/check/impl.h index f225f6f565c3a..daf84dbbda2a1 100644 --- a/toolchain/check/impl.h +++ b/toolchain/check/impl.h @@ -14,7 +14,11 @@ namespace Carbon::Check { auto ImplWitnessForDeclaration(Context& context, const SemIR::Impl& impl) -> SemIR::InstId; -// TODO: AddConstantsToImplWitnessFromConstraint() +auto AddConstantsToImplWitnessFromConstraint(Context& context, + const SemIR::Impl& impl, + SemIR::InstId witness_id, + SemIR::ImplId prev_decl_id) + -> void; // Update `impl`'s witness at the start of a definition. auto ImplWitnessStartDefinition(Context& context, SemIR::Impl& impl) -> void; 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 f5bb22e027019..19d464b385a1b 100644 --- a/toolchain/check/testdata/impl/fail_extend_impl_type_as.carbon +++ b/toolchain/check/testdata/impl/fail_extend_impl_type_as.carbon @@ -37,7 +37,7 @@ class E { // CHECK:STDERR: extend impl Self as I {} // CHECK:STDERR: ^~~~ // CHECK:STDERR: - // CHECK:STDERR: fail_extend_impl_type_as.carbon:[[@LINE-11]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_extend_impl_type_as.carbon:[[@LINE-11]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: extend impl D as I; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ extend impl Self as I {} diff --git a/toolchain/check/testdata/impl/fail_extend_non_interface.carbon b/toolchain/check/testdata/impl/fail_extend_non_interface.carbon index ca98467f25eb3..f114c053c86a9 100644 --- a/toolchain/check/testdata/impl/fail_extend_non_interface.carbon +++ b/toolchain/check/testdata/impl/fail_extend_non_interface.carbon @@ -17,7 +17,7 @@ class C { // CHECK:STDERR: extend impl as i32; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: - // CHECK:STDERR: fail_extend_non_interface.carbon:[[@LINE+3]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_extend_non_interface.carbon:[[@LINE+3]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: extend impl as i32; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ extend impl as i32; 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 4e93960bab425..5f056541d062d 100644 --- a/toolchain/check/testdata/impl/fail_extend_partially_defined_interface.carbon +++ b/toolchain/check/testdata/impl/fail_extend_partially_defined_interface.carbon @@ -17,7 +17,7 @@ interface I { // CHECK:STDERR: interface I { // CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: - // CHECK:STDERR: fail_extend_partially_defined_interface.carbon:[[@LINE+3]]:5: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_extend_partially_defined_interface.carbon:[[@LINE+3]]:5: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: extend impl as I; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ extend impl as I; diff --git a/toolchain/check/testdata/impl/fail_extend_undefined_interface.carbon b/toolchain/check/testdata/impl/fail_extend_undefined_interface.carbon index babf9ea582fb4..84595d9cbdab5 100644 --- a/toolchain/check/testdata/impl/fail_extend_undefined_interface.carbon +++ b/toolchain/check/testdata/impl/fail_extend_undefined_interface.carbon @@ -43,7 +43,7 @@ fn F(c: C) { // 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 [MissingImplDefinition] + // 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: ^~~~~~~~~~~~~~~~~ c.F(); diff --git a/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon b/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon index 24b1c49b43666..d92a1d78a5f2f 100644 --- a/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon +++ b/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon @@ -14,7 +14,7 @@ class NoF { // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE+7]]:3: error: missing implementation of F in impl of interface I [ImplMissingFunction] // CHECK:STDERR: impl as I {} // CHECK:STDERR: ^~~~~~~~~~~ - // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE-6]]:15: note: associated function F declared here [ImplAssociatedFunctionHere] + // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE-6]]:15: note: associated function F declared here [AssociatedFunctionHere] // CHECK:STDERR: interface I { fn F(); } // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: @@ -26,7 +26,7 @@ class FNotFunction { // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE+7]]:5: error: associated function F implemented by non-function [ImplFunctionWithNonFunction] // CHECK:STDERR: class F; // CHECK:STDERR: ^~~~~~~~ - // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE-18]]:15: note: associated function F declared here [ImplAssociatedFunctionHere] + // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE-18]]:15: note: associated function F declared here [AssociatedFunctionHere] // CHECK:STDERR: interface I { fn F(); } // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: @@ -42,7 +42,7 @@ class FAlias { // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE+7]]:11: error: associated function F implemented by non-function [ImplFunctionWithNonFunction] // CHECK:STDERR: alias F = PossiblyF; // CHECK:STDERR: ^ - // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE-34]]:15: note: associated function F declared here [ImplAssociatedFunctionHere] + // CHECK:STDERR: fail_impl_bad_assoc_fn.carbon:[[@LINE-34]]:15: note: associated function F declared here [AssociatedFunctionHere] // CHECK:STDERR: interface I { fn F(); } // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: diff --git a/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon b/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon deleted file mode 100644 index e5ccef2753c21..0000000000000 --- a/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon +++ /dev/null @@ -1,82 +0,0 @@ -// 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 -// -// AUTOUPDATE -// TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon -// TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon - -interface I { let T:! type; } - -// CHECK:STDERR: fail_todo_impl_assoc_const.carbon:[[@LINE+3]]:1: error: semantics TODO: `impl of interface with associated constant T` [SemanticsTodo] -// CHECK:STDERR: impl bool as I where .T = bool {} -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -impl bool as I where .T = bool {} - -// CHECK:STDOUT: --- fail_todo_impl_assoc_const.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %I.type: type = facet_type <@I> [template] -// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] -// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %I.type, type [template] -// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @I.%T [template] -// CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template] -// CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template] -// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic] -// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] -// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] -// CHECK:STDOUT: %I_where.type: type = facet_type <@I where %impl.elem0 = bool> [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { -// CHECK:STDOUT: .Bool = %import_ref -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// 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 [template = constants.%I.type] {} {} -// CHECK:STDOUT: impl_decl @impl [template] {} { -// CHECK:STDOUT: %bool.make_type.loc16_6: init type = call constants.%Bool() [template = bool] -// CHECK:STDOUT: %.loc16_6.1: type = value_of_initializer %bool.make_type.loc16_6 [template = bool] -// CHECK:STDOUT: %.loc16_6.2: type = converted %bool.make_type.loc16_6, %.loc16_6.1 [template = bool] -// CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type] -// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic = constants.%.Self] -// CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self [symbolic = constants.%.Self] -// CHECK:STDOUT: %T.ref: %assoc_type = name_ref T, @I.%assoc0 [template = constants.%assoc0] -// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self.ref [symbolic = constants.%.Self.as_wit] -// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic = constants.%impl.elem0] -// CHECK:STDOUT: %bool.make_type.loc16_27: init type = call constants.%Bool() [template = bool] -// CHECK:STDOUT: %.loc16_27.1: type = value_of_initializer %bool.make_type.loc16_27 [template = bool] -// CHECK:STDOUT: %.loc16_27.2: type = converted %bool.make_type.loc16_27, %.loc16_27.1 [template = bool] -// CHECK:STDOUT: %.loc16_16: type = where_expr %.Self [template = constants.%I_where.type] { -// CHECK:STDOUT: requirement_rewrite %impl.elem0, %.loc16_27.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 [template] -// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %T [template = constants.%assoc0] -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: .T = %assoc0 -// CHECK:STDOUT: witness = (%T) -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: impl @impl: %.loc16_6.2 as %.loc16_16 { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: witness = -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/fail_todo_use_assoc_const.carbon b/toolchain/check/testdata/impl/fail_todo_use_assoc_const.carbon new file mode 100644 index 0000000000000..3d747e1e94df9 --- /dev/null +++ b/toolchain/check/testdata/impl/fail_todo_use_assoc_const.carbon @@ -0,0 +1,596 @@ +// 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 +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/fail_todo_use_assoc_const.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_todo_use_assoc_const.carbon + +// --- fail_todo_associated_type_in_signature.carbon +library "[[@TEST_NAME]]"; + +interface J { + let U:! type; + // CHECK:STDERR: fail_todo_associated_type_in_signature.carbon:[[@LINE+14]]:23: error: cannot implicitly convert from `` to `type` [ImplicitAsConversionFailure] + // CHECK:STDERR: fn F[self: Self](u: U) -> U; + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_todo_associated_type_in_signature.carbon:[[@LINE+11]]:23: note: type `` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote] + // CHECK:STDERR: fn F[self: Self](u: U) -> U; + // CHECK:STDERR: ^ + // CHECK:STDERR: + // CHECK:STDERR: fail_todo_associated_type_in_signature.carbon:[[@LINE+7]]:29: error: cannot implicitly convert from `` to `type` [ImplicitAsConversionFailure] + // CHECK:STDERR: fn F[self: Self](u: U) -> U; + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_todo_associated_type_in_signature.carbon:[[@LINE+4]]:29: note: type `` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote] + // CHECK:STDERR: fn F[self: Self](u: U) -> U; + // CHECK:STDERR: ^ + // CHECK:STDERR: + fn F[self: Self](u: U) -> U; +} + +impl () as J where .U = {} { + fn F[self: Self](u: {}) -> {} { return u; } +} + +class C { + // This allows the type to be copyable so it can be returned. + adapt {}; +} + +impl C as J where .U = C { + fn F[self: Self](u: C) -> C { return self; } +} + +// --- fail_todo_use_non-type_in_function.carbon +library "[[@TEST_NAME]]"; + +interface M { + let Z:! {.b: {}}; + fn G() -> {}; +} + +impl () as M where .Z = {.b = {}} { + fn G() -> {} { + // CHECK:STDERR: fail_todo_use_non-type_in_function.carbon:[[@LINE+7]]:13: error: cannot convert from `type` to `M` with `as` [ExplicitAsConversionFailure] + // CHECK:STDERR: return (Self as M).Z.b; + // CHECK:STDERR: ^~~~~~~~~ + // CHECK:STDERR: fail_todo_use_non-type_in_function.carbon:[[@LINE+4]]:13: note: type `type` does not implement interface `Core.As(M)` [MissingImplInMemberAccessNote] + // CHECK:STDERR: return (Self as M).Z.b; + // CHECK:STDERR: ^~~~~~~~~ + // CHECK:STDERR: + return (Self as M).Z.b; + } +} + +// --- fail_todo_associated_int_in_array.carbon +library "[[@TEST_NAME]]"; + +interface I { + let N:! i32; + // CHECK:STDERR: fail_todo_associated_int_in_array.carbon:[[@LINE+6]]:32: error: cannot implicitly convert from `` to `Core.IntLiteral` [ImplicitAsConversionFailure] + // CHECK:STDERR: fn F[self: Self]() -> [bool; N]; + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_todo_associated_int_in_array.carbon:[[@LINE+3]]:32: note: type `` does not implement interface `Core.ImplicitAs(Core.IntLiteral)` [MissingImplInMemberAccessNote] + // CHECK:STDERR: fn F[self: Self]() -> [bool; N]; + // CHECK:STDERR: ^ + fn F[self: Self]() -> [bool; N]; +} + +impl () as I where .N = 2 { + fn F[self: Self]() -> [bool; 2] { return (true, false); } +} + +// CHECK:STDOUT: --- fail_todo_associated_type_in_signature.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %J.type: type = facet_type <@J> [template] +// CHECK:STDOUT: %Self.ccd: %J.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %J.type, type [template] +// CHECK:STDOUT: %assoc0.021: %assoc_type = assoc_entity element0, @J.%U [template] +// CHECK:STDOUT: %Self.as_type.3df: type = facet_access_type %Self.ccd [symbolic] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %F.type.c14: type = fn_type @F.1 [template] +// CHECK:STDOUT: %F.b71: %F.type.c14 = struct_value () [template] +// CHECK:STDOUT: %F.assoc_type: type = assoc_entity_type %J.type, %F.type.c14 [template] +// CHECK:STDOUT: %assoc1: %F.assoc_type = assoc_entity element1, @J.%F.decl [template] +// CHECK:STDOUT: %.Self: %J.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] +// CHECK:STDOUT: %J_where.type.800: type = facet_type <@J where %impl.elem0 = %empty_struct_type> [template] +// CHECK:STDOUT: %impl_witness.f71: = impl_witness (%empty_struct_type, ) [template] +// CHECK:STDOUT: %F.type.159: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.59d: %F.type.159 = struct_value () [template] +// CHECK:STDOUT: %J.facet.550: %J.type = facet_value %empty_tuple.type, %impl_witness.f71 [template] +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template] +// CHECK:STDOUT: %J_where.type.2f6: type = facet_type <@J where %impl.elem0 = %C> [template] +// CHECK:STDOUT: %impl_witness.c2b: = impl_witness (%C, ) [template] +// CHECK:STDOUT: %F.type.01a: type = fn_type @F.3 [template] +// CHECK:STDOUT: %F.686: %F.type.01a = struct_value () [template] +// CHECK:STDOUT: %J.facet.38d: %J.type = facet_value %C, %impl_witness.c2b [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .ImplicitAs = %import_ref.d44 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/... +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .J = %J.decl +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %J.decl: type = interface_decl @J [template = constants.%J.type] {} {} +// CHECK:STDOUT: impl_decl @impl.1 [template] {} { +// CHECK:STDOUT: %.loc22_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc22_7.2: type = converted %.loc22_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [template = constants.%J.type] +// CHECK:STDOUT: %.Self: %J.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: %J.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %U.ref: %assoc_type = name_ref U, @J.%assoc0 [template = constants.%assoc0.021] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self.ref [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc22_26.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc22_26.2: type = converted %.loc22_26.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %.loc22_14: type = where_expr %.Self [template = constants.%J_where.type.800] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0, %.loc22_26.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness.loc22: = impl_witness (constants.%empty_struct_type, ) [template = constants.%impl_witness.f71] +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} +// CHECK:STDOUT: impl_decl @impl.2 [template] {} { +// CHECK:STDOUT: %C.ref.loc31_6: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [template = constants.%J.type] +// CHECK:STDOUT: %.Self: %J.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: %J.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %U.ref: %assoc_type = name_ref U, @J.%assoc0 [template = constants.%assoc0.021] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self.ref [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %C.ref.loc31_24: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %.loc31: type = where_expr %.Self [template = constants.%J_where.type.2f6] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0, %C.ref.loc31_24 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness.loc31: = impl_witness (constants.%C, ) [template = constants.%impl_witness.c2b] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @J { +// CHECK:STDOUT: %Self: %J.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.ccd] +// CHECK:STDOUT: %U: type = assoc_const_decl U [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %U [template = constants.%assoc0.021] +// CHECK:STDOUT: %F.decl: %F.type.c14 = fn_decl @F.1 [template = constants.%F.b71] { +// CHECK:STDOUT: %self.patt: @F.1.%Self.as_type.loc19_14.1 (%Self.as_type.3df) = binding_pattern self +// CHECK:STDOUT: %self.param_patt: @F.1.%Self.as_type.loc19_14.1 (%Self.as_type.3df) = value_param_pattern %self.patt, runtime_param0 +// CHECK:STDOUT: %u.patt: = binding_pattern u +// CHECK:STDOUT: %u.param_patt: = value_param_pattern %u.patt, runtime_param1 +// CHECK:STDOUT: %return.patt: = return_slot_pattern +// CHECK:STDOUT: %return.param_patt: = out_param_pattern %return.patt, runtime_param2 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %U.ref.loc19_29: %assoc_type = name_ref U, @J.%assoc0 [template = constants.%assoc0.021] +// CHECK:STDOUT: %.loc19_29: type = converted %U.ref.loc19_29, [template = ] +// CHECK:STDOUT: %self.param: @F.1.%Self.as_type.loc19_14.1 (%Self.as_type.3df) = value_param runtime_param0 +// CHECK:STDOUT: %.loc19_14.1: type = splice_block %.loc19_14.2 [symbolic = %Self.as_type.loc19_14.1 (constants.%Self.as_type.3df)] { +// CHECK:STDOUT: %Self.ref: %J.type = name_ref Self, @J.%Self [symbolic = %Self (constants.%Self.ccd)] +// CHECK:STDOUT: %Self.as_type.loc19_14.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc19_14.1 (constants.%Self.as_type.3df)] +// CHECK:STDOUT: %.loc19_14.2: type = converted %Self.ref, %Self.as_type.loc19_14.2 [symbolic = %Self.as_type.loc19_14.1 (constants.%Self.as_type.3df)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %self: @F.1.%Self.as_type.loc19_14.1 (%Self.as_type.3df) = bind_name self, %self.param +// CHECK:STDOUT: %u.param: = value_param runtime_param1 +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %U.ref.loc19_23: %assoc_type = name_ref U, @J.%assoc0 [template = constants.%assoc0.021] +// CHECK:STDOUT: %.loc19_23: type = converted %U.ref.loc19_23, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %u: = bind_name u, %u.param +// CHECK:STDOUT: %return.param: ref = out_param runtime_param2 +// CHECK:STDOUT: %return: ref = return_slot %return.param +// CHECK:STDOUT: } +// CHECK:STDOUT: %assoc1: %F.assoc_type = assoc_entity element1, %F.decl [template = constants.%assoc1] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .U = %assoc0 +// CHECK:STDOUT: .F = %assoc1 +// CHECK:STDOUT: witness = (%U, %F.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.1: %.loc22_7.2 as %.loc22_14 { +// CHECK:STDOUT: %F.decl: %F.type.159 = fn_decl @F.2 [template = constants.%F.59d] { +// CHECK:STDOUT: %self.patt: %empty_tuple.type = binding_pattern self +// CHECK:STDOUT: %self.param_patt: %empty_tuple.type = value_param_pattern %self.patt, runtime_param0 +// CHECK:STDOUT: %u.patt: %empty_struct_type = binding_pattern u +// CHECK:STDOUT: %u.param_patt: %empty_struct_type = value_param_pattern %u.patt, runtime_param1 +// CHECK:STDOUT: %return.patt: %empty_struct_type = return_slot_pattern +// CHECK:STDOUT: %return.param_patt: %empty_struct_type = out_param_pattern %return.patt, runtime_param2 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %.loc23_31.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc23_31.2: type = converted %.loc23_31.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %self.param: %empty_tuple.type = value_param runtime_param0 +// CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.1.%.loc22_7.2 [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %self: %empty_tuple.type = bind_name self, %self.param +// CHECK:STDOUT: %u.param: %empty_struct_type = value_param runtime_param1 +// CHECK:STDOUT: %.loc23_24.1: type = splice_block %.loc23_24.3 [template = constants.%empty_struct_type] { +// CHECK:STDOUT: %.loc23_24.2: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc23_24.3: type = converted %.loc23_24.2, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %u: %empty_struct_type = bind_name u, %u.param +// CHECK:STDOUT: %return.param: ref %empty_struct_type = out_param runtime_param2 +// CHECK:STDOUT: %return: ref %empty_struct_type = return_slot %return.param +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: witness = file.%impl_witness.loc22 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.2: %C.ref.loc31_6 as %.loc31 { +// CHECK:STDOUT: %F.decl: %F.type.01a = fn_decl @F.3 [template = constants.%F.686] { +// CHECK:STDOUT: %self.patt: %C = binding_pattern self +// CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, runtime_param0 +// CHECK:STDOUT: %u.patt: %C = binding_pattern u +// CHECK:STDOUT: %u.param_patt: %C = value_param_pattern %u.patt, runtime_param1 +// CHECK:STDOUT: %return.patt: %C = return_slot_pattern +// CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param2 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %C.ref.loc32_29: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %self.param: %C = value_param runtime_param0 +// CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.2.%C.ref.loc31_6 [template = constants.%C] +// CHECK:STDOUT: %self: %C = bind_name self, %self.param +// CHECK:STDOUT: %u.param: %C = value_param runtime_param1 +// CHECK:STDOUT: %C.ref.loc32_23: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %u: %C = bind_name u, %u.param +// CHECK:STDOUT: %return.param: ref %C = out_param runtime_param2 +// CHECK:STDOUT: %return: ref %C = return_slot %return.param +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: witness = file.%impl_witness.loc31 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: %.loc28_10: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc28_11: type = converted %.loc28_10, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: adapt_decl %.loc28_11 [template] +// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template = constants.%complete_type] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: complete_type_witness = %complete_type +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.1(@J.%Self: %J.type) { +// CHECK:STDOUT: %Self: %J.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.ccd)] +// CHECK:STDOUT: %Self.as_type.loc19_14.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc19_14.1 (constants.%Self.as_type.3df)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self.param_patt: @F.1.%Self.as_type.loc19_14.1 (%Self.as_type.3df)](%u.param_patt: ) -> ; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.2[%self.param_patt: %empty_tuple.type](%u.param_patt: %empty_struct_type) -> %empty_struct_type { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %u.ref: %empty_struct_type = name_ref u, %u +// CHECK:STDOUT: return %u.ref +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.3[%self.param_patt: %C](%u.param_patt: %C) -> %C { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %self.ref: %C = name_ref self, %self +// CHECK:STDOUT: return %self.ref +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self.ccd) { +// CHECK:STDOUT: %Self => constants.%Self.ccd +// CHECK:STDOUT: %Self.as_type.loc19_14.1 => constants.%Self.as_type.3df +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%J.facet.550) { +// CHECK:STDOUT: %Self => constants.%J.facet.550 +// CHECK:STDOUT: %Self.as_type.loc19_14.1 => constants.%empty_tuple.type +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%J.facet.38d) { +// CHECK:STDOUT: %Self => constants.%J.facet.38d +// CHECK:STDOUT: %Self.as_type.loc19_14.1 => constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_use_non-type_in_function.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %M.type: type = facet_type <@M> [template] +// CHECK:STDOUT: %Self.bcc: %M.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] +// CHECK:STDOUT: %struct_type.b.347: type = struct_type {.b: %empty_struct_type} [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %M.type, %struct_type.b.347 [template] +// CHECK:STDOUT: %assoc0.fbc: %assoc_type = assoc_entity element0, @M.%Z [template] +// CHECK:STDOUT: %G.type.020: type = fn_type @G.1 [template] +// CHECK:STDOUT: %G.91c: %G.type.020 = struct_value () [template] +// CHECK:STDOUT: %G.assoc_type: type = assoc_entity_type %M.type, %G.type.020 [template] +// CHECK:STDOUT: %assoc1: %G.assoc_type = assoc_entity element1, @M.%G.decl [template] +// CHECK:STDOUT: %.Self: %M.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: %struct_type.b.347 = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [template] +// CHECK:STDOUT: %struct: %struct_type.b.347 = struct_value (%empty_struct) [template] +// CHECK:STDOUT: %M_where.type: type = facet_type <@M where %impl.elem0 = %struct> [template] +// CHECK:STDOUT: %impl_witness: = impl_witness (%struct, @impl.%G.decl) [template] +// CHECK:STDOUT: %G.type.aa2: type = fn_type @G.2 [template] +// CHECK:STDOUT: %G.816: %G.type.aa2 = struct_value () [template] +// CHECK:STDOUT: %M.facet: %M.type = facet_value %empty_tuple.type, %impl_witness [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .As = %import_ref.16b +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/... +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .M = %M.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %M.decl: type = interface_decl @M [template = constants.%M.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc8_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc8_7.2: type = converted %.loc8_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %M.ref: type = name_ref M, file.%M.decl [template = constants.%M.type] +// CHECK:STDOUT: %.Self: %M.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: %M.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %Z.ref: %assoc_type = name_ref Z, @M.%assoc0 [template = constants.%assoc0.fbc] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self.ref [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0: %struct_type.b.347 = impl_witness_access %.Self.as_wit, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc8_32: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc8_33.1: %struct_type.b.347 = struct_literal (%.loc8_32) +// CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [template = constants.%empty_struct] +// CHECK:STDOUT: %.loc8_33.2: %empty_struct_type = converted %.loc8_32, %empty_struct [template = constants.%empty_struct] +// CHECK:STDOUT: %struct: %struct_type.b.347 = struct_value (%.loc8_33.2) [template = constants.%struct] +// CHECK:STDOUT: %.loc8_33.3: %struct_type.b.347 = converted %.loc8_33.1, %struct [template = constants.%struct] +// CHECK:STDOUT: %.loc8_14: type = where_expr %.Self [template = constants.%M_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0, %.loc8_33.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%struct, @impl.%G.decl) [template = constants.%impl_witness] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @M { +// CHECK:STDOUT: %Self: %M.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.bcc] +// CHECK:STDOUT: %Z: %struct_type.b.347 = assoc_const_decl Z [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %Z [template = constants.%assoc0.fbc] +// CHECK:STDOUT: %G.decl: %G.type.020 = fn_decl @G.1 [template = constants.%G.91c] { +// CHECK:STDOUT: %return.patt: %empty_struct_type = return_slot_pattern +// CHECK:STDOUT: %return.param_patt: %empty_struct_type = out_param_pattern %return.patt, runtime_param0 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %.loc5_14.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc5_14.2: type = converted %.loc5_14.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %return.param: ref %empty_struct_type = out_param runtime_param0 +// CHECK:STDOUT: %return: ref %empty_struct_type = return_slot %return.param +// CHECK:STDOUT: } +// CHECK:STDOUT: %assoc1: %G.assoc_type = assoc_entity element1, %G.decl [template = constants.%assoc1] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .Z = %assoc0 +// CHECK:STDOUT: .G = %assoc1 +// CHECK:STDOUT: witness = (%Z, %G.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc8_7.2 as %.loc8_14 { +// CHECK:STDOUT: %G.decl: %G.type.aa2 = fn_decl @G.2 [template = constants.%G.816] { +// CHECK:STDOUT: %return.patt: %empty_struct_type = return_slot_pattern +// CHECK:STDOUT: %return.param_patt: %empty_struct_type = out_param_pattern %return.patt, runtime_param0 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %.loc9_14.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_14.2: type = converted %.loc9_14.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %return.param: ref %empty_struct_type = out_param runtime_param0 +// CHECK:STDOUT: %return: ref %empty_struct_type = return_slot %return.param +// CHECK:STDOUT: } +// 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(@M.%Self: %M.type) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> %empty_struct_type; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @G.2() -> %empty_struct_type { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.%.loc8_7.2 [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %M.ref: type = name_ref M, file.%M.decl [template = constants.%M.type] +// CHECK:STDOUT: %.loc17: %M.type = converted %Self.ref, [template = ] +// CHECK:STDOUT: %Z.ref: = name_ref Z, [template = ] +// CHECK:STDOUT: %b.ref: = name_ref b, [template = ] +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G.1(constants.%Self.bcc) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G.1(constants.%M.facet) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_associated_int_in_array.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [template] +// CHECK:STDOUT: %Self.826: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %I.type, %i32 [template] +// CHECK:STDOUT: %assoc0.9f1: %assoc_type = assoc_entity element0, @I.%N [template] +// CHECK:STDOUT: %Self.as_type.b70: type = facet_access_type %Self.826 [symbolic] +// CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template] +// CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template] +// CHECK:STDOUT: %F.type.cf0: type = fn_type @F.1 [template] +// CHECK:STDOUT: %F.bc6: %F.type.cf0 = struct_value () [template] +// CHECK:STDOUT: %F.assoc_type: type = assoc_entity_type %I.type, %F.type.cf0 [template] +// CHECK:STDOUT: %assoc1: %F.assoc_type = assoc_entity element1, @I.%F.decl [template] +// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: %i32 = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] +// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] +// CHECK:STDOUT: %impl_witness.d39: = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound: = bound_method %int_2.ecc, %Convert.956 [template] +// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(%int_32) [template] +// CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [template] +// CHECK:STDOUT: %I_where.type: type = facet_type <@I where %impl.elem0 = %int_2.ef8> [template] +// CHECK:STDOUT: %impl_witness.2c9: = impl_witness (%int_2.ef8, ) [template] +// CHECK:STDOUT: %array_type: type = array_type %int_2.ecc, bool [template] +// CHECK:STDOUT: %F.type.9f6: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.572: %F.type.9f6 = struct_value () [template] +// CHECK:STDOUT: %I.facet: %I.type = facet_value %empty_tuple.type, %impl_witness.2c9 [template] +// CHECK:STDOUT: %true: bool = bool_literal true [template] +// CHECK:STDOUT: %false: bool = bool_literal false [template] +// CHECK:STDOUT: %tuple.type: type = tuple_type (bool, bool) [template] +// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %array: %array_type = tuple_value (%true, %false) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int = %import_ref.485 +// CHECK:STDOUT: .Bool = %import_ref.783 +// CHECK:STDOUT: .ImplicitAs = %import_ref.d44 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/... +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// 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 [template = constants.%I.type] {} {} +// CHECK:STDOUT: impl_decl @impl.44 [template] {} { +// CHECK:STDOUT: %.loc14_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc14_7.2: type = converted %.loc14_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type] +// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %N.ref: %assoc_type = name_ref N, @I.%assoc0 [template = constants.%assoc0.9f1] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self.ref [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc14_20: %i32 = impl_witness_access %.Self.as_wit, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %impl.elem0.loc14_25: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound: = bound_method %int_2, %impl.elem0.loc14_25 [template = constants.%Convert.bound] +// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_2) [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc14_25.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc14_25.2: %i32 = converted %int_2, %.loc14_25.1 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc14_14: type = where_expr %.Self [template = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc14_20, %.loc14_25.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%int_2.ef8, ) [template = constants.%impl_witness.2c9] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.826] +// CHECK:STDOUT: %N: %i32 = assoc_const_decl N [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %N [template = constants.%assoc0.9f1] +// CHECK:STDOUT: %F.decl: %F.type.cf0 = fn_decl @F.1 [template = constants.%F.bc6] { +// CHECK:STDOUT: %self.patt: @F.1.%Self.as_type.loc11_14.1 (%Self.as_type.b70) = binding_pattern self +// CHECK:STDOUT: %self.param_patt: @F.1.%Self.as_type.loc11_14.1 (%Self.as_type.b70) = value_param_pattern %self.patt, runtime_param0 +// CHECK:STDOUT: %return.patt: = return_slot_pattern +// CHECK:STDOUT: %return.param_patt: = out_param_pattern %return.patt, runtime_param1 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %N.ref: %assoc_type = name_ref N, @I.%assoc0 [template = constants.%assoc0.9f1] +// CHECK:STDOUT: %.loc11_26.1: type = value_of_initializer %bool.make_type [template = bool] +// CHECK:STDOUT: %.loc11_26.2: type = converted %bool.make_type, %.loc11_26.1 [template = bool] +// CHECK:STDOUT: %.loc11_32: Core.IntLiteral = converted %N.ref, [template = ] +// CHECK:STDOUT: %array_type: type = array_type , bool [template = ] +// CHECK:STDOUT: %self.param: @F.1.%Self.as_type.loc11_14.1 (%Self.as_type.b70) = value_param runtime_param0 +// CHECK:STDOUT: %.loc11_14.1: type = splice_block %.loc11_14.2 [symbolic = %Self.as_type.loc11_14.1 (constants.%Self.as_type.b70)] { +// CHECK:STDOUT: %Self.ref: %I.type = name_ref Self, @I.%Self [symbolic = %Self (constants.%Self.826)] +// CHECK:STDOUT: %Self.as_type.loc11_14.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc11_14.1 (constants.%Self.as_type.b70)] +// CHECK:STDOUT: %.loc11_14.2: type = converted %Self.ref, %Self.as_type.loc11_14.2 [symbolic = %Self.as_type.loc11_14.1 (constants.%Self.as_type.b70)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %self: @F.1.%Self.as_type.loc11_14.1 (%Self.as_type.b70) = bind_name self, %self.param +// CHECK:STDOUT: %return.param: ref = out_param runtime_param1 +// CHECK:STDOUT: %return: ref = return_slot %return.param +// CHECK:STDOUT: } +// CHECK:STDOUT: %assoc1: %F.assoc_type = assoc_entity element1, %F.decl [template = constants.%assoc1] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .N = %assoc0 +// CHECK:STDOUT: .F = %assoc1 +// CHECK:STDOUT: witness = (%N, %F.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.44: %.loc14_7.2 as %.loc14_14 { +// CHECK:STDOUT: %F.decl: %F.type.9f6 = fn_decl @F.2 [template = constants.%F.572] { +// CHECK:STDOUT: %self.patt: %empty_tuple.type = binding_pattern self +// CHECK:STDOUT: %self.param_patt: %empty_tuple.type = value_param_pattern %self.patt, runtime_param0 +// CHECK:STDOUT: %return.patt: %array_type = return_slot_pattern +// CHECK:STDOUT: %return.param_patt: %array_type = out_param_pattern %return.patt, runtime_param1 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc15_26.1: type = value_of_initializer %bool.make_type [template = bool] +// CHECK:STDOUT: %.loc15_26.2: type = converted %bool.make_type, %.loc15_26.1 [template = bool] +// CHECK:STDOUT: %array_type: type = array_type %int_2, bool [template = constants.%array_type] +// CHECK:STDOUT: %self.param: %empty_tuple.type = value_param runtime_param0 +// CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.44.%.loc14_7.2 [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %self: %empty_tuple.type = bind_name self, %self.param +// CHECK:STDOUT: %return.param: ref %array_type = out_param runtime_param1 +// CHECK:STDOUT: %return: ref %array_type = return_slot %return.param +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.1(@I.%Self: %I.type) { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.826)] +// CHECK:STDOUT: %Self.as_type.loc11_14.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc11_14.1 (constants.%Self.as_type.b70)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self.param_patt: @F.1.%Self.as_type.loc11_14.1 (%Self.as_type.b70)]() -> ; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.2[%self.param_patt: %empty_tuple.type]() -> %return.param_patt: %array_type { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %false: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %.loc15_56.1: %tuple.type = tuple_literal (%true, %false) +// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] +// CHECK:STDOUT: %.loc15_56.2: ref bool = array_index %return, %int_0 +// CHECK:STDOUT: %.loc15_56.3: init bool = initialize_from %true to %.loc15_56.2 [template = constants.%true] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %.loc15_56.4: ref bool = array_index %return, %int_1 +// CHECK:STDOUT: %.loc15_56.5: init bool = initialize_from %false to %.loc15_56.4 [template = constants.%false] +// CHECK:STDOUT: %.loc15_56.6: init %array_type = array_init (%.loc15_56.3, %.loc15_56.5) to %return [template = constants.%array] +// CHECK:STDOUT: %.loc15_57: init %array_type = converted %.loc15_56.1, %.loc15_56.6 [template = constants.%array] +// CHECK:STDOUT: return %.loc15_57 to %return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self.826) { +// CHECK:STDOUT: %Self => constants.%Self.826 +// CHECK:STDOUT: %Self.as_type.loc11_14.1 => constants.%Self.as_type.b70 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%I.facet) { +// CHECK:STDOUT: %Self => constants.%I.facet +// CHECK:STDOUT: %Self.as_type.loc11_14.1 => constants.%empty_tuple.type +// 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 a87eecef4d36f..fb2fe94afe123 100644 --- a/toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon +++ b/toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon @@ -23,7 +23,7 @@ fn F() -> i32 { // CHECK:STDERR: return C.F(); // CHECK:STDERR: ^~~ // CHECK:STDERR: - // CHECK:STDERR: fail_todo_undefined_impl.carbon:[[@LINE-8]]:3: error: impl declared but not defined [MissingImplDefinition] + // 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: ^~~~~~~~~~~~~~~~~ return C.F(); diff --git a/toolchain/check/testdata/impl/fail_impl_bad_assoc_const.carbon b/toolchain/check/testdata/impl/no_prelude/fail_impl_bad_assoc_const.carbon similarity index 58% rename from toolchain/check/testdata/impl/fail_impl_bad_assoc_const.carbon rename to toolchain/check/testdata/impl/no_prelude/fail_impl_bad_assoc_const.carbon index 05d2618df9e28..40a92776d1a76 100644 --- a/toolchain/check/testdata/impl/fail_impl_bad_assoc_const.carbon +++ b/toolchain/check/testdata/impl/no_prelude/fail_impl_bad_assoc_const.carbon @@ -4,16 +4,19 @@ // // AUTOUPDATE // TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/fail_impl_bad_assoc_const.carbon +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/no_prelude/fail_impl_bad_assoc_const.carbon // TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_impl_bad_assoc_const.carbon +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/no_prelude/fail_impl_bad_assoc_const.carbon interface I { let T:! type; } -// CHECK:STDERR: fail_impl_bad_assoc_const.carbon:[[@LINE+3]]:1: error: semantics TODO: `impl of interface with associated constant T` [SemanticsTodo] -// CHECK:STDERR: impl bool as I {} -// CHECK:STDERR: ^~~~~~~~~~~~~~~~ -impl bool as I {} +// CHECK:STDERR: fail_impl_bad_assoc_const.carbon:[[@LINE+6]]:12: error: associated constant T not given a value in impl of interface I [ImplAssociatedConstantNeedsValue] +// CHECK:STDERR: impl () as I {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_impl_bad_assoc_const.carbon:[[@LINE-5]]:15: note: associated constant T declared here [AssociatedConstantHere] +// CHECK:STDERR: interface I { let T:! type; } +// CHECK:STDERR: ^~~~~~~~~~~~~ +impl () as I {} // CHECK:STDOUT: --- fail_impl_bad_assoc_const.carbon // CHECK:STDOUT: @@ -22,31 +25,21 @@ impl bool as I {} // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] // CHECK:STDOUT: %assoc_type: type = assoc_entity_type %I.type, type [template] // CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @I.%T [template] -// CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template] -// CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { -// CHECK:STDOUT: .Bool = %import_ref -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %impl_witness: = impl_witness () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// 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 [template = constants.%I.type] {} {} // CHECK:STDOUT: impl_decl @impl [template] {} { -// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] -// CHECK:STDOUT: %.loc16_6.1: type = value_of_initializer %bool.make_type [template = bool] -// CHECK:STDOUT: %.loc16_6.2: type = converted %bool.make_type, %.loc16_6.1 [template = bool] +// CHECK:STDOUT: %.loc19_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc19_7.2: type = converted %.loc19_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type] // CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness () [template = constants.%impl_witness] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: interface @I { @@ -60,8 +53,8 @@ impl bool as I {} // CHECK:STDOUT: witness = (%T) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @impl: %.loc16_6.2 as %I.ref { +// CHECK:STDOUT: impl @impl: %.loc19_7.2 as %I.ref { // CHECK:STDOUT: !members: -// CHECK:STDOUT: witness = +// CHECK:STDOUT: witness = file.%impl_witness // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/no_prelude/impl_assoc_const.carbon b/toolchain/check/testdata/impl/no_prelude/impl_assoc_const.carbon new file mode 100644 index 0000000000000..85327ab1b9d82 --- /dev/null +++ b/toolchain/check/testdata/impl/no_prelude/impl_assoc_const.carbon @@ -0,0 +1,937 @@ +// 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 +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/no_prelude/impl_assoc_const.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/no_prelude/impl_assoc_const.carbon + +// --- success.carbon +library "[[@TEST_NAME]]"; + +interface I { let T:! type; } + +impl () as I where .T = {} {} + +// --- redecl.carbon +library "[[@TEST_NAME]]"; + +interface I2 { let T2:! type; } + +impl () as I2 where .T2 = {}; +impl () as I2 where .T2 = {} {} + +// --- redecl_adds_rewrites.carbon +library "[[@TEST_NAME]]"; + +interface I3 { let T3:! type; } + +impl () as I3; +impl () as I3 where .T3 = {} {} + +// --- fail_mismatch.carbon +library "[[@TEST_NAME]]"; + +interface J { let U:! type; } + +impl () as J where .U = {}; +// CHECK:STDERR: fail_mismatch.carbon:[[@LINE+7]]:1: error: redeclaration with different value for associated constant U [AssociatedConstantDifferentInRedecl] +// CHECK:STDERR: impl () as J where .U = () {} +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_mismatch.carbon:[[@LINE-4]]:1: note: impl previously declared here [ImplPreviousDeclHere] +// CHECK:STDERR: impl () as J where .U = {}; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +impl () as J where .U = () {} + +// --- fail_mismatch_bad_value.carbon +library "[[@TEST_NAME]]"; + +interface I4 { + let T4:! type; + let T5:! type; + let T6:! type; +} + +// This is testing that it won't complain about mismatching values if one of +// them is an error. Note that both impl declarations must have facet types +// with errors in them or they won't match each other. + +// CHECK:STDERR: fail_mismatch_bad_value.carbon:[[@LINE+8]]:27: error: name `BAD1` not found [NameNotFound] +// CHECK:STDERR: impl () as I4 where .T4 = BAD1 and .T5 = {.a: {}} and .T6 = BAD2; +// CHECK:STDERR: ^~~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_mismatch_bad_value.carbon:[[@LINE+4]]:61: error: name `BAD2` not found [NameNotFound] +// CHECK:STDERR: impl () as I4 where .T4 = BAD1 and .T5 = {.a: {}} and .T6 = BAD2; +// CHECK:STDERR: ^~~~ +// CHECK:STDERR: +impl () as I4 where .T4 = BAD1 and .T5 = {.a: {}} and .T6 = BAD2; + +// CHECK:STDERR: fail_mismatch_bad_value.carbon:[[@LINE+8]]:46: error: name `BAD3` not found [NameNotFound] +// CHECK:STDERR: impl () as I4 where .T4 = {.b: {}} and .T5 = BAD3 and .T6 = BAD4 {} +// CHECK:STDERR: ^~~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_mismatch_bad_value.carbon:[[@LINE+4]]:61: error: name `BAD4` not found [NameNotFound] +// CHECK:STDERR: impl () as I4 where .T4 = {.b: {}} and .T5 = BAD3 and .T6 = BAD4 {} +// CHECK:STDERR: ^~~~ +// CHECK:STDERR: +impl () as I4 where .T4 = {.b: {}} and .T5 = BAD3 and .T6 = BAD4 {} + +// --- fail_missing_on_definition.carbon +library "[[@TEST_NAME]]"; + +interface K { let V:! type; } + +impl () as K where .V = {}; +// CHECK:STDERR: fail_missing_on_definition.carbon:[[@LINE+7]]:1: error: associated constant V given value in declaration but not redeclaration [AssociatedConstantMissingInRedecl] +// CHECK:STDERR: impl () as K {} +// CHECK:STDERR: ^~~~~~~~~~~~~~ +// CHECK:STDERR: fail_missing_on_definition.carbon:[[@LINE-4]]:1: note: impl previously declared here [ImplPreviousDeclHere] +// CHECK:STDERR: impl () as K where .V = {}; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +impl () as K {} + +// --- fail_two_different.carbon +library "[[@TEST_NAME]]"; + +interface L { let W:! type; } + +// CHECK:STDERR: fail_two_different.carbon:[[@LINE+4]]:12: error: associated constant W given two different values [AssociatedConstantWithDifferentValues] +// CHECK:STDERR: impl () as L where .W = {} and .W = () {} +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +impl () as L where .W = {} and .W = () {} + +// --- fail_two_different_first_bad.carbon +library "[[@TEST_NAME]]"; + +interface L2 { let W2:! type; } + +// CHECK:STDERR: fail_two_different_first_bad.carbon:[[@LINE+4]]:27: error: name `BAD5` not found [NameNotFound] +// CHECK:STDERR: impl () as L2 where .W2 = BAD5 and .W2 = () {} +// CHECK:STDERR: ^~~~ +// CHECK:STDERR: +impl () as L2 where .W2 = BAD5 and .W2 = () {} + +// --- fail_two_different_second_bad.carbon +library "[[@TEST_NAME]]"; + +interface L3 { let W3:! type; } + +// CHECK:STDERR: fail_two_different_second_bad.carbon:[[@LINE+4]]:40: error: name `BAD6` not found [NameNotFound] +// CHECK:STDERR: impl () as L3 where .W3 = {} and .W3 = BAD6 {} +// CHECK:STDERR: ^~~~ +// CHECK:STDERR: +impl () as L3 where .W3 = {} and .W3 = BAD6 {} + +// --- fail_two_different_both_bad.carbon +library "[[@TEST_NAME]]"; + +interface L4 { let W4:! type; } + +// CHECK:STDERR: fail_two_different_both_bad.carbon:[[@LINE+7]]:27: error: name `BAD7` not found [NameNotFound] +// CHECK:STDERR: impl () as L4 where .W4 = BAD7 and .W4 = BAD8 {} +// CHECK:STDERR: ^~~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_two_different_both_bad.carbon:[[@LINE+3]]:42: error: name `BAD8` not found [NameNotFound] +// CHECK:STDERR: impl () as L4 where .W4 = BAD7 and .W4 = BAD8 {} +// CHECK:STDERR: ^~~~ +impl () as L4 where .W4 = BAD7 and .W4 = BAD8 {} + +// --- repeated.carbon +library "[[@TEST_NAME]]"; + +interface M { let X:! type; } + +impl () as M where .X = {} and .X = {} {} + +// --- non-type.carbon +library "[[@TEST_NAME]]"; + +interface N { + let Y:! {.a: {}}; +} + +impl () as N where .Y = {.a = {}} { } + +// CHECK:STDOUT: --- success.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I.type: type = facet_type <@I> [template] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %I.type, type [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @I.%T [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] +// CHECK:STDOUT: %I_where.type: type = facet_type <@I where %impl.elem0 = %empty_struct_type> [template] +// CHECK:STDOUT: %impl_witness: = impl_witness (%empty_struct_type) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .I = %I.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc5_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc5_7.2: type = converted %.loc5_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type] +// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %T.ref: %assoc_type = name_ref T, @I.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self.ref [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc5_26.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc5_26.2: type = converted %.loc5_26.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %.loc5_14: type = where_expr %.Self [template = constants.%I_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0, %.loc5_26.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%empty_struct_type) [template = constants.%impl_witness] +// 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 [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %T [template = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .T = %assoc0 +// CHECK:STDOUT: witness = (%T) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc5_7.2 as %.loc5_14 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- redecl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I2.type: type = facet_type <@I2> [template] +// CHECK:STDOUT: %Self: %I2.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %I2.type, type [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @I2.%T2 [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %.Self: %I2.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] +// CHECK:STDOUT: %I2_where.type: type = facet_type <@I2 where %impl.elem0 = %empty_struct_type> [template] +// CHECK:STDOUT: %impl_witness: = impl_witness (%empty_struct_type) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .I2 = %I2.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %I2.decl: type = interface_decl @I2 [template = constants.%I2.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc5_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc5_7.2: type = converted %.loc5_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %I2.ref.loc5: type = name_ref I2, file.%I2.decl [template = constants.%I2.type] +// CHECK:STDOUT: %.Self.1: %I2.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc5: %I2.type = name_ref .Self, %.Self.1 [symbolic = constants.%.Self] +// CHECK:STDOUT: %T2.ref.loc5: %assoc_type = name_ref T2, @I2.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc5: = facet_access_witness %.Self.ref.loc5 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc5: type = impl_witness_access %.Self.as_wit.loc5, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc5_28.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc5_28.2: type = converted %.loc5_28.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %.loc5_15: type = where_expr %.Self.1 [template = constants.%I2_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc5, %.loc5_28.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%empty_struct_type) [template = constants.%impl_witness] +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc6_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_7.2: type = converted %.loc6_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %I2.ref.loc6: type = name_ref I2, file.%I2.decl [template = constants.%I2.type] +// CHECK:STDOUT: %.Self.2: %I2.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc6: %I2.type = name_ref .Self, %.Self.2 [symbolic = constants.%.Self] +// CHECK:STDOUT: %T2.ref.loc6: %assoc_type = name_ref T2, @I2.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc6: = facet_access_witness %.Self.ref.loc6 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc6: type = impl_witness_access %.Self.as_wit.loc6, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc6_28.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc6_28.2: type = converted %.loc6_28.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %.loc6_15: type = where_expr %.Self.2 [template = constants.%I2_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc6, %.loc6_28.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I2 { +// CHECK:STDOUT: %Self: %I2.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %T2: type = assoc_const_decl T2 [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %T2 [template = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .T2 = %assoc0 +// CHECK:STDOUT: witness = (%T2) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc5_7.2 as %.loc5_15 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- redecl_adds_rewrites.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I3.type: type = facet_type <@I3> [template] +// CHECK:STDOUT: %Self: %I3.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %I3.type, type [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @I3.%T3 [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %impl_witness: = impl_witness (%empty_struct_type) [template] +// CHECK:STDOUT: %.Self: %I3.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] +// CHECK:STDOUT: %I3_where.type: type = facet_type <@I3 where %impl.elem0 = %empty_struct_type> [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .I3 = %I3.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %I3.decl: type = interface_decl @I3 [template = constants.%I3.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc5_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc5_7.2: type = converted %.loc5_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %I3.ref.loc5: type = name_ref I3, file.%I3.decl [template = constants.%I3.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%empty_struct_type) [template = constants.%impl_witness] +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc6_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_7.2: type = converted %.loc6_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %I3.ref.loc6: type = name_ref I3, file.%I3.decl [template = constants.%I3.type] +// CHECK:STDOUT: %.Self: %I3.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: %I3.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %T3.ref: %assoc_type = name_ref T3, @I3.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self.ref [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc6_28.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc6_28.2: type = converted %.loc6_28.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %.loc6_15: type = where_expr %.Self [template = constants.%I3_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0, %.loc6_28.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I3 { +// CHECK:STDOUT: %Self: %I3.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %T3: type = assoc_const_decl T3 [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %T3 [template = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .T3 = %assoc0 +// CHECK:STDOUT: witness = (%T3) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc5_7.2 as %I3.ref.loc5 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_mismatch.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %J.type: type = facet_type <@J> [template] +// CHECK:STDOUT: %Self: %J.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %J.type, type [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @J.%U [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %.Self: %J.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] +// CHECK:STDOUT: %J_where.type.800: type = facet_type <@J where %impl.elem0 = %empty_struct_type> [template] +// CHECK:STDOUT: %impl_witness: = impl_witness (%empty_struct_type) [template] +// CHECK:STDOUT: %J_where.type.25a: type = facet_type <@J where %impl.elem0 = %empty_tuple.type> [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .J = %J.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %J.decl: type = interface_decl @J [template = constants.%J.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc5_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc5_7.2: type = converted %.loc5_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %J.ref.loc5: type = name_ref J, file.%J.decl [template = constants.%J.type] +// CHECK:STDOUT: %.Self.1: %J.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc5: %J.type = name_ref .Self, %.Self.1 [symbolic = constants.%.Self] +// CHECK:STDOUT: %U.ref.loc5: %assoc_type = name_ref U, @J.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc5: = facet_access_witness %.Self.ref.loc5 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc5: type = impl_witness_access %.Self.as_wit.loc5, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc5_26.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc5_26.2: type = converted %.loc5_26.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %.loc5_14: type = where_expr %.Self.1 [template = constants.%J_where.type.800] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc5, %.loc5_26.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%empty_struct_type) [template = constants.%impl_witness] +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc13_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_7.2: type = converted %.loc13_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %J.ref.loc13: type = name_ref J, file.%J.decl [template = constants.%J.type] +// CHECK:STDOUT: %.Self.2: %J.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc13: %J.type = name_ref .Self, %.Self.2 [symbolic = constants.%.Self] +// CHECK:STDOUT: %U.ref.loc13: %assoc_type = name_ref U, @J.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc13: = facet_access_witness %.Self.ref.loc13 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc13: type = impl_witness_access %.Self.as_wit.loc13, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc13_26.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_26.2: type = converted %.loc13_26.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc13_14: type = where_expr %.Self.2 [template = constants.%J_where.type.25a] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc13, %.loc13_26.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @J { +// CHECK:STDOUT: %Self: %J.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %U: type = assoc_const_decl U [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %U [template = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .U = %assoc0 +// CHECK:STDOUT: witness = (%U) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc5_7.2 as %.loc5_14 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_mismatch_bad_value.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %I4.type: type = facet_type <@I4> [template] +// CHECK:STDOUT: %Self: %I4.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %I4.type, type [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @I4.%T4 [template] +// CHECK:STDOUT: %assoc1: %assoc_type = assoc_entity element1, @I4.%T5 [template] +// CHECK:STDOUT: %assoc2: %assoc_type = assoc_entity element2, @I4.%T6 [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %.Self: %I4.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %impl.elem1: type = impl_witness_access %.Self.as_wit, element1 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %empty_struct_type} [template] +// CHECK:STDOUT: %impl.elem2: type = impl_witness_access %.Self.as_wit, element2 [symbolic] +// CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %empty_struct_type} [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .I4 = %I4.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %I4.decl: type = interface_decl @I4 [template = constants.%I4.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc21_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc21_7.2: type = converted %.loc21_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %I4.ref.loc21: type = name_ref I4, file.%I4.decl [template = constants.%I4.type] +// CHECK:STDOUT: %.Self.1: %I4.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc21_21: %I4.type = name_ref .Self, %.Self.1 [symbolic = constants.%.Self] +// CHECK:STDOUT: %T4.ref.loc21: %assoc_type = name_ref T4, @I4.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc21_21: = facet_access_witness %.Self.ref.loc21_21 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc21: type = impl_witness_access %.Self.as_wit.loc21_21, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %BAD1.ref: = name_ref BAD1, [template = ] +// CHECK:STDOUT: %.Self.ref.loc21_36: %I4.type = name_ref .Self, %.Self.1 [symbolic = constants.%.Self] +// CHECK:STDOUT: %T5.ref.loc21: %assoc_type = name_ref T5, @I4.%assoc1 [template = constants.%assoc1] +// CHECK:STDOUT: %.Self.as_wit.loc21_36: = facet_access_witness %.Self.ref.loc21_36 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem1.loc21: type = impl_witness_access %.Self.as_wit.loc21_36, element1 [symbolic = constants.%impl.elem1] +// CHECK:STDOUT: %.loc21_48.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc21_48.2: type = converted %.loc21_48.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %empty_struct_type} [template = constants.%struct_type.a] +// CHECK:STDOUT: %.Self.ref.loc21_55: %I4.type = name_ref .Self, %.Self.1 [symbolic = constants.%.Self] +// CHECK:STDOUT: %T6.ref.loc21: %assoc_type = name_ref T6, @I4.%assoc2 [template = constants.%assoc2] +// CHECK:STDOUT: %.Self.as_wit.loc21_55: = facet_access_witness %.Self.ref.loc21_55 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem2.loc21: type = impl_witness_access %.Self.as_wit.loc21_55, element2 [symbolic = constants.%impl.elem2] +// CHECK:STDOUT: %BAD2.ref: = name_ref BAD2, [template = ] +// CHECK:STDOUT: %.loc21_15: type = where_expr %.Self.1 [template = ] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc21, +// CHECK:STDOUT: requirement_rewrite %impl.elem1.loc21, %struct_type.a +// CHECK:STDOUT: requirement_rewrite %impl.elem2.loc21, +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc31_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc31_7.2: type = converted %.loc31_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %I4.ref.loc31: type = name_ref I4, file.%I4.decl [template = constants.%I4.type] +// CHECK:STDOUT: %.Self.2: %I4.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc31_21: %I4.type = name_ref .Self, %.Self.2 [symbolic = constants.%.Self] +// CHECK:STDOUT: %T4.ref.loc31: %assoc_type = name_ref T4, @I4.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc31_21: = facet_access_witness %.Self.ref.loc31_21 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc31: type = impl_witness_access %.Self.as_wit.loc31_21, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc31_33.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc31_33.2: type = converted %.loc31_33.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %empty_struct_type} [template = constants.%struct_type.b] +// CHECK:STDOUT: %.Self.ref.loc31_40: %I4.type = name_ref .Self, %.Self.2 [symbolic = constants.%.Self] +// CHECK:STDOUT: %T5.ref.loc31: %assoc_type = name_ref T5, @I4.%assoc1 [template = constants.%assoc1] +// CHECK:STDOUT: %.Self.as_wit.loc31_40: = facet_access_witness %.Self.ref.loc31_40 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem1.loc31: type = impl_witness_access %.Self.as_wit.loc31_40, element1 [symbolic = constants.%impl.elem1] +// CHECK:STDOUT: %BAD3.ref: = name_ref BAD3, [template = ] +// CHECK:STDOUT: %.Self.ref.loc31_55: %I4.type = name_ref .Self, %.Self.2 [symbolic = constants.%.Self] +// CHECK:STDOUT: %T6.ref.loc31: %assoc_type = name_ref T6, @I4.%assoc2 [template = constants.%assoc2] +// CHECK:STDOUT: %.Self.as_wit.loc31_55: = facet_access_witness %.Self.ref.loc31_55 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem2.loc31: type = impl_witness_access %.Self.as_wit.loc31_55, element2 [symbolic = constants.%impl.elem2] +// CHECK:STDOUT: %BAD4.ref: = name_ref BAD4, [template = ] +// CHECK:STDOUT: %.loc31_15: type = where_expr %.Self.2 [template = ] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc31, %struct_type.b +// CHECK:STDOUT: requirement_rewrite %impl.elem1.loc31, +// CHECK:STDOUT: requirement_rewrite %impl.elem2.loc31, +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I4 { +// CHECK:STDOUT: %Self: %I4.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %T4: type = assoc_const_decl T4 [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %T4 [template = constants.%assoc0] +// CHECK:STDOUT: %T5: type = assoc_const_decl T5 [template] +// CHECK:STDOUT: %assoc1: %assoc_type = assoc_entity element1, %T5 [template = constants.%assoc1] +// CHECK:STDOUT: %T6: type = assoc_const_decl T6 [template] +// CHECK:STDOUT: %assoc2: %assoc_type = assoc_entity element2, %T6 [template = constants.%assoc2] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .T4 = %assoc0 +// CHECK:STDOUT: .T5 = %assoc1 +// CHECK:STDOUT: .T6 = %assoc2 +// CHECK:STDOUT: witness = (%T4, %T5, %T6) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc21_7.2 as %.loc21_15 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_missing_on_definition.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %K.type: type = facet_type <@K> [template] +// CHECK:STDOUT: %Self: %K.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %K.type, type [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @K.%V [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %.Self: %K.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] +// CHECK:STDOUT: %K_where.type: type = facet_type <@K where %impl.elem0 = %empty_struct_type> [template] +// CHECK:STDOUT: %impl_witness: = impl_witness (%empty_struct_type) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .K = %K.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %K.decl: type = interface_decl @K [template = constants.%K.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc5_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc5_7.2: type = converted %.loc5_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %K.ref.loc5: type = name_ref K, file.%K.decl [template = constants.%K.type] +// CHECK:STDOUT: %.Self: %K.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: %K.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %V.ref: %assoc_type = name_ref V, @K.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self.ref [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc5_26.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc5_26.2: type = converted %.loc5_26.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %.loc5_14: type = where_expr %.Self [template = constants.%K_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0, %.loc5_26.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%empty_struct_type) [template = constants.%impl_witness] +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc13_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_7.2: type = converted %.loc13_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %K.ref.loc13: type = name_ref K, file.%K.decl [template = constants.%K.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @K { +// CHECK:STDOUT: %Self: %K.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %V: type = assoc_const_decl V [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %V [template = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .V = %assoc0 +// CHECK:STDOUT: witness = (%V) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc5_7.2 as %.loc5_14 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_two_different.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %L.type: type = facet_type <@L> [template] +// CHECK:STDOUT: %Self: %L.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %L.type, type [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @L.%W [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %.Self: %L.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] +// CHECK:STDOUT: %L_where.type: type = facet_type <@L where %impl.elem0 = %empty_tuple.type and %impl.elem0 = %empty_struct_type> [template] +// CHECK:STDOUT: %impl_witness: = impl_witness (%empty_tuple.type) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .L = %L.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %L.decl: type = interface_decl @L [template = constants.%L.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc9_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc9_7.2: type = converted %.loc9_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %L.ref: type = name_ref L, file.%L.decl [template = constants.%L.type] +// CHECK:STDOUT: %.Self: %L.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc9_20: %L.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %W.ref.loc9_20: %assoc_type = name_ref W, @L.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc9_20: = facet_access_witness %.Self.ref.loc9_20 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc9_20: type = impl_witness_access %.Self.as_wit.loc9_20, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc9_26.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_26.2: type = converted %.loc9_26.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %.Self.ref.loc9_32: %L.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %W.ref.loc9_32: %assoc_type = name_ref W, @L.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc9_32: = facet_access_witness %.Self.ref.loc9_32 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc9_32: type = impl_witness_access %.Self.as_wit.loc9_32, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc9_38.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc9_38.2: type = converted %.loc9_38.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc9_14: type = where_expr %.Self [template = constants.%L_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc9_20, %.loc9_26.2 +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc9_32, %.loc9_38.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%empty_tuple.type) [template = constants.%impl_witness] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @L { +// CHECK:STDOUT: %Self: %L.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %W: type = assoc_const_decl W [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %W [template = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .W = %assoc0 +// CHECK:STDOUT: witness = (%W) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc9_7.2 as %.loc9_14 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_two_different_first_bad.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %L2.type: type = facet_type <@L2> [template] +// CHECK:STDOUT: %Self: %L2.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %L2.type, type [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @L2.%W2 [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %.Self: %L2.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .L2 = %L2.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %L2.decl: type = interface_decl @L2 [template = constants.%L2.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc9_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc9_7.2: type = converted %.loc9_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %L2.ref: type = name_ref L2, file.%L2.decl [template = constants.%L2.type] +// CHECK:STDOUT: %.Self: %L2.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc9_21: %L2.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %W2.ref.loc9_21: %assoc_type = name_ref W2, @L2.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc9_21: = facet_access_witness %.Self.ref.loc9_21 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc9_21: type = impl_witness_access %.Self.as_wit.loc9_21, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %BAD5.ref: = name_ref BAD5, [template = ] +// CHECK:STDOUT: %.Self.ref.loc9_36: %L2.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %W2.ref.loc9_36: %assoc_type = name_ref W2, @L2.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc9_36: = facet_access_witness %.Self.ref.loc9_36 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc9_36: type = impl_witness_access %.Self.as_wit.loc9_36, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc9_43.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc9_43.2: type = converted %.loc9_43.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc9_15: type = where_expr %.Self [template = ] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc9_21, +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc9_36, %.loc9_43.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @L2 { +// CHECK:STDOUT: %Self: %L2.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %W2: type = assoc_const_decl W2 [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %W2 [template = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .W2 = %assoc0 +// CHECK:STDOUT: witness = (%W2) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc9_7.2 as %.loc9_15 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_two_different_second_bad.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %L3.type: type = facet_type <@L3> [template] +// CHECK:STDOUT: %Self: %L3.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %L3.type, type [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @L3.%W3 [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %.Self: %L3.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .L3 = %L3.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %L3.decl: type = interface_decl @L3 [template = constants.%L3.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc9_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc9_7.2: type = converted %.loc9_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %L3.ref: type = name_ref L3, file.%L3.decl [template = constants.%L3.type] +// CHECK:STDOUT: %.Self: %L3.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc9_21: %L3.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %W3.ref.loc9_21: %assoc_type = name_ref W3, @L3.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc9_21: = facet_access_witness %.Self.ref.loc9_21 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc9_21: type = impl_witness_access %.Self.as_wit.loc9_21, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc9_28.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_28.2: type = converted %.loc9_28.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %.Self.ref.loc9_34: %L3.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %W3.ref.loc9_34: %assoc_type = name_ref W3, @L3.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc9_34: = facet_access_witness %.Self.ref.loc9_34 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc9_34: type = impl_witness_access %.Self.as_wit.loc9_34, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %BAD6.ref: = name_ref BAD6, [template = ] +// CHECK:STDOUT: %.loc9_15: type = where_expr %.Self [template = ] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc9_21, %.loc9_28.2 +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc9_34, +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @L3 { +// CHECK:STDOUT: %Self: %L3.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %W3: type = assoc_const_decl W3 [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %W3 [template = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .W3 = %assoc0 +// CHECK:STDOUT: witness = (%W3) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc9_7.2 as %.loc9_15 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_two_different_both_bad.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %L4.type: type = facet_type <@L4> [template] +// CHECK:STDOUT: %Self: %L4.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %L4.type, type [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @L4.%W4 [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %.Self: %L4.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .L4 = %L4.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %L4.decl: type = interface_decl @L4 [template = constants.%L4.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc12_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_7.2: type = converted %.loc12_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %L4.ref: type = name_ref L4, file.%L4.decl [template = constants.%L4.type] +// CHECK:STDOUT: %.Self: %L4.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc12_21: %L4.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %W4.ref.loc12_21: %assoc_type = name_ref W4, @L4.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc12_21: = facet_access_witness %.Self.ref.loc12_21 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc12_21: type = impl_witness_access %.Self.as_wit.loc12_21, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %BAD7.ref: = name_ref BAD7, [template = ] +// CHECK:STDOUT: %.Self.ref.loc12_36: %L4.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %W4.ref.loc12_36: %assoc_type = name_ref W4, @L4.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc12_36: = facet_access_witness %.Self.ref.loc12_36 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc12_36: type = impl_witness_access %.Self.as_wit.loc12_36, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %BAD8.ref: = name_ref BAD8, [template = ] +// CHECK:STDOUT: %.loc12_15: type = where_expr %.Self [template = ] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc12_21, +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc12_36, +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @L4 { +// CHECK:STDOUT: %Self: %L4.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %W4: type = assoc_const_decl W4 [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %W4 [template = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .W4 = %assoc0 +// CHECK:STDOUT: witness = (%W4) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc12_7.2 as %.loc12_15 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- repeated.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %M.type: type = facet_type <@M> [template] +// CHECK:STDOUT: %Self: %M.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %M.type, type [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @M.%X [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %.Self: %M.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] +// CHECK:STDOUT: %M_where.type: type = facet_type <@M where %impl.elem0 = %empty_struct_type> [template] +// CHECK:STDOUT: %impl_witness: = impl_witness (%empty_struct_type) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .M = %M.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %M.decl: type = interface_decl @M [template = constants.%M.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc5_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc5_7.2: type = converted %.loc5_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %M.ref: type = name_ref M, file.%M.decl [template = constants.%M.type] +// CHECK:STDOUT: %.Self: %M.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref.loc5_20: %M.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %X.ref.loc5_20: %assoc_type = name_ref X, @M.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc5_20: = facet_access_witness %.Self.ref.loc5_20 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc5_20: type = impl_witness_access %.Self.as_wit.loc5_20, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc5_26.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc5_26.2: type = converted %.loc5_26.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %.Self.ref.loc5_32: %M.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %X.ref.loc5_32: %assoc_type = name_ref X, @M.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit.loc5_32: = facet_access_witness %.Self.ref.loc5_32 [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0.loc5_32: type = impl_witness_access %.Self.as_wit.loc5_32, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc5_38.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc5_38.2: type = converted %.loc5_38.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %.loc5_14: type = where_expr %.Self [template = constants.%M_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc5_20, %.loc5_26.2 +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc5_32, %.loc5_38.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%empty_struct_type) [template = constants.%impl_witness] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @M { +// CHECK:STDOUT: %Self: %M.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %X: type = assoc_const_decl X [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %X [template = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .X = %assoc0 +// CHECK:STDOUT: witness = (%X) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc5_7.2 as %.loc5_14 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- non-type.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %N.type: type = facet_type <@N> [template] +// CHECK:STDOUT: %Self: %N.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] +// CHECK:STDOUT: %struct_type.a.225: type = struct_type {.a: %empty_struct_type} [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %N.type, %struct_type.a.225 [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, @N.%Y [template] +// CHECK:STDOUT: %.Self: %N.type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %impl.elem0: %struct_type.a.225 = impl_witness_access %.Self.as_wit, element0 [symbolic] +// CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [template] +// CHECK:STDOUT: %struct: %struct_type.a.225 = struct_value (%empty_struct) [template] +// CHECK:STDOUT: %N_where.type: type = facet_type <@N where %impl.elem0 = %struct> [template] +// CHECK:STDOUT: %impl_witness: = impl_witness (%struct) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .N = %N.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %N.decl: type = interface_decl @N [template = constants.%N.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc7_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc7_7.2: type = converted %.loc7_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %N.ref: type = name_ref N, file.%N.decl [template = constants.%N.type] +// CHECK:STDOUT: %.Self: %N.type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: %N.type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %Y.ref: %assoc_type = name_ref Y, @N.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self.ref [symbolic = constants.%.Self.as_wit] +// CHECK:STDOUT: %impl.elem0: %struct_type.a.225 = impl_witness_access %.Self.as_wit, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc7_32: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc7_33.1: %struct_type.a.225 = struct_literal (%.loc7_32) +// CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [template = constants.%empty_struct] +// CHECK:STDOUT: %.loc7_33.2: %empty_struct_type = converted %.loc7_32, %empty_struct [template = constants.%empty_struct] +// CHECK:STDOUT: %struct: %struct_type.a.225 = struct_value (%.loc7_33.2) [template = constants.%struct] +// CHECK:STDOUT: %.loc7_33.3: %struct_type.a.225 = converted %.loc7_33.1, %struct [template = constants.%struct] +// CHECK:STDOUT: %.loc7_14: type = where_expr %.Self [template = constants.%N_where.type] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0, %.loc7_33.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl_witness: = impl_witness (constants.%struct) [template = constants.%impl_witness] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @N { +// CHECK:STDOUT: %Self: %N.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %Y: %struct_type.a.225 = assoc_const_decl Y [template] +// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %Y [template = constants.%assoc0] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .Y = %assoc0 +// CHECK:STDOUT: witness = (%Y) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc7_7.2 as %.loc7_14 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = file.%impl_witness +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/no_prelude/impl_self_as.carbon b/toolchain/check/testdata/impl/no_prelude/impl_self_as.carbon index cdb16c10026be..be455031a405b 100644 --- a/toolchain/check/testdata/impl/no_prelude/impl_self_as.carbon +++ b/toolchain/check/testdata/impl/no_prelude/impl_self_as.carbon @@ -65,56 +65,56 @@ interface J6(T6:! type) {} // `impl C as` should not match `impl Self as` or `impl as`. class C3 { - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl C3 as I3; // CHECK:STDERR: ^~~~~~~~~~~~~~ // CHECK:STDERR: impl C3 as I3; impl as I3 {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl C3 as I4; // CHECK:STDERR: ^~~~~~~~~~~~~~ // CHECK:STDERR: impl C3 as I4; impl Self as I4 {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl as I5; // CHECK:STDERR: ^~~~~~~~~~~ // CHECK:STDERR: impl as I5; impl C3 as I5 {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl Self as I6; // CHECK:STDERR: ^~~~~~~~~~~~~~~~ // CHECK:STDERR: impl Self as I6; impl C3 as I6 {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl forall [Z3:! type] C3 as J3(Z3); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: impl forall [Z3:! type] C3 as J3(Z3); impl forall [Z3:! type] as J3(Z3) {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl forall [Z4:! type] C3 as J4(Z4); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: impl forall [Z4:! type] C3 as J4(Z4); impl forall [Z4:! type] Self as J4(Z4) {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl forall [Z5:! type] as J5(Z5); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: impl forall [Z5:! type] as J5(Z5); impl forall [Z5:! type] C3 as J5(Z5) {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl forall [Z6:! type] Self as J6(Z6); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: @@ -123,56 +123,56 @@ class C3 { } class C4(A:! type) { - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl C4(A) as I3; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: impl C4(A) as I3; impl as I3 {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl C4(A) as I4; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ // CHECK:STDERR: impl C4(A) as I4; impl Self as I4 {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl as I5; // CHECK:STDERR: ^~~~~~~~~~~ // CHECK:STDERR: impl as I5; impl C4(A) as I5 {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl Self as I6; // CHECK:STDERR: ^~~~~~~~~~~~~~~~ // CHECK:STDERR: impl Self as I6; impl C4(A) as I6 {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl forall [B3:! type] C4(A) as J3(B3); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: impl forall [B3:! type] C4(A) as J3(B3); impl forall [B3:! type] as J3(B3) {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl forall [B4:! type] C4(A) as J4(B4); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: impl forall [B4:! type] C4(A) as J4(B4); impl forall [B4:! type] Self as J4(B4) {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+4]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl forall [B5:! type] as J5(B5); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: impl forall [B5:! type] as J5(B5); impl forall [B5:! type] C4(A) as J5(B5) {} - // CHECK:STDERR: fail_no_match.carbon:[[@LINE+3]]:3: error: impl declared but not defined [MissingImplDefinition] + // CHECK:STDERR: fail_no_match.carbon:[[@LINE+3]]:3: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl forall [B6:! type] Self as J6(B6); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl forall [B6:! type] Self as J6(B6); diff --git a/toolchain/check/testdata/impl/no_prelude/impl_where_redecl.carbon b/toolchain/check/testdata/impl/no_prelude/impl_where_redecl.carbon index c59c393f64714..ae50c1ca90907 100644 --- a/toolchain/check/testdata/impl/no_prelude/impl_where_redecl.carbon +++ b/toolchain/check/testdata/impl/no_prelude/impl_where_redecl.carbon @@ -13,12 +13,22 @@ // --- match.carbon library "[[@TEST_NAME]]"; +interface I { let T:! type; } interface J {} // `impl` matching ignores the `where` clause. It should not get confused by // nested `where`, so the following should not trigger impl declaration without // definition diagnostics. +impl () as I where .T = {}; +impl () as I where .T = {} and .T impls (type where .Self impls type) {} + +impl {} as I; +impl {} as I where .T = {} and .T impls (type where .Self impls type) {} + +impl ({},) as I where .T = {} and .T impls (type where .Self impls type); +impl ({},) as I where .T = {} {} + impl () as J; impl () as J where .Self impls type and .Self impls (type where .Self impls type) {} @@ -40,7 +50,7 @@ library "[[@TEST_NAME]]"; interface L {} -// CHECK:STDERR: fail_other_nesting.carbon:[[@LINE+3]]:1: error: impl declared but not defined [MissingImplDefinition] +// CHECK:STDERR: fail_other_nesting.carbon:[[@LINE+3]]:1: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl () as (L where .Self impls type) where .Self impls type; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ impl () as (L where .Self impls type) where .Self impls type; diff --git a/toolchain/check/testdata/impl/no_prelude/import_generic.carbon b/toolchain/check/testdata/impl/no_prelude/import_generic.carbon index 34ff58eed0cb2..43e7f8303ee53 100644 --- a/toolchain/check/testdata/impl/no_prelude/import_generic.carbon +++ b/toolchain/check/testdata/impl/no_prelude/import_generic.carbon @@ -57,13 +57,13 @@ library "[[@TEST_NAME]]"; class D {} interface J(T:! type) {} -// CHECK:STDERR: fail_import_generic_decl.carbon:[[@LINE+4]]:1: error: impl declared but not defined [MissingImplDefinition] +// CHECK:STDERR: fail_import_generic_decl.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl forall [T:! type] D as J(T); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: impl forall [T:! type] D as J(T); -// CHECK:STDERR: fail_import_generic_decl.carbon:[[@LINE+4]]:1: error: impl declared but not defined [MissingImplDefinition] +// CHECK:STDERR: fail_import_generic_decl.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl forall [T:! type] D as J(T*); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: 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 25cdd3694c6dc..b6ae66928c72d 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 @@ -14,7 +14,7 @@ library "[[@TEST_NAME]]"; interface A {} -// CHECK:STDERR: fail_decl_in_api_definition_in_impl.carbon:[[@LINE+4]]:1: error: impl declared but not defined [MissingImplDefinition] +// CHECK:STDERR: fail_decl_in_api_definition_in_impl.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl () as A; // CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: @@ -52,7 +52,7 @@ library "[[@TEST_NAME]]"; interface B {} -// CHECK:STDERR: fail_decl_only_in_api.carbon:[[@LINE+4]]:1: error: impl declared but not defined [MissingImplDefinition] +// CHECK:STDERR: fail_decl_only_in_api.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl () as B; // CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: @@ -68,7 +68,7 @@ library "[[@TEST_NAME]]"; interface C {} -// CHECK:STDERR: fail_decl_in_api_decl_in_impl.carbon:[[@LINE+4]]:1: error: impl declared but not defined [MissingImplDefinition] +// CHECK:STDERR: fail_decl_in_api_decl_in_impl.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl () as C; // CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: @@ -94,7 +94,7 @@ impl library "[[@TEST_NAME]]"; interface D {} -// CHECK:STDERR: fail_decl_only_in_impl.impl.carbon:[[@LINE+3]]:1: error: impl declared but not defined [MissingImplDefinition] +// CHECK:STDERR: fail_decl_only_in_impl.impl.carbon:[[@LINE+3]]:1: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl () as D; // CHECK:STDERR: ^~~~~~~~~~~~~ impl () as D; diff --git a/toolchain/check/testdata/interface/no_prelude/import_interface_decl.carbon b/toolchain/check/testdata/interface/no_prelude/import_interface_decl.carbon index 1a2e5878ac2f3..410936a885e48 100644 --- a/toolchain/check/testdata/interface/no_prelude/import_interface_decl.carbon +++ b/toolchain/check/testdata/interface/no_prelude/import_interface_decl.carbon @@ -18,7 +18,7 @@ impl library "[[@TEST_NAME]]"; // --- fail_b.carbon library "[[@TEST_NAME]]"; interface B {} -// CHECK:STDERR: fail_b.carbon:[[@LINE+3]]:1: error: impl declared but not defined [MissingImplDefinition] +// CHECK:STDERR: fail_b.carbon:[[@LINE+3]]:1: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl () as B; // CHECK:STDERR: ^~~~~~~~~~~~~ impl () as B; diff --git a/toolchain/diagnostics/diagnostic_kind.def b/toolchain/diagnostics/diagnostic_kind.def index 3d029708bf29b..781f396d9e584 100644 --- a/toolchain/diagnostics/diagnostic_kind.def +++ b/toolchain/diagnostics/diagnostic_kind.def @@ -252,6 +252,10 @@ CARBON_DIAGNOSTIC_KIND(InterfaceForwardDeclaredHere) CARBON_DIAGNOSTIC_KIND(InterfaceUndefinedWithinDefinition) // Impl checking. +CARBON_DIAGNOSTIC_KIND(AssociatedConstantDifferentInRedecl) +CARBON_DIAGNOSTIC_KIND(AssociatedConstantHere) +CARBON_DIAGNOSTIC_KIND(AssociatedConstantMissingInRedecl) +CARBON_DIAGNOSTIC_KIND(AssociatedFunctionHere) CARBON_DIAGNOSTIC_KIND(ExtendImplForall) CARBON_DIAGNOSTIC_KIND(ExtendImplOutsideClass) CARBON_DIAGNOSTIC_KIND(ExtendImplSelfAs) @@ -259,13 +263,14 @@ CARBON_DIAGNOSTIC_KIND(ExtendImplSelfAsDefault) CARBON_DIAGNOSTIC_KIND(ImplAccessMemberBeforeComplete) CARBON_DIAGNOSTIC_KIND(ImplAsNonFacetType) CARBON_DIAGNOSTIC_KIND(ImplAsOutsideClass) +CARBON_DIAGNOSTIC_KIND(ImplAssociatedConstantNeedsValue) +CARBON_DIAGNOSTIC_KIND(ImplFunctionWithNonFunction) +CARBON_DIAGNOSTIC_KIND(ImplMissingDefinition) +CARBON_DIAGNOSTIC_KIND(ImplMissingFunction) CARBON_DIAGNOSTIC_KIND(ImplPreviousDefinition) +CARBON_DIAGNOSTIC_KIND(ImplPreviousDeclHere) CARBON_DIAGNOSTIC_KIND(ImplRedefinition) -CARBON_DIAGNOSTIC_KIND(ImplMissingFunction) -CARBON_DIAGNOSTIC_KIND(ImplFunctionWithNonFunction) -CARBON_DIAGNOSTIC_KIND(ImplAssociatedFunctionHere) CARBON_DIAGNOSTIC_KIND(ImplOfUndefinedInterface) -CARBON_DIAGNOSTIC_KIND(MissingImplDefinition) // Impl lookup. CARBON_DIAGNOSTIC_KIND(MissingImplInMemberAccess) @@ -408,6 +413,7 @@ CARBON_DIAGNOSTIC_KIND(ClassInvalidMemberAccess) CARBON_DIAGNOSTIC_KIND(AliasRequiresNameRef) // Where operator and its requirements. +CARBON_DIAGNOSTIC_KIND(AssociatedConstantWithDifferentValues) CARBON_DIAGNOSTIC_KIND(ImplsOnNonFacetType) CARBON_DIAGNOSTIC_KIND(WhereOnNonFacetType)