mirror of
https://github.com/golang/go
synced 2024-11-20 05:04:43 -07:00
method expansion bugs
R=ken OCL=31310 CL=31310
This commit is contained in:
parent
17bc836127
commit
42af80348c
@ -154,6 +154,7 @@ struct Type
|
||||
uchar outnamed;
|
||||
|
||||
Type* method;
|
||||
Type* xmethod;
|
||||
|
||||
Sym* sym;
|
||||
int32 vargen; // unique name for OTYPE/ONAME
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user