Skip to content

Commit

Permalink
Merge pull request #3104 from 9rnsr/fix11896
Browse files Browse the repository at this point in the history
[REG2.065a] Issue 11896 - isVirtualMethod related GitHub HEAD regression (works with 2.064)
  • Loading branch information
WalterBright committed Jan 16, 2014
2 parents 7ecbbce + a9769a2 commit 8409d8c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/func.c
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions src/template.c
Expand Up @@ -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;
Expand Down
59 changes: 55 additions & 4 deletions test/runnable/test7511.d
Expand Up @@ -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);
}

/**********************************/

Expand All @@ -353,6 +403,7 @@ int main()
test9952();
test10373();
test10329();
test11896c();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 8409d8c

Please sign in to comment.