]> Cypherpunks repositories - gostls13.git/commitdiff
method expansion bugs
authorRuss Cox <rsc@golang.org>
Tue, 7 Jul 2009 23:05:55 +0000 (16:05 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 7 Jul 2009 23:05:55 +0000 (16:05 -0700)
R=ken
OCL=31310
CL=31310

src/cmd/gc/go.h
src/cmd/gc/reflect.c
src/cmd/gc/subr.c

index b9af878599859b18bbda7d9f38e8774c99abda3b..1bcfd420c66fe8e0c510d807d456adbb5f46e72f 100644 (file)
@@ -154,6 +154,7 @@ struct      Type
        uchar   outnamed;
 
        Type*   method;
+       Type*   xmethod;
 
        Sym*    sym;
        int32   vargen;         // unique name for OTYPE/ONAME
index 2e2e68c8bfc80a3ac5cb3dfac74beb81613c0e33..733874324620fce023b34659b26cebce569a1a13 100644 (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
index d922c8b01995ed5bff7daf780f7e406db96dd267..a1c66d1179c34593784ed2b0c62832b33c2d0169 100644 (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;
 
                }
        }