| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- // 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/no_prelude/fail_extend_impl_scope.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/no_prelude/fail_extend_impl_scope.carbon
- // --- fail_extend_impl_file_scope.carbon
- library "[[@TEST_NAME]]";
- interface I {}
- // CHECK:STDERR: fail_extend_impl_file_scope.carbon:[[@LINE+4]]:1: error: `extend impl` can only be used in a class [ExtendImplOutsideClass]
- // CHECK:STDERR: extend impl () as I {}
- // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
- // CHECK:STDERR:
- extend impl () as I {}
- // --- fail_extend_impl_function_scope.carbon
- library "[[@TEST_NAME]]";
- interface J {}
- fn F() {
- // CHECK:STDERR: fail_extend_impl_function_scope.carbon:[[@LINE+4]]:3: error: `extend impl` can only be used in a class [ExtendImplOutsideClass]
- // CHECK:STDERR: extend impl {} as J {}
- // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
- // CHECK:STDERR:
- extend impl {} as J {}
- }
- // CHECK:STDOUT: --- fail_extend_impl_file_scope.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
- // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
- // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
- // CHECK:STDOUT: %impl_witness: <witness> = impl_witness () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .I = %I.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
- // CHECK:STDOUT: impl_decl @impl [template] {} {
- // CHECK:STDOUT: %.loc9_14.1: %empty_tuple.type = tuple_literal ()
- // CHECK:STDOUT: %.loc9_14.2: type = converted %.loc9_14.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
- // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %impl_witness: <witness> = impl_witness () [template = constants.%impl_witness]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: interface @I {
- // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = %Self
- // CHECK:STDOUT: witness = ()
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: impl @impl: %.loc9_14.2 as %I.ref {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: witness = file.%impl_witness
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_extend_impl_function_scope.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %J.type: type = facet_type <@J> [template]
- // CHECK:STDOUT: %Self: %J.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: %empty_struct_type: type = struct_type {} [template]
- // CHECK:STDOUT: %impl_witness: <witness> = impl_witness () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .J = %J.decl
- // CHECK:STDOUT: .F = %F.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %J.decl: type = interface_decl @J [template = constants.%J.type] {} {}
- // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: interface @J {
- // CHECK:STDOUT: %Self: %J.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = %Self
- // CHECK:STDOUT: witness = ()
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: impl @impl: %.loc10_16.2 as %J.ref {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: witness = @F.%impl_witness
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @F() {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: impl_decl @impl [template] {} {
- // CHECK:STDOUT: %.loc10_16.1: %empty_struct_type = struct_literal ()
- // CHECK:STDOUT: %.loc10_16.2: type = converted %.loc10_16.1, constants.%empty_struct_type [template = constants.%empty_struct_type]
- // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [template = constants.%J.type]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %impl_witness: <witness> = impl_witness () [template = constants.%impl_witness]
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|