diff --git a/compiler2/Type.cc b/compiler2/Type.cc
index 35ffd9672f32d0bcd38efcff5d96d8c3056e823a..10acf4423f797b8a0bae30fc38ab1fca9cf1d9b9 100644
--- a/compiler2/Type.cc
+++ b/compiler2/Type.cc
@@ -7494,6 +7494,7 @@ namespace Common {
   string Type::get_genname_typedescriptor(Scope *p_scope)
   {
     Type *t = this;
+    bool is_anytype = get_type_refd_last()->typetype == T_ANYTYPE;
     for ( ; ; ) {
       /* If it has tags or encoding attributes, then its encoding may be
        * different from the other "equivalent" types and needs to have its own
@@ -7501,7 +7502,7 @@ namespace Common {
        */
       if (t->is_tagged() || t->rawattrib || t->textattrib || t->jsonattrib ||
           (!t->is_asn1() && t->hasEncodeAttr(get_encoding_name(CT_JSON))) ||
-          (t->xerattrib && !t->xerattrib->empty() ) ||
+          (!is_anytype && t->xerattrib && !t->xerattrib->empty() ) ||
           (asn1_xer && t->is_asn1() && t->ownertype != OT_RECORD_OF && t->ownertype != OT_REF_SPEC) ||
           (t->oerattrib && !t->oerattrib->empty() && t->is_asn1()))
       {
diff --git a/compiler2/Type_codegen.cc b/compiler2/Type_codegen.cc
index 222887bb66652f2ffe50db71f95a12b322fce15b..574cd68a64ef6c5147d168902ed4126370f63eb8 100644
--- a/compiler2/Type_codegen.cc
+++ b/compiler2/Type_codegen.cc
@@ -433,7 +433,7 @@ void Type::generate_code_typedescriptor(output_struct *target)
     
     if (T_SEQOF == last->typetype || T_SETOF == last->typetype) {
       target->source.global_vars=mputprintf(target->source.global_vars,
-        "&%s_descr_, ", get_type_refd_last()->u.seof.ofType->get_genname_typedescriptor(my_scope).c_str());
+        "&%s_descr_, ", last->u.seof.ofType->get_genname_typedescriptor(my_scope).c_str());
     }
     else {
       target->source.global_vars = mputstr(target->source.global_vars,