@@ -73,21 +73,21 @@ func (x *Dix) evalProvider(typ outputType, opt Options) map[group][]value {
7373 Str ("kind" , typ .Kind ().String ()).
7474 Int ("providers" , len (x .providers [typ ])).
7575 Msg ("eval type value" )
76- objects := make (map [outputType ]map [group ][]value )
7776 for _ , n := range x .providers [typ ] {
7877 if x .initializer [n .fn ] {
7978 continue
8079 }
8180
8281 var input []reflect.Value
8382 for _ , in := range n .input {
84- val := x .getValue (in .typ , opt , in .isMap , in .isList )
83+ val := x .getValue (in .typ , opt , in .isMap , in .isList , typ )
8584 input = append (input , val )
8685 }
8786
8887 fnCall := n .call (input )
8988 x .initializer [n .fn ] = true
9089
90+ objects := make (map [outputType ]map [group ][]value )
9191 for k , oo := range handleOutput (typ , fnCall [0 ]) {
9292 if n .output .isMap {
9393 if _ , ok := objects [k ]; ok {
@@ -106,15 +106,15 @@ func (x *Dix) evalProvider(typ outputType, opt Options) map[group][]value {
106106 objects [k ][g ] = append (objects [k ][g ], o ... )
107107 }
108108 }
109- }
110109
111- for a , b := range objects {
112- if x .objects [a ] == nil {
113- x .objects [a ] = make (map [group ][]value )
114- }
110+ for a , b := range objects {
111+ if x .objects [a ] == nil {
112+ x .objects [a ] = make (map [group ][]value )
113+ }
115114
116- for c , d := range b {
117- x.objects [a ][c ] = append (x.objects [a ][c ], d ... )
115+ for c , d := range b {
116+ x.objects [a ][c ] = append (x.objects [a ][c ], d ... )
117+ }
118118 }
119119 }
120120
@@ -129,7 +129,7 @@ func (x *Dix) getProviderStack(typ reflect.Type) []string {
129129 return stacks
130130}
131131
132- func (x * Dix ) getValue (typ reflect.Type , opt Options , isMap , isList bool ) reflect.Value {
132+ func (x * Dix ) getValue (typ reflect.Type , opt Options , isMap , isList bool , parents ... reflect. Type ) reflect.Value {
133133 switch {
134134 case isMap :
135135 valMap := x .evalProvider (typ , opt )
@@ -138,6 +138,7 @@ func (x *Dix) getValue(typ reflect.Type, opt Options, isMap, isList bool) reflec
138138 Any ("options" , opt ).
139139 Str ("type" , typ .String ()).
140140 Any ("providers" , x .getProviderStack (typ )).
141+ Any ("parents" , fmt .Sprintf ("%q" , parents )).
141142 Str ("type-kind" , typ .Kind ().String ()).
142143 Msg ("provider value not found" )
143144 }
@@ -155,6 +156,7 @@ func (x *Dix) getValue(typ reflect.Type, opt Options, isMap, isList bool) reflec
155156 Any ("options" , opt ).
156157 Any ("values" , valMap [defaultKey ]).
157158 Any ("providers" , x .getProviderStack (typ )).
159+ Any ("parents" , fmt .Sprintf ("%q" , parents )).
158160 Str ("type" , typ .String ()).
159161 Str ("type-kind" , typ .Kind ().String ()).
160162 Msg (err .Msg )
@@ -173,6 +175,7 @@ func (x *Dix) getValue(typ reflect.Type, opt Options, isMap, isList bool) reflec
173175 Any ("values" , valMap [defaultKey ]).
174176 Str ("type" , typ .String ()).
175177 Any ("providers" , x .getProviderStack (typ )).
178+ Any ("parents" , fmt .Sprintf ("%q" , parents )).
176179 Str ("type-kind" , typ .Kind ().String ()).
177180 Msg ("provider value not found" )
178181 } else {
@@ -188,6 +191,7 @@ func (x *Dix) getValue(typ reflect.Type, opt Options, isMap, isList bool) reflec
188191 Any ("options" , opt ).
189192 Any ("values" , valList ).
190193 Any ("providers" , x .getProviderStack (typ )).
194+ Any ("parents" , fmt .Sprintf ("%q" , parents )).
191195 Str ("type" , typ .String ()).
192196 Str ("type-kind" , typ .Kind ().String ()).
193197 Msg (err .Msg )
@@ -224,7 +228,7 @@ func (x *Dix) injectFunc(vp reflect.Value, opt Options) {
224228
225229 var input []reflect.Value
226230 for _ , in := range inTypes {
227- input = append (input , x .getValue (in .typ , opt , in .isMap , in .isList ))
231+ input = append (input , x .getValue (in .typ , opt , in .isMap , in .isList , vp . Type () ))
228232 }
229233 vp .Call (input )
230234}
@@ -241,16 +245,16 @@ func (x *Dix) injectStruct(vp reflect.Value, opt Options) {
241245 case reflect .Struct :
242246 x .injectStruct (vp .Field (i ), opt )
243247 case reflect .Interface , reflect .Ptr , reflect .Func :
244- vp .Field (i ).Set (x .getValue (field .Type , opt , false , false ))
248+ vp .Field (i ).Set (x .getValue (field .Type , opt , false , false , vp . Type () ))
245249 case reflect .Map :
246250 isList := field .Type .Elem ().Kind () == reflect .Slice
247251 typ := field .Type .Elem ()
248252 if isList {
249253 typ = typ .Elem ()
250254 }
251- vp .Field (i ).Set (x .getValue (typ , opt , true , isList ))
255+ vp .Field (i ).Set (x .getValue (typ , opt , true , isList , vp . Type () ))
252256 case reflect .Slice :
253- vp .Field (i ).Set (x .getValue (field .Type .Elem (), opt , false , true ))
257+ vp .Field (i ).Set (x .getValue (field .Type .Elem (), opt , false , true , vp . Type () ))
254258 default :
255259 panic (& errors.Err {
256260 Msg : "incorrect input type" ,
0 commit comments