diff --git a/src/func.c b/src/func.c index a15d4d9aac71..93355e8a9f93 100644 --- a/src/func.c +++ b/src/func.c @@ -4367,14 +4367,14 @@ bool FuncDeclaration::hasNestedFrameRefs() if (closureVars.dim) return true; - /* If a virtual method has contracts, assume its variables are referenced + /* If a virtual function has contracts, assume its variables are referenced * by those contracts, even if they aren't. Because they might be referenced * by the overridden or overriding function's contracts. * This can happen because frequire and fensure are implemented as nested functions, * and they can be called directly by an overriding function and the overriding function's - * context had better match, or Bugzilla 7337 will bite. + * context had better match, or Bugzilla 7335 will bite. */ - if ((fdrequire || fdensure) && isVirtualMethod()) + if (fdrequire || fdensure) return true; if (foverrides.dim && isVirtualMethod()) diff --git a/test/runnable/testcontracts.d b/test/runnable/testcontracts.d index 0092d3a62e21..a1b9e74b6c27 100644 --- a/test/runnable/testcontracts.d +++ b/test/runnable/testcontracts.d @@ -753,6 +753,25 @@ class C10981 body {} } +/*******************************************/ +// 14779 + +class C14779 +{ + final void foo(int v) + in { assert(v == 0); } + out { assert(v == 0); } + body + { + } +} + +void test14779() +{ + auto c = new C14779(); + c.foo(0); +} + /*******************************************/ int main() @@ -772,6 +791,7 @@ int main() test8073(); test8093(); test9383(); + test14779(); printf("Success\n"); return 0;