diff --git a/src/inline.d b/src/inline.d index 4b83c518414e..bdc6c3f54a8c 100644 --- a/src/inline.d +++ b/src/inline.d @@ -1493,7 +1493,7 @@ public: */ void visitCallExp(CallExp e, Expression eret, bool asStatements) { - //printf("CallExp.inlineScan()\n"); + //printf("CallExp.inlineScan() %s\n", e.toChars()); FuncDeclaration fd; if (e.e1.op == TOKvar) { @@ -1539,7 +1539,16 @@ public: if (ei && ei.exp.op == TOKblit) { Expression e2 = (cast(AssignExp)ei.exp).e2; - if (e2.op == TOKfunction) + if (e2.op == TOKsymoff) + { + auto se = cast(SymOffExp)e2; + fd = se.var.isFuncDeclaration(); + if (fd && fd != parent && canInline(fd, false, false, asStatements)) + { + expandInline(fd, parent, eret, null, e.arguments, asStatements, eresult, sresult, again); + } + } + else if (e2.op == TOKfunction) { auto fld = (cast(FuncExp)e2).fd; assert(fld.tok == TOKfunction); diff --git a/test/runnable/inline.d b/test/runnable/inline.d index a510064a60bd..1188be61340e 100644 --- a/test/runnable/inline.d +++ b/test/runnable/inline.d @@ -799,6 +799,26 @@ void test9785() } +/**********************************/ +// 9785 partial fix + +void test9785_2() { + int j = 3; + + void loop(scope const void function(int x) dg) { + pragma(inline, true); + dg(++j); + } + + static void func(int x) { + pragma(inline, true); + printf("%d\n", x); + assert(x == 4); + } + + loop(&func); +} + /**********************************/ int main() @@ -828,6 +848,7 @@ int main() test14975(); test7625(); test9785(); + test9785_2(); printf("Success\n"); return 0;