@@ -145,13 +145,13 @@ func (fo functionName) Hash(h *fingerprint.Hasher) error {
145145}
146146
147147type signature struct {
148- Arguments []typed.TypeName
149- Results []typed.TypeName
148+ Arguments []* typed.NamedType
149+ Results []* typed.NamedType
150150}
151151
152152// Signature matches function declarations based on their arguments and return
153153// value types.
154- func Signature (args []typed.TypeName , ret []typed.TypeName ) FunctionOption {
154+ func Signature (args []* typed.NamedType , ret []* typed.NamedType ) FunctionOption {
155155 return & signature {Arguments : args , Results : ret }
156156}
157157
@@ -225,8 +225,8 @@ func (fo *signature) evaluate(info functionInformation) bool {
225225func (fo * signature ) Hash (h * fingerprint.Hasher ) error {
226226 return h .Named (
227227 "signature" ,
228- fingerprint.List [typed.TypeName ](fo .Arguments ),
229- fingerprint.List [typed.TypeName ](fo .Results ),
228+ fingerprint.List [* typed.NamedType ](fo .Arguments ),
229+ fingerprint.List [* typed.NamedType ](fo .Results ),
230230 )
231231}
232232
@@ -236,15 +236,15 @@ type signatureContains struct {
236236
237237// SignatureContains matches function declarations based on their arguments and
238238// return value types in any order and does not require all arguments or return values to be present.
239- func SignatureContains (args []typed.TypeName , ret []typed.TypeName ) FunctionOption {
239+ func SignatureContains (args []* typed.NamedType , ret []* typed.NamedType ) FunctionOption {
240240 return & signatureContains {signature {Arguments : args , Results : ret }}
241241}
242242
243243func (fo * signatureContains ) Hash (h * fingerprint.Hasher ) error {
244244 return h .Named (
245245 "signature-contains" ,
246- fingerprint.List [typed.TypeName ](fo .Arguments ),
247- fingerprint.List [typed.TypeName ](fo .Results ),
246+ fingerprint.List [* typed.NamedType ](fo .Arguments ),
247+ fingerprint.List [* typed.NamedType ](fo .Results ),
248248 )
249249}
250250
@@ -262,7 +262,7 @@ func (fo *signatureContains) evaluate(info functionInformation) bool {
262262
263263// containsAnyType checks if any of the expected types match any of the actual types in the field list.
264264// Returns false if either slice is empty or nil.
265- func containsAnyType (expectedTypes []typed.TypeName , fieldList * dst.FieldList ) bool {
265+ func containsAnyType (expectedTypes []* typed.NamedType , fieldList * dst.FieldList ) bool {
266266 // Quick return if either side is empty.
267267 if len (expectedTypes ) == 0 || fieldList == nil || len (fieldList .List ) == 0 {
268268 return false
@@ -281,10 +281,10 @@ func containsAnyType(expectedTypes []typed.TypeName, fieldList *dst.FieldList) b
281281}
282282
283283type receiver struct {
284- TypeName typed.TypeName
284+ TypeName * typed.NamedType
285285}
286286
287- func Receiver (typeName typed.TypeName ) FunctionOption {
287+ func Receiver (typeName * typed.NamedType ) FunctionOption {
288288 return & receiver {typeName }
289289}
290290
@@ -398,7 +398,7 @@ func (fo *resultImplements) evaluate(info functionInformation) bool {
398398 }
399399
400400 // Optimization: First, check for an exact match using the helper.
401- if _ , found := typed .FindMatchingTypeName (info .Type .Results , fo .InterfaceName ); found {
401+ if _ , found := typed .FindMatchingType (info .Type .Results , fo .InterfaceName ); found {
402402 return true // Found direct match
403403 } // If not found, fall through to type resolution.
404404
@@ -467,10 +467,10 @@ func (fo *finalResultImplements) evaluate(info functionInformation) bool {
467467 return false
468468 }
469469
470- // Optimization: First, check for an exact match using TypeName parsing.
471- if tn , err := typed .NewTypeName (fo .InterfaceName ); err == nil {
470+ // Optimization: First, check for an exact match using Type parsing.
471+ if t , err := typed .NewType (fo .InterfaceName ); err == nil {
472472 lastField := info .Type .Results .List [len (info .Type .Results .List )- 1 ]
473- if tn .Matches (lastField .Type ) {
473+ if t .Matches (lastField .Type ) {
474474 return true // Found direct match
475475 }
476476 } // If parsing failed or no match, fall through to type resolution.
@@ -549,9 +549,9 @@ func (o *unmarshalFuncDeclOption) UnmarshalYAML(ctx gocontext.Context, node ast.
549549 if err := yaml .NodeToValueContext (ctx , mapping .Values [0 ].Value , & arg ); err != nil {
550550 return err
551551 }
552- tn , err := typed .NewTypeName (arg )
552+ tn , err := typed .NewNamedType (arg )
553553 if err != nil {
554- return err
554+ return fmt . Errorf ( "invalid receiver type %q: %w" , arg , err )
555555 }
556556 o .FunctionOption = Receiver (tn )
557557 case "signature" , "signature-contains" :
@@ -573,25 +573,27 @@ func (o *unmarshalFuncDeclOption) UnmarshalYAML(ctx gocontext.Context, node ast.
573573 return fmt .Errorf ("unexpected keys: %s" , strings .Join (keys , ", " ))
574574 }
575575
576- var args []typed.TypeName
576+ var args []* typed.NamedType
577577 if len (sig .Args ) > 0 {
578- args = make ([]typed.TypeName , len (sig .Args ))
578+ args = make ([]* typed.NamedType , len (sig .Args ))
579579 for i , a := range sig .Args {
580- var err error
581- if args [ i ], err = typed . NewTypeName ( a ); err != nil {
582- return err
580+ tn , err := typed . NewNamedType ( a )
581+ if err != nil {
582+ return fmt . Errorf ( "invalid argument type %q at position %d: %w" , a , i , err )
583583 }
584+ args [i ] = tn
584585 }
585586 }
586587
587- var ret []typed.TypeName
588+ var ret []* typed.NamedType
588589 if len (sig .Ret ) > 0 {
589- ret = make ([]typed.TypeName , len (sig .Ret ))
590+ ret = make ([]* typed.NamedType , len (sig .Ret ))
590591 for i , r := range sig .Ret {
591- var err error
592- if ret [ i ], err = typed . NewTypeName ( r ); err != nil {
593- return err
592+ tn , err := typed . NewNamedType ( r )
593+ if err != nil {
594+ return fmt . Errorf ( "invalid return type %q at position %d: %w" , r , i , err )
594595 }
596+ ret [i ] = tn
595597 }
596598 }
597599
0 commit comments