mirror of
https://github.com/golang/go
synced 2024-11-14 19:50:21 -07:00
Fix npe from importerOf[p]
This commit is contained in:
parent
d76568d7ee
commit
c5a16256d1
@ -546,13 +546,13 @@ func recompileForTest(pmain, preal, ptest, pxtest *Package) *PackageError {
|
|||||||
// by x, and then we reverse it.
|
// by x, and then we reverse it.
|
||||||
var stk ImportStack
|
var stk ImportStack
|
||||||
for p != nil {
|
for p != nil {
|
||||||
tokenPositions := []token.Position{}
|
importer, ok := importerOf[p]
|
||||||
if importerOf[p].Internal.Build != nil {
|
if importer == nil && ok { // we set importerOf[p] == nil for the initial set of packages p that are imports of ptest
|
||||||
tokenPositions = importerOf[p].Internal.Build.ImportPos[p.ImportPath]
|
importer = ptest
|
||||||
}
|
}
|
||||||
stk = append(stk, ImportInfo{
|
stk = append(stk, ImportInfo{
|
||||||
Pkg: p.ImportPath,
|
Pkg: p.ImportPath,
|
||||||
Pos: extractFirstImport(tokenPositions),
|
Pos: extractFirstImport(importer.Internal.Build.ImportPos[p.ImportPath]),
|
||||||
})
|
})
|
||||||
p = importerOf[p]
|
p = importerOf[p]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user