@@ -118,14 +118,19 @@ func msgpackUnmarshal(dec *msgpack.Decoder, typ Type, path *AttributePath) (Valu
118118 }
119119 return NewValue (Bool , rv ), nil
120120 case typ .Is (List {}):
121+ //nolint:forcetypeassert // Is func above guarantees this type assertion
121122 return msgpackUnmarshalList (dec , typ .(List ).ElementType , path )
122123 case typ .Is (Set {}):
124+ //nolint:forcetypeassert // Is func above guarantees this type assertion
123125 return msgpackUnmarshalSet (dec , typ .(Set ).ElementType , path )
124126 case typ .Is (Map {}):
127+ //nolint:forcetypeassert // Is func above guarantees this type assertion
125128 return msgpackUnmarshalMap (dec , typ .(Map ).ElementType , path )
126129 case typ .Is (Tuple {}):
130+ //nolint:forcetypeassert // Is func above guarantees this type assertion
127131 return msgpackUnmarshalTuple (dec , typ .(Tuple ).ElementTypes , path )
128132 case typ .Is (Object {}):
133+ //nolint:forcetypeassert // Is func above guarantees this type assertion
129134 return msgpackUnmarshalObject (dec , typ .(Object ).AttributeTypes , path )
130135 }
131136 return Value {}, path .NewErrorf ("unsupported type %s" , typ .String ())
@@ -364,15 +369,20 @@ func marshalMsgPack(val Value, typ Type, p *AttributePath, enc *msgpack.Encoder)
364369 case typ .Is (Bool ):
365370 return marshalMsgPackBool (val , typ , p , enc )
366371 case typ .Is (List {}):
367- return marshalMsgPackList (val , typ , p , enc )
372+ //nolint:forcetypeassert // Is func above guarantees this type assertion
373+ return marshalMsgPackList (val , typ .(List ), p , enc )
368374 case typ .Is (Set {}):
369- return marshalMsgPackSet (val , typ , p , enc )
375+ //nolint:forcetypeassert // Is func above guarantees this type assertion
376+ return marshalMsgPackSet (val , typ .(Set ), p , enc )
370377 case typ .Is (Map {}):
371- return marshalMsgPackMap (val , typ , p , enc )
378+ //nolint:forcetypeassert // Is func above guarantees this type assertion
379+ return marshalMsgPackMap (val , typ .(Map ), p , enc )
372380 case typ .Is (Tuple {}):
373- return marshalMsgPackTuple (val , typ , p , enc )
381+ //nolint:forcetypeassert // Is func above guarantees this type assertion
382+ return marshalMsgPackTuple (val , typ .(Tuple ), p , enc )
374383 case typ .Is (Object {}):
375- return marshalMsgPackObject (val , typ , p , enc )
384+ //nolint:forcetypeassert // Is func above guarantees this type assertion
385+ return marshalMsgPackObject (val , typ .(Object ), p , enc )
376386 }
377387 return fmt .Errorf ("unknown type %s" , typ )
378388}
@@ -459,7 +469,7 @@ func marshalMsgPackBool(val Value, typ Type, p *AttributePath, enc *msgpack.Enco
459469 return nil
460470}
461471
462- func marshalMsgPackList (val Value , typ Type , p * AttributePath , enc * msgpack.Encoder ) error {
472+ func marshalMsgPackList (val Value , typ List , p * AttributePath , enc * msgpack.Encoder ) error {
463473 l , ok := val .value .([]Value )
464474 if ! ok {
465475 return unexpectedValueTypeError (p , l , val .value , typ )
@@ -469,15 +479,15 @@ func marshalMsgPackList(val Value, typ Type, p *AttributePath, enc *msgpack.Enco
469479 return p .NewErrorf ("error encoding list length: %w" , err )
470480 }
471481 for pos , i := range l {
472- err := marshalMsgPack (i , typ .( List ). ElementType , p .WithElementKeyInt (pos ), enc )
482+ err := marshalMsgPack (i , typ .ElementType , p .WithElementKeyInt (pos ), enc )
473483 if err != nil {
474484 return err
475485 }
476486 }
477487 return nil
478488}
479489
480- func marshalMsgPackSet (val Value , typ Type , p * AttributePath , enc * msgpack.Encoder ) error {
490+ func marshalMsgPackSet (val Value , typ Set , p * AttributePath , enc * msgpack.Encoder ) error {
481491 s , ok := val .value .([]Value )
482492 if ! ok {
483493 return unexpectedValueTypeError (p , s , val .value , typ )
@@ -487,15 +497,15 @@ func marshalMsgPackSet(val Value, typ Type, p *AttributePath, enc *msgpack.Encod
487497 return p .NewErrorf ("error encoding set length: %w" , err )
488498 }
489499 for _ , i := range s {
490- err := marshalMsgPack (i , typ .( Set ). ElementType , p .WithElementKeyValue (i ), enc )
500+ err := marshalMsgPack (i , typ .ElementType , p .WithElementKeyValue (i ), enc )
491501 if err != nil {
492502 return err
493503 }
494504 }
495505 return nil
496506}
497507
498- func marshalMsgPackMap (val Value , typ Type , p * AttributePath , enc * msgpack.Encoder ) error {
508+ func marshalMsgPackMap (val Value , typ Map , p * AttributePath , enc * msgpack.Encoder ) error {
499509 m , ok := val .value .(map [string ]Value )
500510 if ! ok {
501511 return unexpectedValueTypeError (p , m , val .value , typ )
@@ -509,20 +519,20 @@ func marshalMsgPackMap(val Value, typ Type, p *AttributePath, enc *msgpack.Encod
509519 if err != nil {
510520 return p .NewErrorf ("error encoding map key: %w" , err )
511521 }
512- err = marshalMsgPack (v , typ .( Map ). ElementType , p , enc )
522+ err = marshalMsgPack (v , typ .ElementType , p , enc )
513523 if err != nil {
514524 return err
515525 }
516526 }
517527 return nil
518528}
519529
520- func marshalMsgPackTuple (val Value , typ Type , p * AttributePath , enc * msgpack.Encoder ) error {
530+ func marshalMsgPackTuple (val Value , typ Tuple , p * AttributePath , enc * msgpack.Encoder ) error {
521531 t , ok := val .value .([]Value )
522532 if ! ok {
523533 return unexpectedValueTypeError (p , t , val .value , typ )
524534 }
525- types := typ .( Tuple ). ElementTypes
535+ types := typ .ElementTypes
526536 err := enc .EncodeArrayLen (len (types ))
527537 if err != nil {
528538 return p .NewErrorf ("error encoding tuple length: %w" , err )
@@ -537,12 +547,12 @@ func marshalMsgPackTuple(val Value, typ Type, p *AttributePath, enc *msgpack.Enc
537547 return nil
538548}
539549
540- func marshalMsgPackObject (val Value , typ Type , p * AttributePath , enc * msgpack.Encoder ) error {
550+ func marshalMsgPackObject (val Value , typ Object , p * AttributePath , enc * msgpack.Encoder ) error {
541551 o , ok := val .value .(map [string ]Value )
542552 if ! ok {
543553 return unexpectedValueTypeError (p , o , val .value , typ )
544554 }
545- types := typ .( Object ). AttributeTypes
555+ types := typ .AttributeTypes
546556 keys := make ([]string , 0 , len (types ))
547557 for k := range types {
548558 keys = append (keys , k )
0 commit comments