@@ -79,7 +79,7 @@ type Annotated struct {
7979 Group string
8080
8181 // Target is the constructor or value being annotated with fx.Annotated.
82- Target interface {}
82+ Target any
8383}
8484
8585func (a Annotated ) String () string {
@@ -116,7 +116,7 @@ var (
116116// or with [Supply], for a value.
117117type Annotation interface {
118118 apply (* annotated ) error
119- build (* annotated ) (interface {} , error )
119+ build (* annotated ) (any , error )
120120}
121121
122122var (
@@ -129,7 +129,7 @@ var (
129129// that it encountered as well as the target interface that was attempted
130130// to be annotated.
131131type annotationError struct {
132- target interface {}
132+ target any
133133 err error
134134}
135135
@@ -247,7 +247,7 @@ func (pt paramTagsAnnotation) apply(ann *annotated) error {
247247}
248248
249249// build builds and returns a constructor after applying a ParamTags annotation
250- func (pt paramTagsAnnotation ) build (ann * annotated ) (interface {} , error ) {
250+ func (pt paramTagsAnnotation ) build (ann * annotated ) (any , error ) {
251251 paramTypes , remap := pt .parameters (ann )
252252 resultTypes , _ := ann .currentResultTypes ()
253253
@@ -390,7 +390,7 @@ func (rt resultTagsAnnotation) apply(ann *annotated) error {
390390}
391391
392392// build builds and returns a constructor after applying a ResultTags annotation
393- func (rt resultTagsAnnotation ) build (ann * annotated ) (interface {} , error ) {
393+ func (rt resultTagsAnnotation ) build (ann * annotated ) (any , error ) {
394394 paramTypes := ann .currentParamTypes ()
395395 resultTypes , remapResults := rt .results (ann )
396396 origFn := reflect .ValueOf (ann .Target )
@@ -558,7 +558,7 @@ const (
558558
559559type lifecycleHookAnnotation struct {
560560 Type _lifecycleHookAnnotationType
561- Target interface {}
561+ Target any
562562}
563563
564564var _ Annotation = (* lifecycleHookAnnotation )(nil )
@@ -625,7 +625,7 @@ func (la *lifecycleHookAnnotation) apply(ann *annotated) error {
625625}
626626
627627// build builds and returns a constructor after applying a lifecycle hook annotation.
628- func (la * lifecycleHookAnnotation ) build (ann * annotated ) (interface {} , error ) {
628+ func (la * lifecycleHookAnnotation ) build (ann * annotated ) (any , error ) {
629629 resultTypes , hasError := ann .currentResultTypes ()
630630 if ! hasError {
631631 resultTypes = append (resultTypes , _typeOfError )
@@ -809,7 +809,7 @@ func (la *lifecycleHookAnnotation) buildHookInstaller(ann *annotated) (
809809 // parameter is a context, inject the provided context.
810810 if ctxStructPos < 0 {
811811 offset := 0
812- for i := 0 ; i < len ( hookArgs ); i ++ {
812+ for i := range hookArgs {
813813 if i == ctxPos {
814814 hookArgs [i ] = reflect .ValueOf (ctx )
815815 offset = 1
@@ -887,7 +887,7 @@ var (
887887// that the lifecycle hook being appended can depend on. It also deduplicates
888888// duplicate param and result types, which is possible when using fx.Decorate,
889889// and uses values from results for providing the deduplicated types.
890- func makeHookScopeCtor (paramTypes []reflect.Type , resultTypes []reflect.Type , args []reflect.Value ) interface {} {
890+ func makeHookScopeCtor (paramTypes []reflect.Type , resultTypes []reflect.Type , args []reflect.Value ) any {
891891 type key struct {
892892 t reflect.Type
893893 name string
@@ -1112,7 +1112,7 @@ func (la *lifecycleHookAnnotation) buildHook(fn func(context.Context) error) (ho
11121112// as OnStop. The hook function passed into OnStart cannot take any arguments
11131113// outside of the annotated constructor's existing dependencies or results, except
11141114// a context.Context.
1115- func OnStart (onStart interface {} ) Annotation {
1115+ func OnStart (onStart any ) Annotation {
11161116 return & lifecycleHookAnnotation {
11171117 Type : _onStartHookType ,
11181118 Target : onStart ,
@@ -1176,15 +1176,15 @@ func OnStart(onStart interface{}) Annotation {
11761176// as OnStart. The hook function passed into OnStop cannot take any arguments
11771177// outside of the annotated constructor's existing dependencies or results, except
11781178// a context.Context.
1179- func OnStop (onStop interface {} ) Annotation {
1179+ func OnStop (onStop any ) Annotation {
11801180 return & lifecycleHookAnnotation {
11811181 Type : _onStopHookType ,
11821182 Target : onStop ,
11831183 }
11841184}
11851185
11861186type asAnnotation struct {
1187- targets []interface {}
1187+ targets []any
11881188 types []asType
11891189}
11901190
@@ -1256,7 +1256,7 @@ var _ Annotation = (*asAnnotation)(nil)
12561256// to maintain the original return types when using As, see [Self].
12571257//
12581258// As annotation cannot be used in a function that returns an [Out] struct as a return type.
1259- func As (interfaces ... interface {} ) Annotation {
1259+ func As (interfaces ... any ) Annotation {
12601260 return & asAnnotation {targets : interfaces }
12611261}
12621262
@@ -1311,7 +1311,7 @@ func (at *asAnnotation) apply(ann *annotated) error {
13111311}
13121312
13131313// build implements Annotation
1314- func (at * asAnnotation ) build (ann * annotated ) (interface {} , error ) {
1314+ func (at * asAnnotation ) build (ann * annotated ) (any , error ) {
13151315 paramTypes := ann .currentParamTypes ()
13161316
13171317 resultTypes , remapResults , err := at .results (ann )
@@ -1430,7 +1430,7 @@ func extractResultFields(types []reflect.Type) ([]reflect.StructField, func(int,
14301430}
14311431
14321432type fromAnnotation struct {
1433- targets []interface {}
1433+ targets []any
14341434 types []reflect.Type
14351435}
14361436
@@ -1483,7 +1483,7 @@ var _ Annotation = (*fromAnnotation)(nil)
14831483//
14841484// From annotation cannot be used in a function that takes an [In] struct as a
14851485// parameter.
1486- func From (interfaces ... interface {} ) Annotation {
1486+ func From (interfaces ... any ) Annotation {
14871487 return & fromAnnotation {targets : interfaces }
14881488}
14891489
@@ -1508,7 +1508,7 @@ func (fr *fromAnnotation) apply(ann *annotated) error {
15081508}
15091509
15101510// build builds and returns a constructor after applying a From annotation
1511- func (fr * fromAnnotation ) build (ann * annotated ) (interface {} , error ) {
1511+ func (fr * fromAnnotation ) build (ann * annotated ) (any , error ) {
15121512 paramTypes , remap , err := fr .parameters (ann )
15131513 if err != nil {
15141514 return nil , err
@@ -1613,7 +1613,7 @@ func (fr *fromAnnotation) parameters(ann *annotated) (
16131613}
16141614
16151615type annotated struct {
1616- Target interface {}
1616+ Target any
16171617 Annotations []Annotation
16181618 ParamTags []string
16191619 ResultTags []string
@@ -1647,7 +1647,7 @@ func (ann annotated) String() string {
16471647
16481648// Build builds and returns a constructor based on fx.In/fx.Out params and
16491649// results wrapping the original constructor passed to fx.Annotate.
1650- func (ann * annotated ) Build () (interface {} , error ) {
1650+ func (ann * annotated ) Build () (any , error ) {
16511651 ann .container = dig .New ()
16521652 ft := reflect .TypeOf (ann .Target )
16531653 if ft .Kind () != reflect .Func {
@@ -1758,7 +1758,7 @@ func (ann *annotated) cleanUpAsResults() {
17581758func (ann * annotated ) typeCheckOrigFn () error {
17591759 ft := reflect .TypeOf (ann .Target )
17601760 numOut := ft .NumOut ()
1761- for i := 0 ; i < numOut ; i ++ {
1761+ for i := range numOut {
17621762 ot := ft .Out (i )
17631763 if ot == _typeOfError && i != numOut - 1 {
17641764 return fmt .Errorf (
@@ -1796,7 +1796,7 @@ func (ann *annotated) currentResultTypes() (resultTypes []reflect.Type, hasError
17961796 numOut := ft .NumOut ()
17971797 resultTypes = make ([]reflect.Type , numOut )
17981798
1799- for i := 0 ; i < numOut ; i ++ {
1799+ for i := range numOut {
18001800 resultTypes [i ] = ft .Out (i )
18011801 if resultTypes [i ] == _typeOfError && i == numOut - 1 {
18021802 hasError = true
@@ -1898,7 +1898,7 @@ func (ann *annotated) currentParamTypes() []reflect.Type {
18981898// Target: func(..) http.Handler { ... },
18991899// Group: "server",
19001900// }
1901- func Annotate (t interface {} , anns ... Annotation ) interface {} {
1901+ func Annotate (t any , anns ... Annotation ) any {
19021902 result := annotated {Target : t }
19031903 for _ , ann := range anns {
19041904 if err := ann .apply (& result ); err != nil {
0 commit comments