1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/ice9540.d(34): Error: function ice9540.A.test.AddFront!(this, f).AddFront.dg (int _param_0) is not callable using argument types ()
5 fail_compilation/ice9540.d(25): Error: template instance ice9540.A.test.AddFront!(this, f) error instantiating
6 ---
7 */
8 
Tuple(E...)9 template Tuple(E...) { alias E Tuple; }
10 alias Tuple!(int) Args;
11 
main()12 void main() {
13     (new A).test ();
14 }
15 
test1(int delegate (int)f)16 void test1 (int delegate (int) f) { f (-2); }
17 
18 class A
19 {
f(int a)20     int f (int a) {
21         return a;
22     }
23 
test()24     void test () {
25         test1 (&AddFront!(this, f));
26     }
27 }
28 
AddFront(alias ctx,alias fun)29 template AddFront (alias ctx, alias fun)  {
30     auto AddFront(Args args) {
31         auto dg (Args dgArgs) {
32             return fun (dgArgs);
33         }
34         dg.ptr = ctx;
35         return dg(args);
36     }
37 }
38