From c8be771c1ef5125c9873c0ed183aa1ac97be93dc Mon Sep 17 00:00:00 2001 From: David Sharnoff Date: Mon, 11 Apr 2022 21:30:33 -0700 Subject: [PATCH] bugfix for DownFlows() & UpFlows() (#29) --- nject.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/nject.go b/nject.go index d34fa39..723014e 100644 --- a/nject.go +++ b/nject.go @@ -364,10 +364,15 @@ func (fm provider) DownFlows() ([]reflect.Type, []reflect.Type) { } t := v.Type() if t.Kind() == reflect.Func { - if fm.group == finalGroup { + switch fm.group { + case finalGroup: return typesIn(t), nil + default: + return effectiveOutputs(t) } - return effectiveOutputs(t) + } + if fm.group == invokeGroup && t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Func { + return nil, typesIn(t.Elem()) } return nil, []reflect.Type{t} } @@ -443,10 +448,15 @@ func (fm provider) UpFlows() ([]reflect.Type, []reflect.Type) { } t := v.Type() if t.Kind() == reflect.Func { - if fm.group == finalGroup { + switch fm.group { + case finalGroup: return nil, typesOut(t) + default: + return effectiveReturns(t) } - return effectiveReturns(t) + } + if fm.group == invokeGroup && t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Func { + return typesOut(t.Elem()), nil } return nil, []reflect.Type{t} }