From a9769a205c47aa5960e78fea4ce26a312a2b6cde Mon Sep 17 00:00:00 2001 From: k-hara Date: Thu, 16 Jan 2014 01:56:19 +0900 Subject: [PATCH] fix Issue 11896 - isVirtualMethod related GitHub HEAD regression (works with 2.064) --- src/func.c | 2 +- src/template.c | 2 -- test/runnable/test7511.d | 59 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/func.c b/src/func.c index 8829f804d323..2535609dccbf 100644 --- a/src/func.c +++ b/src/func.c @@ -1905,7 +1905,7 @@ bool FuncDeclaration::functionSemantic() if (isInstantiated() && !isVirtualMethod() && !(ti = parent->isTemplateInstance(), ti && !ti->isTemplateMixin() && ti->name != ident)) { - AggregateDeclaration *ad = isThis(); + AggregateDeclaration *ad = isMember2(); if (ad && ad->sizeok != SIZEOKdone) { /* Currently dmd cannot resolve forward references per methods, diff --git a/src/template.c b/src/template.c index 8dc114a28d03..c5ce5d534d4a 100644 --- a/src/template.c +++ b/src/template.c @@ -2038,8 +2038,6 @@ void functionResolve(Match *m, Dsymbol *dstart, Loc loc, Scope *sc, // explicitly specified tiargs never match to non template function if (tiargs && tiargs->dim > 0) return 0; - if (fd->scope && fd->semanticRun < PASSsemanticdone) - fd->semantic(fd->scope); //printf("fd = %s %s\n", fd->toChars(), fd->type->toChars()); m->anyf = fd; diff --git a/test/runnable/test7511.d b/test/runnable/test7511.d index eb29c6c52f21..cdddb60dc0ee 100644 --- a/test/runnable/test7511.d +++ b/test/runnable/test7511.d @@ -328,19 +328,69 @@ void test10329() pure nothrow @safe /**********************************/ // 11896 -class Foo11896(T = int) +class Foo11896a(T = int) { static if (!__traits(isVirtualMethod, zoo)) {} else { Undefined x; } static void bar() {} - static void bar(Foo11896 foo) {} + static void bar(Foo11896a foo) {} static void zoo() { - bar(new Foo11896); + bar(new Foo11896a); } } -Foo11896!(int) baz; +Foo11896a!(int) baz11896a; + +// ---- + +Frop11896b!(int) frop11896b; + +mixin template baz11896b() +{ + public void bar11896b() {} +} + +mixin baz11896b; + +class Foo11896b(T) +{ + static if (! __traits(isVirtualMethod, zoo)) {} + + static void zoo() + { + bar11896b(); + } +} + +class Frop11896b(T) : Foo11896b!T {} + +// ---- + +static bool flag11896c = false; + +class Bar11896c {} + +class Foo11896c(T = Bar11896c) +{ + static if (! __traits(isVirtualMethod, foo)) {} + alias Foo11896c!(T) this_type; + this() + { + flag11896c = true; + } + static public this_type foo() + { + auto c = new this_type(); + return flag11896c ? c : null; + } +} + +void test11896c() +{ + alias Foo11896c!Bar11896c FooBar; + assert(FooBar.foo() !is null); +} /**********************************/ @@ -353,6 +403,7 @@ int main() test9952(); test10373(); test10329(); + test11896c(); printf("Success\n"); return 0;