Files
carbon-lang/toolchain/check/testdata/interop/cpp/template/generic_call.carbon
T
Nicholas Bishop f519cccaf2 Add CallAction to allow deferring calls (#7682)
Calls with template callee or args can now be deferred via an
InstAction. This allows code like this to check:

```carbon
import Cpp inline '''
template<typename T>
struct C {};
''';

fn F(generic T: type) {
  let unused c: Cpp.C(T) = Cpp.C(T).C();
}
```
2026-08-28 18:00:58 +00:00

40 lines
1.3 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/convert.carbon
// EXTRA-ARGS: --clang-arg=--std=c++20
//
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/template/generic_call.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/template/generic_call.carbon
// --- header.h
struct X {};
template<typename T> struct S {};
// --- fail_todo_generic_call.carbon
library "[[@TEST_NAME]]";
import Cpp library "header.h";
fn F[T: type](unused x: T) {
var unused v: Cpp.S(T);
}
fn G() {
// CHECK:STDERR: fail_todo_generic_call.carbon:[[@LINE+7]]:3: error: unable to monomorphize specific `F(Cpp.X)` [ResolvingSpecificHere]
// CHECK:STDERR: F({} as Cpp.X);
// CHECK:STDERR: ^
// CHECK:STDERR: fail_todo_generic_call.carbon:[[@LINE-7]]:3: note: value of type `<bound method>` is not callable [CallToNonCallable]
// CHECK:STDERR: var unused v: Cpp.S(T);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
F({} as Cpp.X);
}