1
0
mirror of https://github.com/golang/go synced 2024-11-25 23:17:58 -07:00

method expansion bugs

R=ken
OCL=31310
CL=31310
This commit is contained in:
Russ Cox 2009-07-07 16:05:55 -07:00
parent 17bc836127
commit 42af80348c
3 changed files with 9 additions and 5 deletions

View File

@ -154,6 +154,7 @@ struct Type
uchar outnamed;
Type* method;
Type* xmethod;
Sym* sym;
int32 vargen; // unique name for OTYPE/ONAME

View File

@ -145,7 +145,7 @@ methods(Type *t)
a = nil;
o = 0;
oldlist = nil;
for(f=mt->method; f; f=f->down) {
for(f=mt->xmethod; f; f=f->down) {
if(f->type->etype != TFUNC)
continue;
if(f->etype != TFIELD)
@ -159,6 +159,8 @@ methods(Type *t)
// this is not an embedded pointer inside a struct,
// method does not apply.
this = getthisx(f->type)->type->type;
if(isptr[this->etype] && this->type == t)
continue;
if(isptr[this->etype] && !isptr[t->etype]
&& f->embedded != 2 && !isifacemethod(f))
continue;
@ -200,7 +202,7 @@ methods(Type *t)
if(!eqtype(this, t)) {
if(oldlist == nil)
oldlist = pc;
if(isptr[it->etype] && isptr[this->etype]
if(isptr[t->etype] && isptr[this->etype]
&& f->embedded && !isifacemethod(f))
genembedtramp(t, f, a->tsym);
else

View File

@ -2796,7 +2796,7 @@ expandmeth(Sym *s, Type *t)
if(s == S)
return;
if(t == T)
if(t == T || t->xmethod != nil)
return;
// generate all reachable methods
@ -2818,6 +2818,7 @@ expandmeth(Sym *s, Type *t)
}
}
t->xmethod = t->method;
for(sl=slist; sl!=nil; sl=sl->link) {
if(sl->good) {
// add it to the base type method list
@ -2826,8 +2827,8 @@ expandmeth(Sym *s, Type *t)
f->embedded = 1; // needs a trampoline
if(sl->followptr)
f->embedded = 2;
f->down = t->method;
t->method = f;
f->down = t->xmethod;
t->xmethod = f;
}
}