mirror of
https://github.com/golang/go
synced 2024-11-26 01:37:58 -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;
|
uchar outnamed;
|
||||||
|
|
||||||
Type* method;
|
Type* method;
|
||||||
|
Type* xmethod;
|
||||||
|
|
||||||
Sym* sym;
|
Sym* sym;
|
||||||
int32 vargen; // unique name for OTYPE/ONAME
|
int32 vargen; // unique name for OTYPE/ONAME
|
||||||
|
@ -145,7 +145,7 @@ methods(Type *t)
|
|||||||
a = nil;
|
a = nil;
|
||||||
o = 0;
|
o = 0;
|
||||||
oldlist = nil;
|
oldlist = nil;
|
||||||
for(f=mt->method; f; f=f->down) {
|
for(f=mt->xmethod; f; f=f->down) {
|
||||||
if(f->type->etype != TFUNC)
|
if(f->type->etype != TFUNC)
|
||||||
continue;
|
continue;
|
||||||
if(f->etype != TFIELD)
|
if(f->etype != TFIELD)
|
||||||
@ -159,6 +159,8 @@ methods(Type *t)
|
|||||||
// this is not an embedded pointer inside a struct,
|
// this is not an embedded pointer inside a struct,
|
||||||
// method does not apply.
|
// method does not apply.
|
||||||
this = getthisx(f->type)->type->type;
|
this = getthisx(f->type)->type->type;
|
||||||
|
if(isptr[this->etype] && this->type == t)
|
||||||
|
continue;
|
||||||
if(isptr[this->etype] && !isptr[t->etype]
|
if(isptr[this->etype] && !isptr[t->etype]
|
||||||
&& f->embedded != 2 && !isifacemethod(f))
|
&& f->embedded != 2 && !isifacemethod(f))
|
||||||
continue;
|
continue;
|
||||||
@ -200,7 +202,7 @@ methods(Type *t)
|
|||||||
if(!eqtype(this, t)) {
|
if(!eqtype(this, t)) {
|
||||||
if(oldlist == nil)
|
if(oldlist == nil)
|
||||||
oldlist = pc;
|
oldlist = pc;
|
||||||
if(isptr[it->etype] && isptr[this->etype]
|
if(isptr[t->etype] && isptr[this->etype]
|
||||||
&& f->embedded && !isifacemethod(f))
|
&& f->embedded && !isifacemethod(f))
|
||||||
genembedtramp(t, f, a->tsym);
|
genembedtramp(t, f, a->tsym);
|
||||||
else
|
else
|
||||||
|
@ -2796,7 +2796,7 @@ expandmeth(Sym *s, Type *t)
|
|||||||
|
|
||||||
if(s == S)
|
if(s == S)
|
||||||
return;
|
return;
|
||||||
if(t == T)
|
if(t == T || t->xmethod != nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// generate all reachable methods
|
// 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) {
|
for(sl=slist; sl!=nil; sl=sl->link) {
|
||||||
if(sl->good) {
|
if(sl->good) {
|
||||||
// add it to the base type method list
|
// add it to the base type method list
|
||||||
@ -2826,8 +2827,8 @@ expandmeth(Sym *s, Type *t)
|
|||||||
f->embedded = 1; // needs a trampoline
|
f->embedded = 1; // needs a trampoline
|
||||||
if(sl->followptr)
|
if(sl->followptr)
|
||||||
f->embedded = 2;
|
f->embedded = 2;
|
||||||
f->down = t->method;
|
f->down = t->xmethod;
|
||||||
t->method = f;
|
t->xmethod = f;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user