Files
carbon-lang/toolchain/check/testdata/impl/extend_final.carbon
T
Jon Ross-Perkins 0a727c32e9 Change min_prelude to use EXTRA-ARGS and INCLUDE-FILE (#5625)
Now that included files can specify `EXTRA-ARGS`, this uses that to
handle min_prelude files. Also moves `As`/`ImplicitAs` out to a shared
file, partly because we duplicate it a few times over, partly just to
show that it works.

Also removes the `min_prelude/` subdirectories because many of these
files were touched by autoupdate regardless. I noticed one conflict for
`impl_thunk.carbon`, so renaming that one to
`impl_thunk_min_prelude.carbon`.

`GetArgReplacements` I simply noticed was unused, so removing it.
2025-06-06 15:56:58 +00:00

56 lines
1.7 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/min_prelude/facet_types.carbon
//
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/extend_final.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/extend_final.carbon
// --- extend_final_impl.carbon
library "[[@TEST_NAME]]";
interface Z {
let X:! type;
}
class C {
extend final impl as Z where .X = () {}
}
fn F() {
let b: C.X = ();
}
// --- fail_final_extend_impl.carbon
library "[[@TEST_NAME]]";
interface Z {}
class C {
// CHECK:STDERR: fail_final_extend_impl.carbon:[[@LINE+7]]:9: error: `extend` must appear before `final` [ModifierMustAppearBefore]
// CHECK:STDERR: final extend impl as Z {}
// CHECK:STDERR: ^~~~~~
// CHECK:STDERR: fail_final_extend_impl.carbon:[[@LINE+4]]:3: note: `final` previously appeared here [ModifierPrevious]
// CHECK:STDERR: final extend impl as Z {}
// CHECK:STDERR: ^~~~~
// CHECK:STDERR:
final extend impl as Z {}
}
// --- fail_final_extend_impl_outside_class.carbon
library "[[@TEST_NAME]]";
interface Z {}
class C {}
// CHECK:STDERR: fail_final_extend_impl_outside_class.carbon:[[@LINE+4]]:1: error: `extend impl` can only be used in a class [ExtendImplOutsideClass]
// CHECK:STDERR: extend final impl C as Z {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
extend final impl C as Z {}