mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 22:02:51 +01:00
Fix import logic to make all imported packages be children of the `NameScopeId::Package` scope. Previously, indirectly-imported packages would end up as children of their importing package's scope, which resulted in them not being treated as packages at all, and in particular not being fingerprinted as packages. Fixing that caused a failure in the fingerprinting logic as we started to encounter packages with no correspoding import scopes. Instead of looking for import scopes, use a simpler mechanism to map packages to their package names, and clean up. Unfortunately the latter change churns all the fingerprints again :( Hopefully this is the last time for a while.
214 lines
10 KiB
Plaintext
214 lines
10 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/destroy.carbon
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/generic/call_basic_depth.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/generic/call_basic_depth.carbon
|
|
|
|
class C {
|
|
fn Cfn[unused self: Self, T:! type](unused x: T) {
|
|
}
|
|
}
|
|
|
|
//@dump-sem-ir-begin
|
|
fn F[T:! type](unused x: T) {
|
|
}
|
|
//@dump-sem-ir-end
|
|
|
|
fn H[T:! type](x: T) {
|
|
//@dump-sem-ir-begin
|
|
F(x);
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
fn G[T:! type](x: T) {
|
|
//@dump-sem-ir-begin
|
|
H(x);
|
|
F(x);
|
|
//@dump-sem-ir-end
|
|
|
|
var c: C = {};
|
|
c.Cfn(x);
|
|
}
|
|
|
|
fn M() {
|
|
var n: C = {};
|
|
|
|
//@dump-sem-ir-begin
|
|
F(n);
|
|
G(n);
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
// CHECK:STDOUT: --- call_basic_depth.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %C: type = class_type @C [concrete]
|
|
// CHECK:STDOUT: %pattern_type.98b: type = pattern_type %C [concrete]
|
|
// CHECK:STDOUT: %type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self]
|
|
// CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
|
|
// CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
|
|
// CHECK:STDOUT: %pattern_type.51d: type = pattern_type %T [symbolic]
|
|
// CHECK:STDOUT: %C.Cfn.type: type = fn_type @C.Cfn [concrete]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
|
// CHECK:STDOUT: %C.Cfn: %C.Cfn.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
|
|
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T [symbolic]
|
|
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
|
|
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %H.type: type = fn_type @H [concrete]
|
|
// CHECK:STDOUT: %H: %H.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %F.specific_fn.eab: <specific function> = specific_function %F, @F(%T) [symbolic]
|
|
// CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
|
|
// CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %H.specific_fn.e9c: <specific function> = specific_function %H, @H(%T) [symbolic]
|
|
// CHECK:STDOUT: %F.specific_fn.e0d: <specific function> = specific_function %F, @F(%C) [concrete]
|
|
// CHECK:STDOUT: %G.specific_fn: <specific function> = specific_function %G, @G(%C) [concrete]
|
|
// CHECK:STDOUT: %H.specific_fn.ca8: <specific function> = specific_function %H, @H(%C) [concrete]
|
|
// CHECK:STDOUT: %C.Cfn.specific_fn.380: <specific function> = specific_function %C.Cfn, @C.Cfn(%C) [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
|
|
// CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
|
|
// CHECK:STDOUT: %x.param_patt: @F.%pattern_type (%pattern_type.51d) = value_param_pattern [concrete]
|
|
// CHECK:STDOUT: %x.patt: @F.%pattern_type (%pattern_type.51d) = at_binding_pattern x, %x.param_patt [concrete]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %.loc19_10.1: type = splice_block %.loc19_10.2 [concrete = type] {
|
|
// CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
|
|
// CHECK:STDOUT: %.loc19_10.2: type = type_literal type [concrete = type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %T.loc19_7.2: type = symbolic_binding T, 0 [symbolic = %T.loc19_7.1 (constants.%T)]
|
|
// CHECK:STDOUT: %x.param: @F.%T.loc19_7.1 (%T) = value_param call_param0
|
|
// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc19_7.2 [symbolic = %T.loc19_7.1 (constants.%T)]
|
|
// CHECK:STDOUT: %x: @F.%T.loc19_7.1 (%T) = value_binding x, %x.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic fn @F(%T.loc19_7.2: type) {
|
|
// CHECK:STDOUT: %T.loc19_7.1: type = symbolic_binding T, 0 [symbolic = %T.loc19_7.1 (constants.%T)]
|
|
// CHECK:STDOUT: %pattern_type: type = pattern_type %T.loc19_7.1 [symbolic = %pattern_type (constants.%pattern_type.51d)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.loc19_7.1 [symbolic = %require_complete (constants.%require_complete)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn(%x.param: @F.%T.loc19_7.1 (%T)) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic fn @H(%T.loc23_7.2: type) {
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: %F.specific_fn.loc25_3.2: <specific function> = specific_function constants.%F, @F(%T.loc23_7.1) [symbolic = %F.specific_fn.loc25_3.2 (constants.%F.specific_fn.eab)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn(%x.param: @H.%T.loc23_7.1 (%T)) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
|
|
// CHECK:STDOUT: %x.ref: @H.%T.loc23_7.1 (%T) = name_ref x, %x
|
|
// CHECK:STDOUT: %F.specific_fn.loc25_3.1: <specific function> = specific_function %F.ref, @F(constants.%T) [symbolic = %F.specific_fn.loc25_3.2 (constants.%F.specific_fn.eab)]
|
|
// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.specific_fn.loc25_3.1(%x.ref)
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic fn @G(%T.loc29_7.2: type) {
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: %H.specific_fn.loc31_3.2: <specific function> = specific_function constants.%H, @H(%T.loc29_7.1) [symbolic = %H.specific_fn.loc31_3.2 (constants.%H.specific_fn.e9c)]
|
|
// CHECK:STDOUT: %F.specific_fn.loc32_3.2: <specific function> = specific_function constants.%F, @F(%T.loc29_7.1) [symbolic = %F.specific_fn.loc32_3.2 (constants.%F.specific_fn.eab)]
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn(%x.param: @G.%T.loc29_7.1 (%T)) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %H.ref: %H.type = name_ref H, file.%H.decl [concrete = constants.%H]
|
|
// CHECK:STDOUT: %x.ref.loc31: @G.%T.loc29_7.1 (%T) = name_ref x, %x
|
|
// CHECK:STDOUT: %H.specific_fn.loc31_3.1: <specific function> = specific_function %H.ref, @H(constants.%T) [symbolic = %H.specific_fn.loc31_3.2 (constants.%H.specific_fn.e9c)]
|
|
// CHECK:STDOUT: %H.call: init %empty_tuple.type = call %H.specific_fn.loc31_3.1(%x.ref.loc31)
|
|
// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
|
|
// CHECK:STDOUT: %x.ref.loc32: @G.%T.loc29_7.1 (%T) = name_ref x, %x
|
|
// CHECK:STDOUT: %F.specific_fn.loc32_3.1: <specific function> = specific_function %F.ref, @F(constants.%T) [symbolic = %F.specific_fn.loc32_3.2 (constants.%F.specific_fn.eab)]
|
|
// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.specific_fn.loc32_3.1(%x.ref.loc32)
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @M() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
|
|
// CHECK:STDOUT: %n.ref.loc43: ref %C = name_ref n, %n
|
|
// CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%C) [concrete = constants.%F.specific_fn.e0d]
|
|
// CHECK:STDOUT: %.loc43: %C = acquire_value %n.ref.loc43
|
|
// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.specific_fn(%.loc43)
|
|
// CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [concrete = constants.%G]
|
|
// CHECK:STDOUT: %n.ref.loc44: ref %C = name_ref n, %n
|
|
// CHECK:STDOUT: %G.specific_fn: <specific function> = specific_function %G.ref, @G(constants.%C) [concrete = constants.%G.specific_fn]
|
|
// CHECK:STDOUT: %.loc44: %C = acquire_value %n.ref.loc44
|
|
// CHECK:STDOUT: %G.call: init %empty_tuple.type = call %G.specific_fn(%.loc44)
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @F(constants.%T) {
|
|
// CHECK:STDOUT: %T.loc19_7.1 => constants.%T
|
|
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.51d
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %require_complete => constants.%require_complete
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @H(constants.%T) {
|
|
// CHECK:STDOUT: %T.loc23_7.1 => constants.%T
|
|
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.51d
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %require_complete => constants.%require_complete
|
|
// CHECK:STDOUT: %F.specific_fn.loc25_3.2 => constants.%F.specific_fn.eab
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @G(constants.%T) {
|
|
// CHECK:STDOUT: %T.loc29_7.1 => constants.%T
|
|
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.51d
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @F(constants.%C) {
|
|
// CHECK:STDOUT: %T.loc19_7.1 => constants.%C
|
|
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.98b
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %require_complete => constants.%complete_type
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @G(constants.%C) {
|
|
// CHECK:STDOUT: %T.loc29_7.1 => constants.%C
|
|
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.98b
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %require_complete => constants.%complete_type
|
|
// CHECK:STDOUT: %H.specific_fn.loc31_3.2 => constants.%H.specific_fn.ca8
|
|
// CHECK:STDOUT: %F.specific_fn.loc32_3.2 => constants.%F.specific_fn.e0d
|
|
// CHECK:STDOUT: %C.Cfn.specific_fn.loc36_4.2 => constants.%C.Cfn.specific_fn.380
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @H(constants.%C) {
|
|
// CHECK:STDOUT: %T.loc23_7.1 => constants.%C
|
|
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.98b
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %require_complete => constants.%complete_type
|
|
// CHECK:STDOUT: %F.specific_fn.loc25_3.2 => constants.%F.specific_fn.e0d
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|