mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-01 10:04:59 +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.
322 lines
23 KiB
Plaintext
322 lines
23 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/int.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/class/inheritance/base.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/inheritance/base.carbon
|
|
|
|
// --- base.carbon
|
|
package Base;
|
|
|
|
base class Base {
|
|
var b: i32;
|
|
}
|
|
|
|
class Derived {
|
|
extend base: Base;
|
|
|
|
var d: i32;
|
|
}
|
|
|
|
fn Make() -> Derived {
|
|
return {.base = {.b = 4}, .d = 7};
|
|
}
|
|
|
|
fn Access(d: Derived) -> (i32, i32) {
|
|
return (d.d, d.base.b);
|
|
}
|
|
|
|
// --- fail_base_after_field.carbon
|
|
package BaseAfterField;
|
|
|
|
base class Base {
|
|
}
|
|
|
|
class Derived {
|
|
var d: i32;
|
|
|
|
// CHECK:STDERR: fail_base_after_field.carbon:[[@LINE+4]]:3: error: `base` declaration must appear before field declarations [BaseDeclAfterFieldDecl]
|
|
// CHECK:STDERR: extend base: Base;
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
extend base: Base;
|
|
}
|
|
|
|
// CHECK:STDOUT: --- base.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %Base: type = class_type @Base [concrete]
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
|
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
|
|
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Base.elem: type = unbound_element_type %Base, %i32 [concrete]
|
|
// CHECK:STDOUT: %struct_type.b.177: type = struct_type {.b: %i32} [concrete]
|
|
// CHECK:STDOUT: %complete_type.421: <witness> = complete_type_witness %struct_type.b.177 [concrete]
|
|
// CHECK:STDOUT: %Derived: type = class_type @Derived [concrete]
|
|
// CHECK:STDOUT: %Derived.elem.24a: type = unbound_element_type %Derived, %Base [concrete]
|
|
// CHECK:STDOUT: %Derived.elem.757: type = unbound_element_type %Derived, %i32 [concrete]
|
|
// CHECK:STDOUT: %struct_type.base.d.c78: type = struct_type {.base: %Base, .d: %i32} [concrete]
|
|
// CHECK:STDOUT: %complete_type.328: <witness> = complete_type_witness %struct_type.base.d.c78 [concrete]
|
|
// CHECK:STDOUT: %.aab: Core.Form = init_form %Derived [concrete]
|
|
// CHECK:STDOUT: %pattern_type.f2f: type = pattern_type %Derived [concrete]
|
|
// CHECK:STDOUT: %Make.type: type = fn_type @Make [concrete]
|
|
// CHECK:STDOUT: %Make: %Make.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [concrete]
|
|
// CHECK:STDOUT: %struct_type.b.a15: type = struct_type {.b: Core.IntLiteral} [concrete]
|
|
// CHECK:STDOUT: %struct.a2e: %struct_type.b.a15 = struct_value (%int_4.0c1) [concrete]
|
|
// CHECK:STDOUT: %int_7.29f: Core.IntLiteral = int_value 7 [concrete]
|
|
// CHECK:STDOUT: %struct_type.base.d.a20: type = struct_type {.base: %struct_type.b.a15, .d: Core.IntLiteral} [concrete]
|
|
// CHECK:STDOUT: %struct.ab7: %struct_type.base.d.a20 = struct_value (%struct.a2e, %int_7.29f) [concrete]
|
|
// CHECK:STDOUT: %.b5a: type = partial_type %Base [concrete]
|
|
// CHECK:STDOUT: %ImplicitAs.type.649: type = generic_interface_type @ImplicitAs [concrete]
|
|
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.649 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %ImplicitAs.type.544: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
|
|
// CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
|
|
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.766: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
|
|
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.ec3: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.766 = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %ImplicitAs.impl_witness.fb6: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.1a5, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.ef7: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e6b: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.ef7 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.544 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.fb6) [concrete]
|
|
// CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.367: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete]
|
|
// CHECK:STDOUT: %.205: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.367, %ImplicitAs.facet [concrete]
|
|
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.30c: <bound method> = bound_method %int_4.0c1, %Core.IntLiteral.as.ImplicitAs.impl.Convert.e6b [concrete]
|
|
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.e6b, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
|
|
// CHECK:STDOUT: %bound_method.bef: <bound method> = bound_method %int_4.0c1, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
|
|
// CHECK:STDOUT: %int_4.a7d: %i32 = int_value 4 [concrete]
|
|
// CHECK:STDOUT: %struct.145: %.b5a = struct_value (%int_4.a7d) [concrete]
|
|
// CHECK:STDOUT: %Base.val: %Base = struct_value (%int_4.a7d) [concrete]
|
|
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.dbb: <bound method> = bound_method %int_7.29f, %Core.IntLiteral.as.ImplicitAs.impl.Convert.e6b [concrete]
|
|
// CHECK:STDOUT: %bound_method.a24: <bound method> = bound_method %int_7.29f, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
|
|
// CHECK:STDOUT: %int_7.0de: %i32 = int_value 7 [concrete]
|
|
// CHECK:STDOUT: %Derived.val: %Derived = struct_value (%Base.val, %int_7.0de) [concrete]
|
|
// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [concrete]
|
|
// CHECK:STDOUT: %tuple.8e3: %tuple.type.24b = tuple_value (%i32, %i32) [concrete]
|
|
// CHECK:STDOUT: %tuple.type.87c: type = tuple_type (%i32, %i32) [concrete]
|
|
// CHECK:STDOUT: %.88c: Core.Form = init_form %tuple.type.87c [concrete]
|
|
// CHECK:STDOUT: %pattern_type.624: type = pattern_type %tuple.type.87c [concrete]
|
|
// CHECK:STDOUT: %Access.type: type = fn_type @Access [concrete]
|
|
// CHECK:STDOUT: %Access: %Access.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.b5d: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.c85: %Int.as.Copy.impl.Op.type.b5d = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %Copy.impl_witness.32d: <witness> = impl_witness imports.%Copy.impl_witness_table.07a, @Int.as.Copy.impl(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.4a0: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.c4a: %Int.as.Copy.impl.Op.type.4a0 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i32, (%Copy.impl_witness.32d) [concrete]
|
|
// CHECK:STDOUT: %Copy.WithSelf.Op.type.afe: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [concrete]
|
|
// CHECK:STDOUT: %.a5f: type = fn_type_with_self_type %Copy.WithSelf.Op.type.afe, %Copy.facet [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.c4a, @Int.as.Copy.impl.Op(%int_32) [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
|
|
// CHECK:STDOUT: .Int = %Core.Int
|
|
// CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
|
|
// CHECK:STDOUT: .Copy = %Core.Copy
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
|
|
// CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.649 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
|
|
// CHECK:STDOUT: %Core.import_ref.dd3: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.766) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.ec3)]
|
|
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.1a5 = impl_witness_table (%Core.import_ref.dd3), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
|
|
// CHECK:STDOUT: %Core.Copy: type = import_ref Core//prelude/parts/copy, Copy, loaded [concrete = constants.%Copy.type]
|
|
// CHECK:STDOUT: %Core.import_ref.809: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.b5d) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.c85)]
|
|
// CHECK:STDOUT: %Copy.impl_witness_table.07a = impl_witness_table (%Core.import_ref.809), @Int.as.Copy.impl [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .Base = %Base.decl
|
|
// CHECK:STDOUT: .Derived = %Derived.decl
|
|
// CHECK:STDOUT: .Make = %Make.decl
|
|
// CHECK:STDOUT: .Access = %Access.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %Base.decl: type = class_decl @Base [concrete = constants.%Base] {} {}
|
|
// CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [concrete = constants.%Derived] {} {}
|
|
// CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [concrete = constants.%Make] {
|
|
// CHECK:STDOUT: %return.param_patt: %pattern_type.f2f = out_param_pattern [concrete]
|
|
// CHECK:STDOUT: %return.patt: %pattern_type.f2f = return_slot_pattern %return.param_patt, %Derived.ref [concrete]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived]
|
|
// CHECK:STDOUT: %.loc13: Core.Form = init_form %Derived.ref [concrete = constants.%.aab]
|
|
// CHECK:STDOUT: %return.param: ref %Derived = out_param call_param0
|
|
// CHECK:STDOUT: %return: ref %Derived = return_slot %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Access.decl: %Access.type = fn_decl @Access [concrete = constants.%Access] {
|
|
// CHECK:STDOUT: %d.param_patt: %pattern_type.f2f = value_param_pattern [concrete]
|
|
// CHECK:STDOUT: %d.patt: %pattern_type.f2f = at_binding_pattern d, %d.param_patt [concrete]
|
|
// CHECK:STDOUT: %return.param_patt: %pattern_type.624 = out_param_pattern [concrete]
|
|
// CHECK:STDOUT: %return.patt: %pattern_type.624 = return_slot_pattern %return.param_patt, %.loc17_35.2 [concrete]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %i32.loc17_27: type = type_literal constants.%i32 [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %i32.loc17_32: type = type_literal constants.%i32 [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %.loc17_35.1: %tuple.type.24b = tuple_literal (%i32.loc17_27, %i32.loc17_32) [concrete = constants.%tuple.8e3]
|
|
// CHECK:STDOUT: %.loc17_35.2: type = converted %.loc17_35.1, constants.%tuple.type.87c [concrete = constants.%tuple.type.87c]
|
|
// CHECK:STDOUT: %.loc17_35.3: Core.Form = init_form %.loc17_35.2 [concrete = constants.%.88c]
|
|
// CHECK:STDOUT: %d.param: %Derived = value_param call_param0
|
|
// CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived]
|
|
// CHECK:STDOUT: %d: %Derived = value_binding d, %d.param
|
|
// CHECK:STDOUT: %return.param: ref %tuple.type.87c = out_param call_param1
|
|
// CHECK:STDOUT: %return: ref %tuple.type.87c = return_slot %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Base {
|
|
// CHECK:STDOUT: %.loc4: %Base.elem = field_decl b, element0 [concrete]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.b.177 [concrete = constants.%complete_type.421]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%Base
|
|
// CHECK:STDOUT: .b = %.loc4
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Derived {
|
|
// CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
|
|
// CHECK:STDOUT: %.loc8: %Derived.elem.24a = base_decl %Base.ref, element0 [concrete]
|
|
// CHECK:STDOUT: %.loc10: %Derived.elem.757 = field_decl d, element1 [concrete]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.base.d.c78 [concrete = constants.%complete_type.328]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%Derived
|
|
// CHECK:STDOUT: .Base = <poisoned>
|
|
// CHECK:STDOUT: .base = %.loc8
|
|
// CHECK:STDOUT: .d = %.loc10
|
|
// CHECK:STDOUT: extend %Base.ref
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Make() -> out %return.param: %Derived {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1]
|
|
// CHECK:STDOUT: %.loc14_26.1: %struct_type.b.a15 = struct_literal (%int_4) [concrete = constants.%struct.a2e]
|
|
// CHECK:STDOUT: %int_7: Core.IntLiteral = int_value 7 [concrete = constants.%int_7.29f]
|
|
// CHECK:STDOUT: %.loc14_35.1: %struct_type.base.d.a20 = struct_literal (%.loc14_26.1, %int_7) [concrete = constants.%struct.ab7]
|
|
// CHECK:STDOUT: %impl.elem0.loc14_26: %.205 = impl_witness_access constants.%ImplicitAs.impl_witness.fb6, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e6b]
|
|
// CHECK:STDOUT: %bound_method.loc14_26.1: <bound method> = bound_method %int_4, %impl.elem0.loc14_26 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.30c]
|
|
// CHECK:STDOUT: %specific_fn.loc14_26: <specific function> = specific_function %impl.elem0.loc14_26, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc14_26.2: <bound method> = bound_method %int_4, %specific_fn.loc14_26 [concrete = constants.%bound_method.bef]
|
|
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14_26: init %i32 = call %bound_method.loc14_26.2(%int_4) [concrete = constants.%int_4.a7d]
|
|
// CHECK:STDOUT: %.loc14_26.2: init %i32 = converted %int_4, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14_26 [concrete = constants.%int_4.a7d]
|
|
// CHECK:STDOUT: %.loc14_35.2: ref %.b5a = class_element_access %return.param, element0
|
|
// CHECK:STDOUT: %.loc14_26.3: ref %i32 = class_element_access %.loc14_35.2, element0
|
|
// CHECK:STDOUT: %.loc14_26.4: init %i32 to %.loc14_26.3 = in_place_init %.loc14_26.2 [concrete = constants.%int_4.a7d]
|
|
// CHECK:STDOUT: %.loc14_26.5: init %.b5a to %.loc14_35.2 = class_init (%.loc14_26.4) [concrete = constants.%struct.145]
|
|
// CHECK:STDOUT: %.loc14_35.3: init %.b5a = converted %.loc14_26.1, %.loc14_26.5 [concrete = constants.%struct.145]
|
|
// CHECK:STDOUT: %.loc14_35.4: init %Base = as_compatible %.loc14_35.3 [concrete = constants.%Base.val]
|
|
// CHECK:STDOUT: %impl.elem0.loc14_35: %.205 = impl_witness_access constants.%ImplicitAs.impl_witness.fb6, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e6b]
|
|
// CHECK:STDOUT: %bound_method.loc14_35.1: <bound method> = bound_method %int_7, %impl.elem0.loc14_35 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.dbb]
|
|
// CHECK:STDOUT: %specific_fn.loc14_35: <specific function> = specific_function %impl.elem0.loc14_35, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc14_35.2: <bound method> = bound_method %int_7, %specific_fn.loc14_35 [concrete = constants.%bound_method.a24]
|
|
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14_35: init %i32 = call %bound_method.loc14_35.2(%int_7) [concrete = constants.%int_7.0de]
|
|
// CHECK:STDOUT: %.loc14_35.5: init %i32 = converted %int_7, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14_35 [concrete = constants.%int_7.0de]
|
|
// CHECK:STDOUT: %.loc14_35.6: ref %i32 = class_element_access %return.param, element1
|
|
// CHECK:STDOUT: %.loc14_35.7: init %i32 to %.loc14_35.6 = in_place_init %.loc14_35.5 [concrete = constants.%int_7.0de]
|
|
// CHECK:STDOUT: %.loc14_35.8: init %Derived to %return.param = class_init (%.loc14_35.4, %.loc14_35.7) [concrete = constants.%Derived.val]
|
|
// CHECK:STDOUT: %.loc14_36: init %Derived = converted %.loc14_35.1, %.loc14_35.8 [concrete = constants.%Derived.val]
|
|
// CHECK:STDOUT: return %.loc14_36 to %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Access(%d.param: %Derived) -> out %return.param: %tuple.type.87c {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %d.ref.loc18_11: %Derived = name_ref d, %d
|
|
// CHECK:STDOUT: %d.ref.loc18_12: %Derived.elem.757 = name_ref d, @Derived.%.loc10 [concrete = @Derived.%.loc10]
|
|
// CHECK:STDOUT: %.loc18_12.1: ref %i32 = class_element_access %d.ref.loc18_11, element1
|
|
// CHECK:STDOUT: %.loc18_12.2: %i32 = acquire_value %.loc18_12.1
|
|
// CHECK:STDOUT: %d.ref.loc18_16: %Derived = name_ref d, %d
|
|
// CHECK:STDOUT: %base.ref: %Derived.elem.24a = name_ref base, @Derived.%.loc8 [concrete = @Derived.%.loc8]
|
|
// CHECK:STDOUT: %.loc18_17.1: ref %Base = class_element_access %d.ref.loc18_16, element0
|
|
// CHECK:STDOUT: %.loc18_17.2: %Base = acquire_value %.loc18_17.1
|
|
// CHECK:STDOUT: %b.ref: %Base.elem = name_ref b, @Base.%.loc4 [concrete = @Base.%.loc4]
|
|
// CHECK:STDOUT: %.loc18_22.1: ref %i32 = class_element_access %.loc18_17.2, element0
|
|
// CHECK:STDOUT: %.loc18_22.2: %i32 = acquire_value %.loc18_22.1
|
|
// CHECK:STDOUT: %.loc18_24.1: %tuple.type.87c = tuple_literal (%.loc18_12.2, %.loc18_22.2)
|
|
// CHECK:STDOUT: %impl.elem0.loc18_12: %.a5f = impl_witness_access constants.%Copy.impl_witness.32d, element0 [concrete = constants.%Int.as.Copy.impl.Op.c4a]
|
|
// CHECK:STDOUT: %bound_method.loc18_12.1: <bound method> = bound_method %.loc18_12.2, %impl.elem0.loc18_12
|
|
// CHECK:STDOUT: %specific_fn.loc18_12: <specific function> = specific_function %impl.elem0.loc18_12, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc18_12.2: <bound method> = bound_method %.loc18_12.2, %specific_fn.loc18_12
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc18_12: init %i32 = call %bound_method.loc18_12.2(%.loc18_12.2)
|
|
// CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %return.param, element0
|
|
// CHECK:STDOUT: %.loc18_24.2: init %i32 to %tuple.elem0 = in_place_init %Int.as.Copy.impl.Op.call.loc18_12
|
|
// CHECK:STDOUT: %impl.elem0.loc18_22: %.a5f = impl_witness_access constants.%Copy.impl_witness.32d, element0 [concrete = constants.%Int.as.Copy.impl.Op.c4a]
|
|
// CHECK:STDOUT: %bound_method.loc18_22.1: <bound method> = bound_method %.loc18_22.2, %impl.elem0.loc18_22
|
|
// CHECK:STDOUT: %specific_fn.loc18_22: <specific function> = specific_function %impl.elem0.loc18_22, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc18_22.2: <bound method> = bound_method %.loc18_22.2, %specific_fn.loc18_22
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc18_22: init %i32 = call %bound_method.loc18_22.2(%.loc18_22.2)
|
|
// CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access %return.param, element1
|
|
// CHECK:STDOUT: %.loc18_24.3: init %i32 to %tuple.elem1 = in_place_init %Int.as.Copy.impl.Op.call.loc18_22
|
|
// CHECK:STDOUT: %.loc18_24.4: init %tuple.type.87c to %return.param = tuple_init (%.loc18_24.2, %.loc18_24.3)
|
|
// CHECK:STDOUT: %.loc18_25: init %tuple.type.87c = converted %.loc18_24.1, %.loc18_24.4
|
|
// CHECK:STDOUT: return %.loc18_25 to %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- fail_base_after_field.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %Base: type = class_type @Base [concrete]
|
|
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
|
|
// CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
|
|
// CHECK:STDOUT: %Derived: type = class_type @Derived [concrete]
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
|
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
|
|
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %i32 [concrete]
|
|
// CHECK:STDOUT: %struct_type.d: type = struct_type {.d: %i32} [concrete]
|
|
// CHECK:STDOUT: %complete_type.c69: <witness> = complete_type_witness %struct_type.d [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
|
|
// CHECK:STDOUT: .Int = %Core.Int
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .Base = %Base.decl
|
|
// CHECK:STDOUT: .Derived = %Derived.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %Base.decl: type = class_decl @Base [concrete = constants.%Base] {} {}
|
|
// CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [concrete = constants.%Derived] {} {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Base {
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%Base
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Derived {
|
|
// CHECK:STDOUT: %.loc7: %Derived.elem = field_decl d, element0 [concrete]
|
|
// CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.d [concrete = constants.%complete_type.c69]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%Derived
|
|
// CHECK:STDOUT: .d = %.loc7
|
|
// CHECK:STDOUT: .Base = <poisoned>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|