mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Fix cross-package signature mismatches. (#7232)
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.
This commit is contained in:
+37
-37
@@ -92,30 +92,30 @@ fn F() {
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
|
||||
// CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.2f8: type = pattern_type %i16 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.0cb: type = pattern_type %i16 [concrete]
|
||||
// CHECK:STDOUT: %Enum: type = class_type @Enum [concrete]
|
||||
// CHECK:STDOUT: %int_0.420: %Enum = int_value 0 [concrete]
|
||||
// CHECK:STDOUT: %int_0.320: %i16 = int_value 0 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.ebf: type = pattern_type %Enum [concrete]
|
||||
// CHECK:STDOUT: %int_0.779: %Enum = int_value 0 [concrete]
|
||||
// CHECK:STDOUT: %int_0.713: %i16 = int_value 0 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.9f7: type = pattern_type %Enum [concrete]
|
||||
// CHECK:STDOUT: %int_42.20e: Core.IntLiteral = int_value 42 [concrete]
|
||||
// CHECK:STDOUT: %As.type.359: type = facet_type <@As, @As(%i16)> [concrete]
|
||||
// CHECK:STDOUT: %As.type.457: type = facet_type <@As, @As(%i16)> [concrete]
|
||||
// CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.38c: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To) [symbolic]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.8f0: %Core.IntLiteral.as.As.impl.Convert.type.38c = struct_value () [symbolic]
|
||||
// CHECK:STDOUT: %As.impl_witness.e74: <witness> = impl_witness imports.%As.impl_witness_table.2cc, @Core.IntLiteral.as.As.impl(%int_16) [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.ae5: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_16) [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.e16: %Core.IntLiteral.as.As.impl.Convert.type.ae5 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %As.facet: %As.type.359 = facet_value Core.IntLiteral, (%As.impl_witness.e74) [concrete]
|
||||
// CHECK:STDOUT: %As.WithSelf.Convert.type.f92: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%i16, %As.facet) [concrete]
|
||||
// CHECK:STDOUT: %.a72: type = fn_type_with_self_type %As.WithSelf.Convert.type.f92, %As.facet [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound: <bound method> = bound_method %int_42.20e, %Core.IntLiteral.as.As.impl.Convert.e16 [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.As.impl.Convert.e16, @Core.IntLiteral.as.As.impl.Convert(%int_16) [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.fc5: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To) [symbolic]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.3a8: %Core.IntLiteral.as.As.impl.Convert.type.fc5 = struct_value () [symbolic]
|
||||
// CHECK:STDOUT: %As.impl_witness.bca: <witness> = impl_witness imports.%As.impl_witness_table.2e6, @Core.IntLiteral.as.As.impl(%int_16) [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.36d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_16) [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.036: %Core.IntLiteral.as.As.impl.Convert.type.36d = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %As.facet: %As.type.457 = facet_value Core.IntLiteral, (%As.impl_witness.bca) [concrete]
|
||||
// CHECK:STDOUT: %As.WithSelf.Convert.type.9f1: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%i16, %As.facet) [concrete]
|
||||
// CHECK:STDOUT: %.3ca: type = fn_type_with_self_type %As.WithSelf.Convert.type.9f1, %As.facet [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound: <bound method> = bound_method %int_42.20e, %Core.IntLiteral.as.As.impl.Convert.036 [concrete]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.As.impl.Convert.036, @Core.IntLiteral.as.As.impl.Convert(%int_16) [concrete]
|
||||
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_42.20e, %Core.IntLiteral.as.As.impl.Convert.specific_fn [concrete]
|
||||
// CHECK:STDOUT: %int_42.a0e: %i16 = int_value 42 [concrete]
|
||||
// CHECK:STDOUT: %int_42.c3a: %Enum = int_value 42 [concrete]
|
||||
// CHECK:STDOUT: %int_42.50d: %i16 = int_value 42 [concrete]
|
||||
// CHECK:STDOUT: %int_42.7b3: %Enum = int_value 42 [concrete]
|
||||
// CHECK:STDOUT: %Other: type = class_type @Other [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.c06: type = pattern_type %Other [concrete]
|
||||
// CHECK:STDOUT: %int_0.fa2: %Other = int_value 0 [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.da8: type = pattern_type %Other [concrete]
|
||||
// CHECK:STDOUT: %int_0.9f3: %Other = int_value 0 [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
@@ -126,9 +126,9 @@ fn F() {
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Enum.decl: type = class_decl @Enum [concrete = constants.%Enum] {} {}
|
||||
// CHECK:STDOUT: %int_0: %Enum = int_value 0 [concrete = constants.%int_0.420]
|
||||
// CHECK:STDOUT: %Core.import_ref.d74: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.38c) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.8f0)]
|
||||
// CHECK:STDOUT: %As.impl_witness_table.2cc = impl_witness_table (%Core.import_ref.d74), @Core.IntLiteral.as.As.impl [concrete]
|
||||
// CHECK:STDOUT: %int_0: %Enum = int_value 0 [concrete = constants.%int_0.779]
|
||||
// CHECK:STDOUT: %Core.import_ref.6c4: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.fc5) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.3a8)]
|
||||
// CHECK:STDOUT: %As.impl_witness_table.2e6 = impl_witness_table (%Core.import_ref.6c4), @Core.IntLiteral.as.As.impl [concrete]
|
||||
// CHECK:STDOUT: %Other.decl: type = class_decl @Other [concrete = constants.%Other] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -139,46 +139,46 @@ fn F() {
|
||||
// CHECK:STDOUT: fn @F() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: name_binding_decl {
|
||||
// CHECK:STDOUT: %a.patt: %pattern_type.2f8 = value_binding_pattern a [concrete]
|
||||
// CHECK:STDOUT: %a.patt: %pattern_type.0cb = value_binding_pattern a [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Enum.ref.loc8: type = name_ref Enum, imports.%Enum.decl [concrete = constants.%Enum]
|
||||
// CHECK:STDOUT: %a.ref.loc8: %Enum = name_ref a, imports.%int_0 [concrete = constants.%int_0.420]
|
||||
// CHECK:STDOUT: %a.ref.loc8: %Enum = name_ref a, imports.%int_0 [concrete = constants.%int_0.779]
|
||||
// CHECK:STDOUT: %i16.loc8_37: type = type_literal constants.%i16 [concrete = constants.%i16]
|
||||
// CHECK:STDOUT: %.loc8_34.1: %i16 = as_compatible %a.ref.loc8 [concrete = constants.%int_0.320]
|
||||
// CHECK:STDOUT: %.loc8_34.2: %i16 = converted %a.ref.loc8, %.loc8_34.1 [concrete = constants.%int_0.320]
|
||||
// CHECK:STDOUT: %.loc8_34.1: %i16 = as_compatible %a.ref.loc8 [concrete = constants.%int_0.713]
|
||||
// CHECK:STDOUT: %.loc8_34.2: %i16 = converted %a.ref.loc8, %.loc8_34.1 [concrete = constants.%int_0.713]
|
||||
// CHECK:STDOUT: %i16.loc8_17: type = type_literal constants.%i16 [concrete = constants.%i16]
|
||||
// CHECK:STDOUT: %a: %i16 = value_binding a, %.loc8_34.2
|
||||
// CHECK:STDOUT: name_binding_decl {
|
||||
// CHECK:STDOUT: %b.patt: %pattern_type.ebf = value_binding_pattern b [concrete]
|
||||
// CHECK:STDOUT: %b.patt: %pattern_type.9f7 = value_binding_pattern b [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [concrete = constants.%int_42.20e]
|
||||
// CHECK:STDOUT: %i16.loc9: type = type_literal constants.%i16 [concrete = constants.%i16]
|
||||
// CHECK:STDOUT: %impl.elem0: %.a72 = impl_witness_access constants.%As.impl_witness.e74, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.e16]
|
||||
// CHECK:STDOUT: %impl.elem0: %.3ca = impl_witness_access constants.%As.impl_witness.bca, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.036]
|
||||
// CHECK:STDOUT: %bound_method.loc9_32.1: <bound method> = bound_method %int_42, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound]
|
||||
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.As.impl.Convert(constants.%int_16) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc9_32.2: <bound method> = bound_method %int_42, %specific_fn [concrete = constants.%bound_method]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call: init %i16 = call %bound_method.loc9_32.2(%int_42) [concrete = constants.%int_42.a0e]
|
||||
// CHECK:STDOUT: %.loc9_32.1: %i16 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_42.a0e]
|
||||
// CHECK:STDOUT: %.loc9_32.2: %i16 = converted %int_42, %.loc9_32.1 [concrete = constants.%int_42.a0e]
|
||||
// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call: init %i16 = call %bound_method.loc9_32.2(%int_42) [concrete = constants.%int_42.50d]
|
||||
// CHECK:STDOUT: %.loc9_32.1: %i16 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_42.50d]
|
||||
// CHECK:STDOUT: %.loc9_32.2: %i16 = converted %int_42, %.loc9_32.1 [concrete = constants.%int_42.50d]
|
||||
// CHECK:STDOUT: %Cpp.ref.loc9_43: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Enum.ref.loc9_46: type = name_ref Enum, imports.%Enum.decl [concrete = constants.%Enum]
|
||||
// CHECK:STDOUT: %.loc9_40.1: %Enum = as_compatible %.loc9_32.2 [concrete = constants.%int_42.c3a]
|
||||
// CHECK:STDOUT: %.loc9_40.2: %Enum = converted %.loc9_32.2, %.loc9_40.1 [concrete = constants.%int_42.c3a]
|
||||
// CHECK:STDOUT: %.loc9_40.1: %Enum = as_compatible %.loc9_32.2 [concrete = constants.%int_42.7b3]
|
||||
// CHECK:STDOUT: %.loc9_40.2: %Enum = converted %.loc9_32.2, %.loc9_40.1 [concrete = constants.%int_42.7b3]
|
||||
// CHECK:STDOUT: %.loc9_20: type = splice_block %Enum.ref.loc9_20 [concrete = constants.%Enum] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc9_17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Enum.ref.loc9_20: type = name_ref Enum, imports.%Enum.decl [concrete = constants.%Enum]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %b: %Enum = value_binding b, %.loc9_40.2
|
||||
// CHECK:STDOUT: name_binding_decl {
|
||||
// CHECK:STDOUT: %c.patt: %pattern_type.c06 = value_binding_pattern c [concrete]
|
||||
// CHECK:STDOUT: %c.patt: %pattern_type.da8 = value_binding_pattern c [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Cpp.ref.loc10_29: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %a.ref.loc10: %Enum = name_ref a, imports.%int_0 [concrete = constants.%int_0.420]
|
||||
// CHECK:STDOUT: %a.ref.loc10: %Enum = name_ref a, imports.%int_0 [concrete = constants.%int_0.779]
|
||||
// CHECK:STDOUT: %Cpp.ref.loc10_38: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Other.ref.loc10_41: type = name_ref Other, imports.%Other.decl [concrete = constants.%Other]
|
||||
// CHECK:STDOUT: %.loc10_35.1: %Other = as_compatible %a.ref.loc10 [concrete = constants.%int_0.fa2]
|
||||
// CHECK:STDOUT: %.loc10_35.2: %Other = converted %a.ref.loc10, %.loc10_35.1 [concrete = constants.%int_0.fa2]
|
||||
// CHECK:STDOUT: %.loc10_35.1: %Other = as_compatible %a.ref.loc10 [concrete = constants.%int_0.9f3]
|
||||
// CHECK:STDOUT: %.loc10_35.2: %Other = converted %a.ref.loc10, %.loc10_35.1 [concrete = constants.%int_0.9f3]
|
||||
// CHECK:STDOUT: %.loc10_20: type = splice_block %Other.ref.loc10_20 [concrete = constants.%Other] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc10_17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Other.ref.loc10_20: type = name_ref Other, imports.%Other.decl [concrete = constants.%Other]
|
||||
|
||||
Reference in New Issue
Block a user