@@ -560,7 +560,6 @@ func makeField(v reflect.Value, params fieldParameters) (e encoder, err error) {
560
560
if ! ok {
561
561
return nil , StructuralError {fmt .Sprintf ("unknown Go type: %v" , v .Type ())}
562
562
}
563
- class := ClassUniversal
564
563
565
564
if params .timeType != 0 && tag != TagUTCTime {
566
565
return nil , StructuralError {"explicit time type given to non-time member" }
@@ -610,27 +609,33 @@ func makeField(v reflect.Value, params fieldParameters) (e encoder, err error) {
610
609
611
610
bodyLen := t .body .Len ()
612
611
613
- if params .explicit {
614
- t .tag = bytesEncoder (appendTagAndLength (t .scratch [:0 ], tagAndLength {class , tag , bodyLen , isCompound }))
612
+ class := ClassUniversal
613
+ if params .tag != nil {
614
+ if params .application {
615
+ class = ClassApplication
616
+ } else {
617
+ class = ClassContextSpecific
618
+ }
615
619
616
- tt := new (taggedEncoder )
620
+ if params .explicit {
621
+ t .tag = bytesEncoder (appendTagAndLength (t .scratch [:0 ], tagAndLength {ClassUniversal , tag , bodyLen , isCompound }))
617
622
618
- tt . body = t
623
+ tt := new ( taggedEncoder )
619
624
620
- tt .tag = bytesEncoder (appendTagAndLength (tt .scratch [:0 ], tagAndLength {
621
- class : ClassContextSpecific ,
622
- tag : * params .tag ,
623
- length : bodyLen + t .tag .Len (),
624
- isCompound : true ,
625
- }))
625
+ tt .body = t
626
626
627
- return tt , nil
628
- }
627
+ tt .tag = bytesEncoder (appendTagAndLength (tt .scratch [:0 ], tagAndLength {
628
+ class : class ,
629
+ tag : * params .tag ,
630
+ length : bodyLen + t .tag .Len (),
631
+ isCompound : true ,
632
+ }))
633
+
634
+ return tt , nil
635
+ }
629
636
630
- if params .tag != nil {
631
637
// implicit tag.
632
638
tag = * params .tag
633
- class = ClassContextSpecific
634
639
}
635
640
636
641
t .tag = bytesEncoder (appendTagAndLength (t .scratch [:0 ], tagAndLength {class , tag , bodyLen , isCompound }))
0 commit comments