1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 11:57:02 +00:00
Former-commit-id: d17b205a56f95f476db8b846c88b4cb6df8b5239
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-07-24 16:50:00 +03:00
parent c3205dafa1
commit baf68391b5
4 changed files with 63 additions and 1 deletions

View File

@@ -208,9 +208,28 @@ func fromDependentFunc(v reflect.Value, dest *Dependency, funcDependencies []*De
}
bindings := getBindingsForFunc(v, funcDependencies, -1 /* parameter bindings are disabled for depent dependencies */)
numIn := typ.NumIn()
numOut := typ.NumOut()
// d1 = Logger
// d2 = func(Logger) S1
// d2 should be static: it accepts dependencies that are static
// (note: we don't check the output argument(s) of this dependnecy).
if numIn == len(bindings) {
static := true
for _, b := range bindings {
if !b.Dependency.Static && matchDependency(b.Dependency, typ.In(b.Input.Index)) {
static = false
break
}
}
if static {
dest.Static = static
}
}
firstOutIsError := numOut == 1 && isError(typ.Out(0))
secondOutIsError := numOut == 2 && isError(typ.Out(1))
@@ -241,5 +260,6 @@ func fromDependentFunc(v reflect.Value, dest *Dependency, funcDependencies []*De
dest.DestType = typ.Out(0)
dest.Handle = handler
return true
}