| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- // 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/impl/fail_impl_as_scope.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_impl_as_scope.carbon
- // --- fail_global.carbon
- library "[[@TEST_NAME]]";
- interface Simple {
- fn F();
- }
- // CHECK:STDERR: fail_global.carbon:[[@LINE+4]]:6: error: `impl as` can only be used in a class [ImplAsOutsideClass]
- // CHECK:STDERR: impl as Simple {
- // CHECK:STDERR: ^~
- // CHECK:STDERR:
- impl as Simple {
- fn F() {}
- }
- // --- fail_function.carbon
- library "[[@TEST_NAME]]";
- interface Simple {
- fn F();
- }
- fn Function() {
- // CHECK:STDERR: fail_function.carbon:[[@LINE+4]]:8: error: `impl as` can only be used in a class [ImplAsOutsideClass]
- // CHECK:STDERR: impl as Simple {
- // CHECK:STDERR: ^~
- // CHECK:STDERR:
- impl as Simple {
- fn F() {}
- }
- }
- // CHECK:STDOUT: --- fail_global.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %Simple.type: type = facet_type <@Simple> [template]
- // CHECK:STDOUT: %Self: %Simple.type = bind_symbolic_name Self, 0 [symbolic]
- // CHECK:STDOUT: %F.type: type = fn_type @F [template]
- // CHECK:STDOUT: %F: %F.type = struct_value () [template]
- // CHECK:STDOUT: %Simple.assoc_type: type = assoc_entity_type %Simple.type [template]
- // CHECK:STDOUT: %assoc0: %Simple.assoc_type = assoc_entity element0, @Simple.%F.decl [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {}
- // CHECK:STDOUT:
- // CHECK:STDOUT: interface @Simple {
- // CHECK:STDOUT: %Self: %Simple.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
- // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
- // CHECK:STDOUT: %assoc0: %Simple.assoc_type = assoc_entity element0, %F.decl [template = constants.%assoc0]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = %Self
- // CHECK:STDOUT: .F = %assoc0
- // CHECK:STDOUT: witness = (%F.decl)
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic fn @F(@Simple.%Self: %Simple.type) {
- // CHECK:STDOUT: fn();
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @F(constants.%Self) {}
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_function.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %Simple.type: type = facet_type <@Simple> [template]
- // CHECK:STDOUT: %Self: %Simple.type = bind_symbolic_name Self, 0 [symbolic]
- // CHECK:STDOUT: %F.type: type = fn_type @F [template]
- // CHECK:STDOUT: %F: %F.type = struct_value () [template]
- // CHECK:STDOUT: %Simple.assoc_type: type = assoc_entity_type %Simple.type [template]
- // CHECK:STDOUT: %assoc0: %Simple.assoc_type = assoc_entity element0, @Simple.%F.decl [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {}
- // CHECK:STDOUT:
- // CHECK:STDOUT: interface @Simple {
- // CHECK:STDOUT: %Self: %Simple.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
- // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
- // CHECK:STDOUT: %assoc0: %Simple.assoc_type = assoc_entity element0, %F.decl [template = constants.%assoc0]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = %Self
- // CHECK:STDOUT: .F = %assoc0
- // CHECK:STDOUT: witness = (%F.decl)
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic fn @F(@Simple.%Self: %Simple.type) {
- // CHECK:STDOUT: fn();
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Function();
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @F(constants.%Self) {}
- // CHECK:STDOUT:
|