| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- // 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/class/fail_adapt_bad_decl.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_adapt_bad_decl.carbon
- // --- fail_not_type.carbon
- library "[[@TEST_NAME]]";
- class Bad {
- // CHECK:STDERR: fail_not_type.carbon:[[@LINE+7]]:3: error: cannot implicitly convert from `i32` to `type` [ImplicitAsConversionFailure]
- // CHECK:STDERR: adapt 100;
- // CHECK:STDERR: ^~~~~~~~~~
- // CHECK:STDERR: fail_not_type.carbon:[[@LINE+4]]:3: note: type `i32` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
- // CHECK:STDERR: adapt 100;
- // CHECK:STDERR: ^~~~~~~~~~
- // CHECK:STDERR:
- adapt 100;
- }
- // CHECK:STDERR: fail_not_type.carbon:[[@LINE+4]]:18: error: name `F` not found [NameNotFound]
- // CHECK:STDERR: fn Use(b: Bad) { b.F(); }
- // CHECK:STDERR: ^~~
- // CHECK:STDERR:
- fn Use(b: Bad) { b.F(); }
- // --- fail_extend_not_type.carbon
- library "[[@TEST_NAME]]";
- class Bad {
- // CHECK:STDERR: fail_extend_not_type.carbon:[[@LINE+7]]:3: error: cannot implicitly convert from `i32` to `type` [ImplicitAsConversionFailure]
- // CHECK:STDERR: extend adapt 100;
- // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
- // CHECK:STDERR: fail_extend_not_type.carbon:[[@LINE+4]]:3: note: type `i32` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
- // CHECK:STDERR: extend adapt 100;
- // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
- // CHECK:STDERR:
- extend adapt 100;
- }
- // No diagnostic here, we don't know what names Bad has.
- fn Use(b: Bad) { b.F(); }
- // --- fail_repeated.carbon
- library "[[@TEST_NAME]]";
- class MultipleAdapts {
- adapt ();
- // CHECK:STDERR: fail_repeated.carbon:[[@LINE+7]]:3: error: multiple `adapt` declarations in class [AdaptDeclRepeated]
- // CHECK:STDERR: adapt {};
- // CHECK:STDERR: ^~~~~~~~~
- // CHECK:STDERR: fail_repeated.carbon:[[@LINE-4]]:3: note: previous `adapt` declaration is here [ClassSpecificDeclPrevious]
- // CHECK:STDERR: adapt ();
- // CHECK:STDERR: ^~~~~~~~~
- // CHECK:STDERR:
- adapt {};
- }
- class MultipleAdaptsSameType {
- adapt ();
- // CHECK:STDERR: fail_repeated.carbon:[[@LINE+7]]:3: error: multiple `adapt` declarations in class [AdaptDeclRepeated]
- // CHECK:STDERR: adapt ();
- // CHECK:STDERR: ^~~~~~~~~
- // CHECK:STDERR: fail_repeated.carbon:[[@LINE-4]]:3: note: previous `adapt` declaration is here [ClassSpecificDeclPrevious]
- // CHECK:STDERR: adapt ();
- // CHECK:STDERR: ^~~~~~~~~
- // CHECK:STDERR:
- adapt ();
- }
- // --- fail_bad_scope.carbon
- library "[[@TEST_NAME]]";
- // CHECK:STDERR: fail_bad_scope.carbon:[[@LINE+4]]:1: error: `adapt` declaration outside class [ClassSpecificDeclOutsideClass]
- // CHECK:STDERR: adapt {};
- // CHECK:STDERR: ^~~~~~~~~
- // CHECK:STDERR:
- adapt {};
- interface I {
- // CHECK:STDERR: fail_bad_scope.carbon:[[@LINE+4]]:3: error: `adapt` declaration outside class [ClassSpecificDeclOutsideClass]
- // CHECK:STDERR: adapt {};
- // CHECK:STDERR: ^~~~~~~~~
- // CHECK:STDERR:
- adapt {};
- }
- class C {
- interface I {
- // CHECK:STDERR: fail_bad_scope.carbon:[[@LINE+3]]:5: error: `adapt` declaration outside class [ClassSpecificDeclOutsideClass]
- // CHECK:STDERR: adapt {};
- // CHECK:STDERR: ^~~~~~~~~
- adapt {};
- }
- }
- // CHECK:STDOUT: --- fail_not_type.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %Bad: type = class_type @Bad [template]
- // CHECK:STDOUT: %.1: i32 = int_value 100 [template]
- // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
- // CHECK:STDOUT: %.2: type = tuple_type () [template]
- // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
- // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
- // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
- // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
- // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
- // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
- // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
- // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
- // CHECK:STDOUT: %.3: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
- // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, imports.%import_ref.5 [symbolic]
- // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(type) [template]
- // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(type) [template]
- // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
- // CHECK:STDOUT: %.5: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
- // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.5 [template]
- // CHECK:STDOUT: %.7: %.3 = assoc_entity element0, imports.%import_ref.6 [symbolic]
- // CHECK:STDOUT: %Use.type: type = fn_type @Use [template]
- // CHECK:STDOUT: %Use: %Use.type = struct_value () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: .ImplicitAs = %import_ref.1
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/...
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.1: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs]
- // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+55, unloaded
- // CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.1 (%.3) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.7)]
- // CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+70, unloaded
- // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+70, unloaded
- // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+70, unloaded
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Core = imports.%Core
- // CHECK:STDOUT: .Bad = %Bad.decl
- // CHECK:STDOUT: .Use = %Use.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %Bad.decl: type = class_decl @Bad [template = constants.%Bad] {} {}
- // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] {
- // CHECK:STDOUT: %b.patt: %Bad = binding_pattern b
- // CHECK:STDOUT: %b.param_patt: %Bad = value_param_pattern %b.patt, runtime_param0
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %Bad.ref: type = name_ref Bad, file.%Bad.decl [template = constants.%Bad]
- // CHECK:STDOUT: %b.param: %Bad = value_param runtime_param0
- // CHECK:STDOUT: %b: %Bad = bind_name b, %b.param
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
- // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
- // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
- // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
- // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
- // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
- // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.3)]
- // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.3) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.2 (constants.%.4)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: interface {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = imports.%import_ref.2
- // CHECK:STDOUT: .Convert = imports.%import_ref.3
- // CHECK:STDOUT: witness = (imports.%import_ref.4)
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @Bad {
- // CHECK:STDOUT: %.loc12_9: i32 = int_value 100 [template = constants.%.1]
- // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(type) [template = constants.%ImplicitAs.type.3]
- // CHECK:STDOUT: %.loc12_12.1: %.5 = specific_constant imports.%import_ref.3, @ImplicitAs(type) [template = constants.%.6]
- // CHECK:STDOUT: %Convert.ref: %.5 = name_ref Convert, %.loc12_12.1 [template = constants.%.6]
- // CHECK:STDOUT: %.loc12_12.2: type = converted %.loc12_9, <error> [template = <error>]
- // CHECK:STDOUT: adapt_decl <error>
- // CHECK:STDOUT: %.loc13: <witness> = complete_type_witness <error> [template = <error>]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%Bad
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
- // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
- // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
- // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Use(%b.param_patt: %Bad) {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %b.ref: %Bad = name_ref b, %b
- // CHECK:STDOUT: %F.ref: <error> = name_ref F, <error> [template = <error>]
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: %Dest.patt => constants.%Dest
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: %Dest.patt => constants.%Dest
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: %Dest.patt => constants.%Dest
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
- // CHECK:STDOUT: %Self => constants.%Self.1
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(type) {
- // CHECK:STDOUT: %Dest => type
- // CHECK:STDOUT: %Dest.patt => type
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
- // CHECK:STDOUT: %Self => constants.%Self.2
- // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
- // CHECK:STDOUT: %Convert => constants.%Convert.2
- // CHECK:STDOUT: %.1 => constants.%.5
- // CHECK:STDOUT: %.2 => constants.%.6
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_extend_not_type.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %Bad: type = class_type @Bad [template]
- // CHECK:STDOUT: %.1: i32 = int_value 100 [template]
- // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
- // CHECK:STDOUT: %.2: type = tuple_type () [template]
- // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
- // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
- // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
- // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
- // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
- // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
- // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
- // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
- // CHECK:STDOUT: %.3: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
- // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, imports.%import_ref.5 [symbolic]
- // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(type) [template]
- // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(type) [template]
- // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
- // CHECK:STDOUT: %.5: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
- // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.5 [template]
- // CHECK:STDOUT: %.7: %.3 = assoc_entity element0, imports.%import_ref.6 [symbolic]
- // CHECK:STDOUT: %Use.type: type = fn_type @Use [template]
- // CHECK:STDOUT: %Use: %Use.type = struct_value () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: .ImplicitAs = %import_ref.1
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/...
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.1: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs]
- // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+55, unloaded
- // CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.1 (%.3) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.7)]
- // CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+70, unloaded
- // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+70, unloaded
- // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+70, unloaded
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Core = imports.%Core
- // CHECK:STDOUT: .Bad = %Bad.decl
- // CHECK:STDOUT: .Use = %Use.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %Bad.decl: type = class_decl @Bad [template = constants.%Bad] {} {}
- // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] {
- // CHECK:STDOUT: %b.patt: %Bad = binding_pattern b
- // CHECK:STDOUT: %b.param_patt: %Bad = value_param_pattern %b.patt, runtime_param0
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %Bad.ref: type = name_ref Bad, file.%Bad.decl [template = constants.%Bad]
- // CHECK:STDOUT: %b.param: %Bad = value_param runtime_param0
- // CHECK:STDOUT: %b: %Bad = bind_name b, %b.param
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
- // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
- // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
- // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
- // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
- // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
- // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.3)]
- // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.3) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.2 (constants.%.4)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: interface {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = imports.%import_ref.2
- // CHECK:STDOUT: .Convert = imports.%import_ref.3
- // CHECK:STDOUT: witness = (imports.%import_ref.4)
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @Bad {
- // CHECK:STDOUT: %.loc12_16: i32 = int_value 100 [template = constants.%.1]
- // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(type) [template = constants.%ImplicitAs.type.3]
- // CHECK:STDOUT: %.loc12_19.1: %.5 = specific_constant imports.%import_ref.3, @ImplicitAs(type) [template = constants.%.6]
- // CHECK:STDOUT: %Convert.ref: %.5 = name_ref Convert, %.loc12_19.1 [template = constants.%.6]
- // CHECK:STDOUT: %.loc12_19.2: type = converted %.loc12_16, <error> [template = <error>]
- // CHECK:STDOUT: adapt_decl <error>
- // CHECK:STDOUT: %.loc13: <witness> = complete_type_witness <error> [template = <error>]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%Bad
- // CHECK:STDOUT: has_error
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
- // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
- // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
- // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Use(%b.param_patt: %Bad) {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %b.ref: %Bad = name_ref b, %b
- // CHECK:STDOUT: %F.ref: <error> = name_ref F, <error> [template = <error>]
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: %Dest.patt => constants.%Dest
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: %Dest.patt => constants.%Dest
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: %Dest.patt => constants.%Dest
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
- // CHECK:STDOUT: %Self => constants.%Self.1
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(type) {
- // CHECK:STDOUT: %Dest => type
- // CHECK:STDOUT: %Dest.patt => type
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
- // CHECK:STDOUT: %Self => constants.%Self.2
- // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
- // CHECK:STDOUT: %Convert => constants.%Convert.2
- // CHECK:STDOUT: %.1 => constants.%.5
- // CHECK:STDOUT: %.2 => constants.%.6
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_repeated.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %MultipleAdapts: type = class_type @MultipleAdapts [template]
- // CHECK:STDOUT: %.1: type = tuple_type () [template]
- // CHECK:STDOUT: %.2: type = struct_type {} [template]
- // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.1 [template]
- // CHECK:STDOUT: %MultipleAdaptsSameType: type = class_type @MultipleAdaptsSameType [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: .MultipleAdapts = %MultipleAdapts.decl
- // CHECK:STDOUT: .MultipleAdaptsSameType = %MultipleAdaptsSameType.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %MultipleAdapts.decl: type = class_decl @MultipleAdapts [template = constants.%MultipleAdapts] {} {}
- // CHECK:STDOUT: %MultipleAdaptsSameType.decl: type = class_decl @MultipleAdaptsSameType [template = constants.%MultipleAdaptsSameType] {} {}
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @MultipleAdapts {
- // CHECK:STDOUT: %.loc5_10: %.1 = tuple_literal ()
- // CHECK:STDOUT: %.loc5_11: type = converted %.loc5_10, constants.%.1 [template = constants.%.1]
- // CHECK:STDOUT: adapt_decl %.1
- // CHECK:STDOUT: %.loc13: %.2 = struct_literal ()
- // CHECK:STDOUT: %.loc14: <witness> = complete_type_witness %.1 [template = constants.%.3]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%MultipleAdapts
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @MultipleAdaptsSameType {
- // CHECK:STDOUT: %.loc17_10: %.1 = tuple_literal ()
- // CHECK:STDOUT: %.loc17_11: type = converted %.loc17_10, constants.%.1 [template = constants.%.1]
- // CHECK:STDOUT: adapt_decl %.1
- // CHECK:STDOUT: %.loc25: %.1 = tuple_literal ()
- // CHECK:STDOUT: %.loc26: <witness> = complete_type_witness %.1 [template = constants.%.3]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%MultipleAdaptsSameType
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_bad_scope.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %.1: type = struct_type {} [template]
- // CHECK:STDOUT: %I.type.1: type = interface_type @I.1 [template]
- // CHECK:STDOUT: %Self.1: %I.type.1 = bind_symbolic_name Self, 0 [symbolic]
- // CHECK:STDOUT: %C: type = class_type @C [template]
- // CHECK:STDOUT: %I.type.2: type = interface_type @I.2 [template]
- // CHECK:STDOUT: %Self.2: %I.type.2 = bind_symbolic_name Self, 0 [symbolic]
- // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [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: .C = %C.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %.loc8: %.1 = struct_literal ()
- // CHECK:STDOUT: %I.decl: type = interface_decl @I.1 [template = constants.%I.type.1] {} {}
- // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: interface @I.1 {
- // CHECK:STDOUT: %Self: %I.type.1 = bind_symbolic_name Self, 0 [symbolic = constants.%Self.1]
- // CHECK:STDOUT: %.loc15: %.1 = struct_literal ()
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = %Self
- // CHECK:STDOUT: witness = ()
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: interface @I.2 {
- // CHECK:STDOUT: %Self: %I.type.2 = bind_symbolic_name Self, 0 [symbolic = constants.%Self.2]
- // CHECK:STDOUT: %.loc23: %.1 = struct_literal ()
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = %Self
- // CHECK:STDOUT: witness = ()
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C {
- // CHECK:STDOUT: %I.decl: type = interface_decl @I.2 [template = constants.%I.type.2] {} {}
- // CHECK:STDOUT: %.loc25: <witness> = complete_type_witness %.1 [template = constants.%.2]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%C
- // CHECK:STDOUT: .I = %I.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|