mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +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:
@@ -24,19 +24,16 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp library "header.h";
|
||||
|
||||
fn F[T: type](unused x: T) {
|
||||
// TODO: This should be treated as being template-dependent on T,
|
||||
// and we should perform the call during monomorphization.
|
||||
// CHECK:STDERR: fail_todo_generic_call.carbon:[[@LINE+8]]:3: error: value of type `<dependent type>` is not callable [CallToNonCallable]
|
||||
// CHECK:STDERR: var unused v: Cpp.S(T);
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_generic_call.carbon:[[@LINE+4]]:3: error: value of type `<dependent type>` is not callable [CallToNonCallable]
|
||||
// CHECK:STDERR: var unused v: Cpp.S(T);
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user