wire: add a test for using a function argument as a provider (google/go-cloud#724)

This commit is contained in:
Robert van Gent
2018-11-16 13:27:30 -08:00
committed by Ross Light
parent 6ea381b3fe
commit 925a11ad0d
5 changed files with 65 additions and 1 deletions

View File

@@ -455,7 +455,7 @@ func (oc *objectCache) get(obj types.Object) (val interface{}, errs []error) {
switch obj := obj.(type) {
case *types.Var:
spec := oc.varDecl(obj)
if len(spec.Values) == 0 {
if spec == nil || len(spec.Values) == 0 {
return nil, []error{fmt.Errorf("%v is not a provider or a provider set", obj)}
}
var i int