~marcopolo/di

d9e72376778f218f694c05252e446b0f9c676f68 — Marco Munizaga 9 months ago ac21236 main
remove the ability to provide a slice of function constructors

I don't think it is ever useful
1 files changed, 6 insertions(+), 20 deletions(-)

M di.go
M di.go => di.go +6 -20
@@ 385,26 385,12 @@ func (c *collector) collect(v reflect.Value, path string) error {

		case reflect.Slice:
			elemT := sf.Type.Elem()
			if elemT.Kind() == reflect.Func {
				for j := 0; j < fv.Len(); j++ {
					fn := fv.Index(j)
					ft := fn.Type()
					if err := validateCtorSignature(ft, fmt.Sprintf("%s[%d]", name, j)); err != nil {
						return err
					}
					c.listProviders[ft.Out(0)] = append(c.listProviders[ft.Out(0)], ctor{
						name: fmt.Sprintf("%s[%d]", name, j),
						fn:   fn, out: ft.Out(0),
					})
				}
			} else {
				if fv.Len() == 0 {
					c.listPresence[elemT] = true // explicit empty list present
				}
				for j := 0; j < fv.Len(); j++ {
					vj := fv.Index(j)
					c.listValues[vj.Type()] = append(c.listValues[vj.Type()], vj)
				}
			if fv.Len() == 0 {
				c.listPresence[elemT] = true // explicit empty list present
			}
			for j := 0; j < fv.Len(); j++ {
				vj := fv.Index(j)
				c.listValues[vj.Type()] = append(c.listValues[vj.Type()], vj)
			}

		default: