mirror of
https://github.com/golang/go
synced 2024-11-18 16:14:46 -07:00
go/types: don't panic if DefaultImport==nil, until we actually use it.
LGTM=gri R=gri CC=golang-codereviews https://golang.org/cl/178860044
This commit is contained in:
parent
89c9513804
commit
0088b7ecd7
@ -130,10 +130,14 @@ func (check *Checker) collectObjects() {
|
||||
|
||||
importer := check.conf.Import
|
||||
if importer == nil {
|
||||
if DefaultImport == nil {
|
||||
panic(`no Config.Import or DefaultImport (missing import _ "golang.org/x/tools/go/gcimporter"?)`)
|
||||
if DefaultImport != nil {
|
||||
importer = DefaultImport
|
||||
} else {
|
||||
// Panic if we encounter an import.
|
||||
importer = func(map[string]*Package, string) (*Package, error) {
|
||||
panic(`no Config.Import or DefaultImport (missing import _ "golang.org/x/tools/go/gcimporter"?)`)
|
||||
}
|
||||
}
|
||||
importer = DefaultImport
|
||||
}
|
||||
|
||||
// pkgImports is the set of packages already imported by any package file seen
|
||||
|
@ -10,8 +10,6 @@ import (
|
||||
|
||||
"golang.org/x/tools/go/types"
|
||||
"golang.org/x/tools/go/types/typeutil"
|
||||
|
||||
_ "golang.org/x/tools/go/gcimporter" // no imports; why is this necessary?
|
||||
)
|
||||
|
||||
func ExampleMap() {
|
||||
|
Loading…
Reference in New Issue
Block a user