mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-29 07:54:56 +01:00
Use it in the instruction namer to make instruction names more stable across unrelated changes to the toolchain or the prelude. --------- Co-authored-by: Dana Jansens <danakj@orodu.net>
308 lines
13 KiB
Plaintext
308 lines
13 KiB
Plaintext
// 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/lookup/transitive.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/lookup/transitive.carbon
|
|
|
|
// --- i.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
interface I { fn F(); }
|
|
|
|
// --- c.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import library "i";
|
|
|
|
class C {}
|
|
impl C as I { fn F() {} }
|
|
|
|
// --- get.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import library "c";
|
|
|
|
fn Get() -> C;
|
|
|
|
// --- call.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import library "get";
|
|
import library "i";
|
|
|
|
fn Call() {
|
|
// We find C in "get", but should look in "c" instead.
|
|
Get().(I.F)();
|
|
}
|
|
|
|
// CHECK:STDOUT: --- i.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: %F.type: type = fn_type @F [template]
|
|
// CHECK:STDOUT: %F: %F.type = struct_value () [template]
|
|
// CHECK:STDOUT: %F.assoc_type: type = assoc_entity_type %I.type, %F.type [template]
|
|
// CHECK:STDOUT: %assoc0: %F.assoc_type = assoc_entity element0, @I.%F.decl [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = 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: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: interface @I {
|
|
// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
|
|
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
|
|
// CHECK:STDOUT: %assoc0: %F.assoc_type = assoc_entity element0, %F.decl [template = constants.%assoc0]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = %Self
|
|
// CHECK:STDOUT: .F = %assoc0
|
|
// CHECK:STDOUT: witness = (%F.decl)
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic fn @F(@I.%Self: %I.type) {
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn();
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @F(constants.%Self) {}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- c.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %C: type = class_type @C [template]
|
|
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
|
|
// CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
|
|
// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
|
|
// CHECK:STDOUT: %F.type.9df: type = fn_type @F.1 [template]
|
|
// CHECK:STDOUT: %F.478: %F.type.9df = struct_value () [template]
|
|
// CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%F.decl) [template]
|
|
// CHECK:STDOUT: %F.type.e0c: type = fn_type @F.2 [template]
|
|
// CHECK:STDOUT: %F.983: %F.type.e0c = struct_value () [template]
|
|
// CHECK:STDOUT: %I.facet: %I.type = facet_value %C, %impl_witness [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %import_ref.9f4: type = import_ref Main//i, I, loaded [template = constants.%I.type]
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %import_ref.f8c = import_ref Main//i, inst17 [no loc], unloaded
|
|
// CHECK:STDOUT: %import_ref.e20 = import_ref Main//i, loc4_21, unloaded
|
|
// CHECK:STDOUT: %import_ref.95d: %F.type.9df = import_ref Main//i, F, loaded [template = constants.%F.478]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .I = imports.%import_ref.9f4
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .C = %C.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %default.import = import <invalid>
|
|
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
|
|
// CHECK:STDOUT: impl_decl @impl [template] {} {
|
|
// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
|
|
// CHECK:STDOUT: %I.ref: type = name_ref I, imports.%import_ref.9f4 [template = constants.%I.type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%F.decl) [template = constants.%impl_witness]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: interface @I [from "i.carbon"] {
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = imports.%import_ref.f8c
|
|
// CHECK:STDOUT: .F = imports.%import_ref.e20
|
|
// CHECK:STDOUT: witness = (imports.%import_ref.95d)
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: impl @impl: %C.ref as %I.ref {
|
|
// CHECK:STDOUT: %F.decl: %F.type.e0c = fn_decl @F.2 [template = constants.%F.983] {} {}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .F = %F.decl
|
|
// CHECK:STDOUT: witness = file.%impl_witness
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @C {
|
|
// CHECK:STDOUT: %complete_type: <witness> = 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(constants.%Self: %I.type) [from "i.carbon"] {
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn();
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @F.2() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @F.1(constants.%Self) {}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @F.1(constants.%I.facet) {}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- get.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %C: type = class_type @C [template]
|
|
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
|
|
// CHECK:STDOUT: %Get.type: type = fn_type @Get [template]
|
|
// CHECK:STDOUT: %Get: %Get.type = struct_value () [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %import_ref.0ac: type = import_ref Main//c, C, loaded [template = constants.%C]
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %import_ref.8f2: <witness> = import_ref Main//c, loc6_10, loaded [template = constants.%complete_type]
|
|
// CHECK:STDOUT: %import_ref.2c4 = import_ref Main//c, inst18 [no loc], unloaded
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .C = imports.%import_ref.0ac
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .Get = %Get.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %default.import = import <invalid>
|
|
// CHECK:STDOUT: %Get.decl: %Get.type = fn_decl @Get [template = constants.%Get] {
|
|
// CHECK:STDOUT: %return.patt: %C = return_slot_pattern
|
|
// CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.0ac [template = constants.%C]
|
|
// CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
|
|
// CHECK:STDOUT: %return: ref %C = return_slot %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @C [from "c.carbon"] {
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = imports.%import_ref.2c4
|
|
// CHECK:STDOUT: complete_type_witness = imports.%import_ref.8f2
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Get() -> %C;
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- call.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %Call.type: type = fn_type @Call [template]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
|
|
// CHECK:STDOUT: %Call: %Call.type = struct_value () [template]
|
|
// CHECK:STDOUT: %Get.type: type = fn_type @Get [template]
|
|
// CHECK:STDOUT: %Get: %Get.type = struct_value () [template]
|
|
// CHECK:STDOUT: %C: type = class_type @C [template]
|
|
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
|
|
// CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
|
|
// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
|
|
// CHECK:STDOUT: %F.type.9df: type = fn_type @F.1 [template]
|
|
// CHECK:STDOUT: %F.assoc_type: type = assoc_entity_type %I.type, %F.type.9df [template]
|
|
// CHECK:STDOUT: %assoc0: %F.assoc_type = assoc_entity element0, imports.%import_ref.911 [template]
|
|
// CHECK:STDOUT: %impl_witness: <witness> = impl_witness (imports.%import_ref.ba1) [template]
|
|
// CHECK:STDOUT: %F.type.731: type = fn_type @F.2 [template]
|
|
// CHECK:STDOUT: %F.2a3: %F.type.731 = struct_value () [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %import_ref.2a6: %Get.type = import_ref Main//get, Get, loaded [template = constants.%Get]
|
|
// CHECK:STDOUT: %import_ref.9f4: type = import_ref Main//i, I, loaded [template = constants.%I.type]
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %import_ref.8db: <witness> = import_ref Main//get, inst21 [indirect], loaded [template = constants.%complete_type]
|
|
// CHECK:STDOUT: %import_ref.6a9 = import_ref Main//get, inst22 [indirect], unloaded
|
|
// CHECK:STDOUT: %import_ref.f8c = import_ref Main//i, inst17 [no loc], unloaded
|
|
// CHECK:STDOUT: %import_ref.145: %F.assoc_type = import_ref Main//i, loc4_21, loaded [template = constants.%assoc0]
|
|
// CHECK:STDOUT: %import_ref.a15 = import_ref Main//i, F, unloaded
|
|
// CHECK:STDOUT: %import_ref.938: <witness> = import_ref Main//c, loc7_13, loaded [template = constants.%impl_witness]
|
|
// CHECK:STDOUT: %import_ref.3de: type = import_ref Main//c, loc7_6, loaded [template = constants.%C]
|
|
// CHECK:STDOUT: %import_ref.60b: type = import_ref Main//c, loc7_11, loaded [template = constants.%I.type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Get = imports.%import_ref.2a6
|
|
// CHECK:STDOUT: .I = imports.%import_ref.9f4
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .Call = %Call.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %default.import = import <invalid>
|
|
// CHECK:STDOUT: %Call.decl: %Call.type = fn_decl @Call [template = constants.%Call] {} {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: interface @I [from "i.carbon"] {
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = imports.%import_ref.f8c
|
|
// CHECK:STDOUT: .F = imports.%import_ref.145
|
|
// CHECK:STDOUT: witness = (imports.%import_ref.a15)
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: impl @impl: imports.%import_ref.3de as imports.%import_ref.60b [from "c.carbon"] {
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: witness = imports.%import_ref.938
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @C [from "get.carbon"] {
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = imports.%import_ref.6a9
|
|
// CHECK:STDOUT: complete_type_witness = imports.%import_ref.8db
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Call() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %Get.ref: %Get.type = name_ref Get, imports.%import_ref.2a6 [template = constants.%Get]
|
|
// CHECK:STDOUT: %.loc9: ref %C = temporary_storage
|
|
// CHECK:STDOUT: %Get.call: init %C = call %Get.ref() to %.loc9
|
|
// CHECK:STDOUT: %I.ref: type = name_ref I, imports.%import_ref.9f4 [template = constants.%I.type]
|
|
// CHECK:STDOUT: %F.ref: %F.assoc_type = name_ref F, imports.%import_ref.145 [template = constants.%assoc0]
|
|
// CHECK:STDOUT: %impl.elem0: %F.type.9df = impl_witness_access constants.%impl_witness, element0 [template = constants.%F.2a3]
|
|
// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %impl.elem0()
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Get() -> %C [from "get.carbon"];
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic fn @F.1(constants.%Self: %I.type) [from "i.carbon"] {
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn();
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @F.2() [from "c.carbon"];
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @F.1(constants.%Self) {}
|
|
// CHECK:STDOUT:
|