mirror of
https://github.com/golang/go
synced 2024-11-25 00:07:56 -07:00
gc: undo most of 'fix infinite recursion for embedded interfaces'
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
This commit is contained in:
parent
696bf79350
commit
290e68b983
@ -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;
|
||||
|
@ -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'])
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -14,3 +14,6 @@
|
||||
== fixedbugs/
|
||||
|
||||
== bugs/
|
||||
|
||||
=========== bugs/bug395.go
|
||||
bug395 is broken
|
||||
|
Loading…
Reference in New Issue
Block a user