mirror of
https://github.com/golang/go
synced 2024-11-12 10:00:25 -07:00
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
This commit is contained in:
parent
3983171b08
commit
d11a4b0dd4
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user