wire: detect cycles incrementally (google/go-cloud#102)

Idea originally mentioned in google/go-cloud#29. This means that any provider set
loaded must not have cycles, which is stricter than before. The cycle
error message now gives full detail on what caused the cycle.
This commit is contained in:
Ross Light
2018-06-20 11:21:59 -07:00
parent cd52d44251
commit 366207371e
6 changed files with 121 additions and 8 deletions

View File

@@ -375,6 +375,9 @@ func (oc *objectCache) processNewSet(pkg *loader.PackageInfo, call *ast.CallExpr
if err != nil {
return nil, err
}
if err := verifyAcyclic(pset.providerMap, oc.hasher); err != nil {
return nil, err
}
return pset, nil
}