mirror of
https://github.com/golang/go
synced 2024-11-19 04:14:45 -07:00
cmd/compile, go/importer: minor cleanups
Change-Id: I4ffb79d8cb08b0b44f59757fb7f0ec3ed1e4479f Reviewed-on: https://go-review.googlesource.com/21624 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
007b12977a
commit
81aacb80d5
@ -109,8 +109,6 @@ import (
|
|||||||
//
|
//
|
||||||
// NOTE: This flag is the first flag to enable if importing dies because of
|
// NOTE: This flag is the first flag to enable if importing dies because of
|
||||||
// (suspected) format errors, and whenever a change is made to the format.
|
// (suspected) format errors, and whenever a change is made to the format.
|
||||||
// Having debugFormat enabled increases the export data size massively (by
|
|
||||||
// several factors) - avoid running with the flag enabled in general.
|
|
||||||
const debugFormat = false // default: false
|
const debugFormat = false // default: false
|
||||||
|
|
||||||
// TODO(gri) remove eventually
|
// TODO(gri) remove eventually
|
||||||
@ -515,19 +513,19 @@ func (p *exporter) typ(t *Type) {
|
|||||||
p.typIndex[t] = len(p.typIndex)
|
p.typIndex[t] = len(p.typIndex)
|
||||||
|
|
||||||
// pick off named types
|
// pick off named types
|
||||||
if sym := t.Sym; sym != nil {
|
if tsym := t.Sym; tsym != nil {
|
||||||
// Predeclared types should have been found in the type map.
|
// Predeclared types should have been found in the type map.
|
||||||
if t.Orig == t {
|
if t.Orig == t {
|
||||||
Fatalf("exporter: predeclared type missing from type map?")
|
Fatalf("exporter: predeclared type missing from type map?")
|
||||||
}
|
}
|
||||||
// TODO(gri) The assertion below seems incorrect (crashes during all.bash).
|
// TODO(gri) The assertion below seems incorrect (crashes during all.bash).
|
||||||
// we expect the respective definition to point to us
|
// we expect the respective definition to point to us
|
||||||
// if sym.Def.Type != t {
|
// if tsym.Def.Type != t {
|
||||||
// Fatalf("exporter: type definition doesn't point to us?")
|
// Fatalf("exporter: type definition doesn't point to us?")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
p.tag(namedTag)
|
p.tag(namedTag)
|
||||||
p.qualifiedName(sym)
|
p.qualifiedName(tsym)
|
||||||
|
|
||||||
// write underlying type
|
// write underlying type
|
||||||
p.typ(t.Orig)
|
p.typ(t.Orig)
|
||||||
|
@ -232,8 +232,7 @@ func (p *importer) typ(parent *types.Package) types.Type {
|
|||||||
switch i {
|
switch i {
|
||||||
case namedTag:
|
case namedTag:
|
||||||
// read type object
|
// read type object
|
||||||
name := p.string()
|
parent, name := p.qualifiedName()
|
||||||
parent = p.pkg()
|
|
||||||
scope := parent.Scope()
|
scope := parent.Scope()
|
||||||
obj := scope.Lookup(name)
|
obj := scope.Lookup(name)
|
||||||
|
|
||||||
@ -258,7 +257,7 @@ func (p *importer) typ(parent *types.Package) types.Type {
|
|||||||
t0.SetUnderlying(p.typ(parent))
|
t0.SetUnderlying(p.typ(parent))
|
||||||
|
|
||||||
// interfaces don't have associated methods
|
// interfaces don't have associated methods
|
||||||
if _, ok := t0.Underlying().(*types.Interface); ok {
|
if types.IsInterface(t0) {
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user