]> Cypherpunks repositories - gostls13.git/commitdiff
gc: undo most of 'fix infinite recursion for embedded interfaces'
authorRuss Cox <rsc@golang.org>
Fri, 20 Jan 2012 22:14:09 +0000 (17:14 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 20 Jan 2012 22:14:09 +0000 (17:14 -0500)
Preserve test.

changeset:   11593:f1deaf35e1d1
user:        Luuk van Dijk <lvd@golang.org>
date:        Tue Jan 17 10:00:57 2012 +0100
summary:     gc: fix infinite recursion for embedded interfaces

This is causing 'interface type loop' errors during compilation
of a complex program.  I don't understand what's happening
well enough to boil it down to a simple test case, but undoing
this change fixes the problem.

The change being undone is fixing a corner case (uses of
pointer to interface in an interface definition) that basically
only comes up in erroneous Go programs.  Let's not try to
fix this again until after Go 1.

Unfixes issue 1909.

TBR=lvd
CC=golang-dev
https://golang.org/cl/5555063

src/cmd/gc/dcl.c
src/cmd/gc/export.c
src/cmd/gc/fmt.c
test/bugs/bug395.go [moved from test/fixedbugs/bug395.go with 63% similarity]
test/golden.out

index 94258a0c593d5f72c484f4dd5c7aaf98e4717a6d..66edab9b94bc2e7f825600f47737acf12c8b79cf 100644 (file)
@@ -940,19 +940,13 @@ interfacefield(Node *n)
 Type*
 tointerface(NodeList *l)
 {
-       Type *t, *f, **tp, **otp, *t1;
+       Type *t, *f, **tp, *t1;
 
        t = typ(TINTER);
-       t->orig = typ(TINTER);
 
        tp = &t->type;
-       otp = &t->orig->type;
-
        for(; l; l=l->next) {
                f = interfacefield(l->n);
-               *otp = typ(TFIELD);
-               **otp = *f;
-               otp = &(*otp)->down;
 
                if (l->n->left == N && f->type->etype == TINTER) {
                        // embedded interface, inline methods
@@ -961,7 +955,6 @@ tointerface(NodeList *l)
                                f->type = t1->type;
                                f->broke = t1->broke;
                                f->sym = t1->sym;
-                               f->embedded = 1;
                                if(f->sym)
                                        f->nname = newname(f->sym);
                                *tp = f;
index 965b745a802346220dbac9f3f1326d4b52e4e368..05fdcbf32b8ea90aff7aef93cbe8724e780f07eb 100644 (file)
@@ -241,13 +241,6 @@ dumpexporttype(Type *t)
        if(t->sym != S && t->etype != TFIELD)
                dumppkg(t->sym->pkg);
 
-       // fmt will print the ->orig of an interface, which has the original embedded interfaces.
-       // be sure to dump them here
-       if(t->etype == TINTER)
-               for(f=t->orig->type; f; f=f->down)
-                       if(f->sym == S)
-                               dumpexporttype(f->type);
-
        dumpexporttype(t->type);
        dumpexporttype(t->down);
 
@@ -477,7 +470,7 @@ importtype(Type *pt, Type *t)
                pt->sym->lastlineno = parserline();
                declare(n, PEXTERN);
                checkwidth(pt);
-       } else if(!eqtype(pt->orig, t->orig))
+       } else if(!eqtype(pt->orig, t))
                yyerror("inconsistent definition for type %S during import\n\t%lT\n\t%lT", pt->sym, pt, t);
 
        if(debug['E'])
index 6f2041c1c5684b0ab6936276b97288e3e24a973f..b7a648789ab235f147d24d120124e9401ca549e9 100644 (file)
@@ -640,15 +640,9 @@ typefmt(Fmt *fp, Type *t)
                return fmtprint(fp, "map[%T]%T", t->down, t->type);
 
        case TINTER:
-               t = t->orig;
                fmtstrcpy(fp, "interface {");
                for(t1=t->type; t1!=T; t1=t1->down)
-                       if(!t1->sym) {
-                               if(t1->down)
-                                       fmtprint(fp, " %T;", t1->type);
-                               else
-                                       fmtprint(fp, " %T ", t1->type);
-                       } else if(exportname(t1->sym->name)) {
+                       if(exportname(t1->sym->name)) {
                                if(t1->down)
                                        fmtprint(fp, " %hS%hT;", t1->sym, t1->type);
                                else
similarity index 63%
rename from test/fixedbugs/bug395.go
rename to test/bugs/bug395.go
index d0af3f9fce158709ffab41c6c7fe240b922bcaf2..adf74497cde7a9bb5fa2f6cecd7aba0f9da20e25 100644 (file)
@@ -1,4 +1,5 @@
-// $G $D/$F.go || echo "Bug395"
+// echo bug395 is broken  # takes 90+ seconds to break
+// # $G $D/$F.go || echo bug395
 
 // Copyright 2011 The Go Authors.  All rights reserved.
 // Use of this source code is governed by a BSD-style
@@ -9,7 +10,13 @@
 package test
 
 type Foo interface {
-       Bar() interface{Foo}
-       Baz() interface{Foo}
-       Bug() interface{Foo}
+       Bar() interface {
+               Foo
+       }
+       Baz() interface {
+               Foo
+       }
+       Bug() interface {
+               Foo
+       }
 }
index d7ecbdc8783658ecc24c1d95f746d6c0b376fce1..e0b4cf6e2a791e8350e6dd70624835df6810bab2 100644 (file)
@@ -14,3 +14,6 @@
 == fixedbugs/
 
 == bugs/
+
+=========== bugs/bug395.go
+bug395 is broken