Commit d11a4b0d authored by Austin Clements's avatar Austin Clements

Fix named types being defined to named types. In general, the

code assumes that the definition of a named type is not a
named type, but some code paths could violate that.

R=rsc
APPROVED=rsc
DELTA=9  (5 added, 2 deleted, 2 changed)
OCL=34046
CL=34053
parent 3983171b
......@@ -85,12 +85,10 @@ func (b *block) DefineType(name string, pos token.Position, t Type) Type {
if _, ok := b.defs[name]; ok {
return nil;
}
// We take the representative type of t because multiple
// levels of naming are useless.
nt := &NamedType{pos, name, nil, true, make(map[string] Method)};
if t != nil {
t = t.lit();
nt.Complete(t);
}
nt := &NamedType{pos, name, t, false, make(map[string] Method)};
b.defs[name] = nt;
return nt;
}
......
......@@ -980,6 +980,11 @@ func (t *NamedType) Complete(def Type) {
if !t.incomplete {
log.Crashf("cannot complete already completed NamedType %+v", *t);
}
// We strip the name from def because multiple levels of
// naming are useless.
if ndef, ok := def.(*NamedType); ok {
def = ndef.Def;
}
t.Def = def;
t.incomplete = false;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment