mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 16:11:06 +01:00
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();
}
```
This commit is contained in:
@@ -118,6 +118,47 @@ fn F(ref b: B(i32)) {
|
||||
}
|
||||
//@dump-sem-ir-end
|
||||
|
||||
// --- let_cpp_template_constructor.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
import Cpp inline '''
|
||||
template<typename T>
|
||||
struct A {};
|
||||
''';
|
||||
|
||||
// @dump-sem-ir-begin
|
||||
fn F(generic T: type) {
|
||||
let unused a: Cpp.A(T) = Cpp.A(T).A();
|
||||
}
|
||||
|
||||
fn G() {
|
||||
F(i32);
|
||||
}
|
||||
// @dump-sem-ir-end
|
||||
|
||||
// --- fail_todo_var_cpp_template_constructor.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
import Cpp inline '''
|
||||
template<typename T>
|
||||
struct A {};
|
||||
''';
|
||||
|
||||
fn F(generic T: type) {
|
||||
var unused a: Cpp.A(T) = Cpp.A(T).A();
|
||||
}
|
||||
|
||||
fn G() {
|
||||
// CHECK:STDERR: fail_todo_var_cpp_template_constructor.carbon:[[@LINE+7]]:3: error: unable to monomorphize specific `F(i32)` [ResolvingSpecificHere]
|
||||
// CHECK:STDERR: F(i32);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_todo_var_cpp_template_constructor.carbon:[[@LINE-7]]:3: note: value of type `<bound method>` is not callable [CallToNonCallable]
|
||||
// CHECK:STDERR: var unused a: Cpp.A(T) = Cpp.A(T).A();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
F(i32);
|
||||
}
|
||||
|
||||
// CHECK:STDOUT: --- use_class_template.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
|
||||
Reference in New Issue
Block a user