mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 22:02:33 +01:00
Fixes link failures when referencing a symbol involving a fingerprint from a different package. Previously we included the `Namespace`'s `import_id` as part of its fingerprint, which caused local and imported namespaces to get different fingerprints. We now store the `import_id` on the `NameScope` instead of on the `Namespace` inst to avoid this problem. Also, when we reach a package-level `NameScopeId`, consistently fingerprint it as a (package name, library name) pair. Previously the fingerprinting depended on whether it was imported or not, as an imported `NameScopeId` had a parent scope (the current package). We need to include the library name here so that private entities with the same name in different libraries have different fingerprints.
159 lines
8.0 KiB
Plaintext
159 lines
8.0 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
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
|
|
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
|
|
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/lookup/alias.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/lookup/alias.carbon
|
|
|
|
interface HasF {
|
|
fn F();
|
|
}
|
|
|
|
class C {
|
|
alias G = HasF.F;
|
|
}
|
|
|
|
impl C as HasF {
|
|
fn F() {}
|
|
}
|
|
|
|
fn G(c: C) {
|
|
C.G();
|
|
c.G();
|
|
}
|
|
|
|
// CHECK:STDOUT: --- alias.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %HasF.type: type = facet_type <@HasF> [concrete]
|
|
// CHECK:STDOUT: %Self: %HasF.type = symbolic_binding Self, 0 [symbolic]
|
|
// CHECK:STDOUT: %HasF.WithSelf.F.type.38d: type = fn_type @HasF.WithSelf.F, @HasF.WithSelf(%Self) [symbolic]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
|
// CHECK:STDOUT: %HasF.WithSelf.F.3d1: %HasF.WithSelf.F.type.38d = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %HasF.assoc_type: type = assoc_entity_type @HasF [concrete]
|
|
// CHECK:STDOUT: %assoc0: %HasF.assoc_type = assoc_entity element0, @HasF.WithSelf.%HasF.WithSelf.F.decl [concrete]
|
|
// CHECK:STDOUT: %C: type = class_type @C [concrete]
|
|
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
|
|
// CHECK:STDOUT: %HasF.impl_witness: <witness> = impl_witness @C.as.HasF.impl.%HasF.impl_witness_table [concrete]
|
|
// CHECK:STDOUT: %C.as.HasF.impl.F.type: type = fn_type @C.as.HasF.impl.F [concrete]
|
|
// CHECK:STDOUT: %C.as.HasF.impl.F: %C.as.HasF.impl.F.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %HasF.facet: %HasF.type = facet_value %C, (%HasF.impl_witness) [concrete]
|
|
// CHECK:STDOUT: %HasF.WithSelf.F.type.3ae: type = fn_type @HasF.WithSelf.F, @HasF.WithSelf(%HasF.facet) [concrete]
|
|
// CHECK:STDOUT: %HasF.WithSelf.F.e6b: %HasF.WithSelf.F.type.3ae = struct_value () [concrete]
|
|
// CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
|
|
// CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
|
|
// CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %.4c1: type = fn_type_with_self_type %HasF.WithSelf.F.type.3ae, %HasF.facet [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .HasF = %HasF.decl
|
|
// CHECK:STDOUT: .C = %C.decl
|
|
// CHECK:STDOUT: .G = %G.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %HasF.decl: type = interface_decl @HasF [concrete = constants.%HasF.type] {} {}
|
|
// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
|
|
// CHECK:STDOUT: impl_decl @C.as.HasF.impl [concrete] {} {
|
|
// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
|
|
// CHECK:STDOUT: %HasF.ref: type = name_ref HasF, file.%HasF.decl [concrete = constants.%HasF.type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
|
|
// CHECK:STDOUT: %c.param_patt: %pattern_type = value_param_pattern [concrete]
|
|
// CHECK:STDOUT: %c.patt: %pattern_type = at_binding_pattern c, %c.param_patt [concrete]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %c.param: %C = value_param call_param0
|
|
// CHECK:STDOUT: %C.ref.loc27: type = name_ref C, file.%C.decl [concrete = constants.%C]
|
|
// CHECK:STDOUT: %c: %C = value_binding c, %c.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: interface @HasF {
|
|
// CHECK:STDOUT: %Self: %HasF.type = symbolic_binding Self, 0 [symbolic = constants.%Self]
|
|
// CHECK:STDOUT: %HasF.WithSelf.decl = interface_with_self_decl @HasF [concrete]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !with Self:
|
|
// CHECK:STDOUT: %HasF.WithSelf.F.decl: @HasF.WithSelf.%HasF.WithSelf.F.type (%HasF.WithSelf.F.type.38d) = fn_decl @HasF.WithSelf.F [symbolic = @HasF.WithSelf.%HasF.WithSelf.F (constants.%HasF.WithSelf.F.3d1)] {} {}
|
|
// CHECK:STDOUT: %assoc0: %HasF.assoc_type = assoc_entity element0, %HasF.WithSelf.F.decl [concrete = constants.%assoc0]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = %Self
|
|
// CHECK:STDOUT: .F = @HasF.WithSelf.%assoc0
|
|
// CHECK:STDOUT: witness = (@HasF.WithSelf.%HasF.WithSelf.F.decl)
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !requires:
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: impl @C.as.HasF.impl: %C.ref as %HasF.ref {
|
|
// CHECK:STDOUT: %C.as.HasF.impl.F.decl: %C.as.HasF.impl.F.type = fn_decl @C.as.HasF.impl.F [concrete = constants.%C.as.HasF.impl.F] {} {}
|
|
// CHECK:STDOUT: %HasF.impl_witness_table = impl_witness_table (%C.as.HasF.impl.F.decl), @C.as.HasF.impl [concrete]
|
|
// CHECK:STDOUT: %HasF.impl_witness: <witness> = impl_witness %HasF.impl_witness_table [concrete = constants.%HasF.impl_witness]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .F = %C.as.HasF.impl.F.decl
|
|
// CHECK:STDOUT: extend %HasF.ref
|
|
// CHECK:STDOUT: witness = %HasF.impl_witness
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @C {
|
|
// CHECK:STDOUT: %HasF.ref: type = name_ref HasF, file.%HasF.decl [concrete = constants.%HasF.type]
|
|
// CHECK:STDOUT: %F.ref: %HasF.assoc_type = name_ref F, @HasF.WithSelf.%assoc0 [concrete = constants.%assoc0]
|
|
// CHECK:STDOUT: %G: %HasF.assoc_type = alias_binding G, %F.ref [concrete = constants.%assoc0]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%C
|
|
// CHECK:STDOUT: .HasF = <poisoned>
|
|
// CHECK:STDOUT: .G = %G
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic fn @HasF.WithSelf.F(@HasF.%Self: %HasF.type) {
|
|
// CHECK:STDOUT: fn();
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @C.as.HasF.impl.F() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @G(%c.param: %C) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %C.ref.loc28: type = name_ref C, file.%C.decl [concrete = constants.%C]
|
|
// CHECK:STDOUT: %G.ref.loc28: %HasF.assoc_type = name_ref G, @C.%G [concrete = constants.%assoc0]
|
|
// CHECK:STDOUT: %impl.elem0.loc28: %.4c1 = impl_witness_access constants.%HasF.impl_witness, element0 [concrete = constants.%C.as.HasF.impl.F]
|
|
// CHECK:STDOUT: %C.as.HasF.impl.F.call.loc28: init %empty_tuple.type = call %impl.elem0.loc28()
|
|
// CHECK:STDOUT: %c.ref: %C = name_ref c, %c
|
|
// CHECK:STDOUT: %G.ref.loc29: %HasF.assoc_type = name_ref G, @C.%G [concrete = constants.%assoc0]
|
|
// CHECK:STDOUT: %impl.elem0.loc29: %.4c1 = impl_witness_access constants.%HasF.impl_witness, element0 [concrete = constants.%C.as.HasF.impl.F]
|
|
// CHECK:STDOUT: %C.as.HasF.impl.F.call.loc29: init %empty_tuple.type = call %impl.elem0.loc29()
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @HasF.WithSelf(constants.%Self) {
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %Self => constants.%Self
|
|
// CHECK:STDOUT: %HasF.WithSelf.F.type => constants.%HasF.WithSelf.F.type.38d
|
|
// CHECK:STDOUT: %HasF.WithSelf.F => constants.%HasF.WithSelf.F.3d1
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @HasF.WithSelf.F(constants.%Self) {}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @HasF.WithSelf(constants.%HasF.facet) {
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %Self => constants.%HasF.facet
|
|
// CHECK:STDOUT: %HasF.WithSelf.F.type => constants.%HasF.WithSelf.F.type.3ae
|
|
// CHECK:STDOUT: %HasF.WithSelf.F => constants.%HasF.WithSelf.F.e6b
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @HasF.WithSelf.F(constants.%HasF.facet) {}
|
|
// CHECK:STDOUT:
|