Revert "Union has its associated (nested) tag enum"

This reverts commit d875b4904bbe094728404ee2c9ed512eabcbcaed.

Reason for revert: Patch for verifying b/224692780.

Change-Id: Ie2e698bf5851cead7d3adc942e144fb43d1f1f42
diff --git a/aidl_language.h b/aidl_language.h
index 15ce4bb..f3c5829 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -999,6 +999,10 @@
     return constants_;
   }
   const std::vector<std::unique_ptr<AidlMethod>>& GetMethods() const { return methods_; }
+  void AddMethod(std::unique_ptr<AidlMethod> method) {
+    members_.push_back(method.get());
+    methods_.push_back(std::move(method));
+  }
   const std::vector<const AidlMember*>& GetMembers() const { return members_; }
   void TraverseChildren(std::function<void(const AidlNode&)> traverse) const override {
     AidlAnnotatable::TraverseChildren(traverse);
@@ -1007,17 +1011,6 @@
     }
   }
 
-  // Modifiers
-  void AddMethod(std::unique_ptr<AidlMethod> method) {
-    members_.push_back(method.get());
-    methods_.push_back(std::move(method));
-  }
-  void AddType(std::unique_ptr<AidlDefinedType> type) {
-    type->SetEnclosingScope(this);
-    members_.push_back(type.get());
-    types_.push_back(std::move(type));
-  }
-
  protected:
   // utility for subclasses with getter names
   bool CheckValidForGetterNames() const;
diff --git a/aidl_to_cpp_common.cpp b/aidl_to_cpp_common.cpp
index 030b13e..b8e38ea 100644
--- a/aidl_to_cpp_common.cpp
+++ b/aidl_to_cpp_common.cpp
@@ -481,7 +481,7 @@
     const auto& default_value = name_of(first_field->GetType(), typenames) + "(" +
                                 first_field->ValueString(decorator) + ")";
 
-    out << "Tag _tag = " << default_name << ";\n";
+    out << "Tag _tag __attribute__((aligned (1))) = " << default_name << ";\n";
     out << "union _value_t {\n";
     out.Indent();
     out << "_value_t() {}\n";
@@ -512,12 +512,23 @@
 }
 
 void UnionWriter::PublicFields(CodeWriter& out) const {
-  out << "// Expose tag symbols for legacy code\n";
-  for (const auto& f : decl.GetFields()) {
-    out << "static const inline Tag";
-    GenerateDeprecated(out, *f);
-    out << " " << f->GetName() << " = Tag::" << f->GetName() << ";\n";
+  std::string tag_type = "int32_t";
+  if (decl.IsFixedSize()) {
+    // For @FixedSize union, we use a smaller type for a tag to minimize the size overhead.
+    AIDL_FATAL_IF(decl.GetFields().size() > std::numeric_limits<uint8_t>::max(), decl)
+        << "Too many fields for @FixedSize";
+    tag_type = "uint8_t";
   }
+  out << "enum Tag : " << tag_type << " {\n";
+  bool is_first = true;
+  for (const auto& f : decl.GetFields()) {
+    out << "  " << f->GetName();
+    GenerateDeprecated(out, *f);
+    if (is_first) out << " = 0";
+    out << ",  // " << f->Signature() << ";\n";
+    is_first = false;
+  }
+  out << "};\n";
 
   const auto& name = decl.GetName();
 
diff --git a/parser.cpp b/parser.cpp
index edb110b..9988f56 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -28,29 +28,6 @@
 YY_BUFFER_STATE yy_scan_buffer(char*, size_t, void*);
 void yy_delete_buffer(YY_BUFFER_STATE, void*);
 
-// For each union, generate nested "Tag" enum type so that "Tag" can be used as a valid type.
-//    union Foo { int a; int b; } => union Foo { ... enum Tag { a, b }}
-struct UnionTagGenerater : AidlVisitor {
-  void Visit(const AidlUnionDecl& decl) override {
-    std::vector<std::unique_ptr<AidlEnumerator>> enumerators;
-    for (const auto& field : decl.GetFields()) {
-      enumerators.push_back(std::make_unique<AidlEnumerator>(AIDL_LOCATION_HERE, field->GetName(),
-                                                             nullptr, field->GetComments()));
-    }
-    auto tag_enum = std::make_unique<AidlEnumDeclaration>(AIDL_LOCATION_HERE, "Tag", &enumerators,
-                                                          decl.GetPackage(), Comments{});
-    // Tag for @FixedSize union is limited to "byte" type so that it can be passed via FMQ with
-    // with lower overhead.
-    std::shared_ptr<AidlConstantValue> backing_type{
-        AidlConstantValue::String(AIDL_LOCATION_HERE, decl.IsFixedSize() ? "\"byte\"" : "\"int\"")};
-    std::vector<std::unique_ptr<AidlAnnotation>> annotations;
-    annotations.push_back(
-        AidlAnnotation::Parse(AIDL_LOCATION_HERE, "Backing", {{"type", backing_type}}, Comments{}));
-    tag_enum->Annotate(std::move(annotations));
-    const_cast<AidlUnionDecl&>(decl).AddType(std::move(tag_enum));
-  }
-};
-
 const AidlDocument* Parser::Parse(const std::string& filename,
                                   const android::aidl::IoDelegate& io_delegate,
                                   AidlTypenames& typenames, bool is_preprocessed) {
@@ -78,10 +55,6 @@
     return nullptr;
   }
 
-  // Preprocess parsed document before adding to typenames.
-  UnionTagGenerater v;
-  VisitTopDown(v, *parser.document_);
-
   // transfer ownership to AidlTypenames and return the raw pointer
   const AidlDocument* result = parser.document_.get();
   if (!typenames.AddDocument(std::move(parser.document_))) {
diff --git a/tests/aidl_test_client_ndk_parcelables.cpp b/tests/aidl_test_client_ndk_parcelables.cpp
index 8b9cd19..72d309d 100644
--- a/tests/aidl_test_client_ndk_parcelables.cpp
+++ b/tests/aidl_test_client_ndk_parcelables.cpp
@@ -25,7 +25,6 @@
 #include <aidl/android/aidl/fixedsizearray/FixedSizeArrayExample.h>
 #include <aidl/android/aidl/tests/ITestService.h>
 #include <aidl/android/aidl/tests/RecursiveList.h>
-#include <aidl/android/aidl/tests/Union.h>
 
 using aidl::android::aidl::fixedsizearray::FixedSizeArrayExample;
 using BnRepeatFixedSizeArray =
@@ -40,7 +39,6 @@
 using aidl::android::aidl::tests::BackendType;
 using aidl::android::aidl::tests::ITestService;
 using aidl::android::aidl::tests::RecursiveList;
-using aidl::android::aidl::tests::Union;
 using android::OK;
 using ndk::AParcel_readData;
 using ndk::AParcel_writeData;
@@ -81,21 +79,6 @@
   EXPECT_EQ(nullptr, cur);
 }
 
-TEST_F(AidlTest, GetUnionTags) {
-  std::vector<Union> unions;
-  std::vector<Union::Tag> tags;
-  // test empty
-  auto status = getService<ITestService>()->GetUnionTags(unions, &tags);
-  ASSERT_TRUE(status.isOk());
-  EXPECT_EQ(tags, (std::vector<Union::Tag>{}));
-  // test non-empty
-  unions.push_back(Union::make<Union::n>());
-  unions.push_back(Union::make<Union::ns>());
-  status = getService<ITestService>()->GetUnionTags(unions, &tags);
-  ASSERT_TRUE(status.isOk());
-  EXPECT_EQ(tags, (std::vector<Union::Tag>{Union::n, Union::ns}));
-}
-
 TEST_F(AidlTest, FixedSizeArray) {
   auto parcel = AParcel_create();
 
diff --git a/tests/aidl_test_client_parcelables.cpp b/tests/aidl_test_client_parcelables.cpp
index 119f513..8d4adee 100644
--- a/tests/aidl_test_client_parcelables.cpp
+++ b/tests/aidl_test_client_parcelables.cpp
@@ -575,21 +575,6 @@
   EXPECT_EQ(nullptr, cur);
 }
 
-TEST_F(AidlTest, GetUnionTags) {
-  std::vector<Union> unions;
-  std::vector<Union::Tag> tags;
-  // test empty
-  auto status = service->GetUnionTags(unions, &tags);
-  ASSERT_TRUE(status.isOk()) << status.toString8();
-  EXPECT_EQ(tags, (std::vector<Union::Tag>{}));
-  // test non-empty
-  unions.push_back(Union::make<Union::n>());
-  unions.push_back(Union::make<Union::ns>());
-  status = service->GetUnionTags(unions, &tags);
-  ASSERT_TRUE(status.isOk()) << status.toString8();
-  EXPECT_EQ(tags, (std::vector<Union::Tag>{Union::n, Union::ns}));
-}
-
 TEST_F(AidlTest, FixedSizeArray) {
   android::Parcel parcel;
 
diff --git a/tests/aidl_test_service.cpp b/tests/aidl_test_service.cpp
index a13547f..f000372 100644
--- a/tests/aidl_test_service.cpp
+++ b/tests/aidl_test_service.cpp
@@ -742,15 +742,6 @@
     return Status::ok();
   }
 
-  Status GetUnionTags(const std::vector<Union>& input,
-                      std::vector<Union::Tag>* _aidl_return) override {
-    std::vector<Union::Tag> tags;
-    std::transform(input.begin(), input.end(), std::back_inserter(tags),
-                   std::mem_fn(&Union::getTag));
-    *_aidl_return = std::move(tags);
-    return Status::ok();
-  }
-
   Status GetCppJavaTests(sp<IBinder>* ret) {
     *ret = new CppJavaTests;
     return Status::ok();
diff --git a/tests/android/aidl/tests/ITestService.aidl b/tests/android/aidl/tests/ITestService.aidl
index 63c0c6c..f8e168a 100644
--- a/tests/android/aidl/tests/ITestService.aidl
+++ b/tests/android/aidl/tests/ITestService.aidl
@@ -25,7 +25,6 @@
 import android.aidl.tests.LongEnum;
 import android.aidl.tests.RecursiveList;
 import android.aidl.tests.StructuredParcelable;
-import android.aidl.tests.Union;
 import android.aidl.tests.extension.ExtendableParcelable;
 
 /**
@@ -260,8 +259,6 @@
     IOldName GetOldNameInterface();
     INewName GetNewNameInterface();
 
-    Union.Tag[] GetUnionTags(in Union[] input);
-
     // Retrieve the ICppJavaTests if the server supports it
     @nullable IBinder GetCppJavaTests();
 
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp
index b7e11ae..40264c0 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp
@@ -2527,44 +2527,6 @@
   return _aidl_status;
 }
 
-::android::binder::Status BpTestService::GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& input, ::std::vector<::android::aidl::tests::Union::Tag>* _aidl_return) {
-  ::android::Parcel _aidl_data;
-  _aidl_data.markSensitive();
-  _aidl_data.markForBinder(remoteStrong());
-  ::android::Parcel _aidl_reply;
-  ::android::status_t _aidl_ret_status = ::android::OK;
-  ::android::binder::Status _aidl_status;
-  _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_data.writeParcelableVector(input);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = remote()->transact(BnTestService::TRANSACTION_GetUnionTags, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_CLEAR_BUF);
-  if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ITestService::getDefaultImpl())) {
-     return ITestService::getDefaultImpl()->GetUnionTags(input, _aidl_return);
-  }
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  if (!_aidl_status.isOk()) {
-    return _aidl_status;
-  }
-  _aidl_ret_status = _aidl_reply.readEnumVector(_aidl_return);
-  if (((_aidl_ret_status) != (::android::OK))) {
-    goto _aidl_error;
-  }
-  _aidl_error:
-  _aidl_status.setFromStatusT(_aidl_ret_status);
-  return _aidl_status;
-}
-
 ::android::binder::Status BpTestService::GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) {
   ::android::Parcel _aidl_data;
   _aidl_data.markSensitive();
@@ -4640,36 +4602,6 @@
     }
   }
   break;
-  case BnTestService::TRANSACTION_GetUnionTags:
-  {
-    ::std::vector<::android::aidl::tests::Union> in_input;
-    ::std::vector<::android::aidl::tests::Union::Tag> _aidl_return;
-    if (!(_aidl_data.checkInterface(this))) {
-      _aidl_ret_status = ::android::BAD_TYPE;
-      break;
-    }
-    _aidl_ret_status = _aidl_data.readParcelableVector(&in_input);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    if (auto st = _aidl_data.enforceNoDataAvail(); !st.isOk()) {
-      _aidl_ret_status = st.writeToParcel(_aidl_reply);
-      break;
-    }
-    ::android::binder::Status _aidl_status(GetUnionTags(in_input, &_aidl_return));
-    _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-    if (!_aidl_status.isOk()) {
-      break;
-    }
-    _aidl_ret_status = _aidl_reply->writeEnumVector(_aidl_return);
-    if (((_aidl_ret_status) != (::android::OK))) {
-      break;
-    }
-  }
-  break;
   case BnTestService::TRANSACTION_GetCppJavaTests:
   {
     ::android::sp<::android::IBinder> _aidl_return;
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp.d b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp.d
index de66202..f82081e 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp.d
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/android/aidl/tests/ITestService.cpp.d
@@ -9,6 +9,6 @@
   system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
   system/tools/aidl/tests/android/aidl/tests/RecursiveList.aidl \
   system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
-  system/tools/aidl/tests/android/aidl/tests/Union.aidl \
   system/tools/aidl/tests/android/aidl/tests/extension/ExtendableParcelable.aidl \
-  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl
+  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ArrayOfInterfaces.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ArrayOfInterfaces.h
index b5c0a6c..0265063 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ArrayOfInterfaces.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ArrayOfInterfaces.h
@@ -2,16 +2,12 @@
 
 #include <android/aidl/tests/ArrayOfInterfaces.h>
 #include <android/binder_to_string.h>
-#include <array>
-#include <binder/Enums.h>
 #include <binder/IBinder.h>
 #include <binder/IInterface.h>
 #include <binder/Parcel.h>
 #include <binder/Status.h>
 #include <cassert>
-#include <cstdint>
 #include <optional>
-#include <string>
 #include <tuple>
 #include <type_traits>
 #include <utility>
@@ -140,17 +136,12 @@
   };  // class MyParcelable
   class MyUnion : public ::android::Parcelable {
   public:
-    enum class Tag : int32_t {
-      iface = 0,
-      nullable_iface = 1,
-      iface_array = 2,
-      nullable_iface_array = 3,
+    enum Tag : int32_t {
+      iface = 0,  // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface iface;
+      nullable_iface,  // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface nullable_iface;
+      iface_array,  // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface[] iface_array;
+      nullable_iface_array,  // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface[] nullable_iface_array;
     };
-    // Expose tag symbols for legacy code
-    static const inline Tag iface = Tag::iface;
-    static const inline Tag nullable_iface = Tag::nullable_iface;
-    static const inline Tag iface_array = Tag::iface_array;
-    static const inline Tag nullable_iface_array = Tag::nullable_iface_array;
 
     template<typename _Tp>
     static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, MyUnion>;
@@ -272,37 +263,3 @@
 }  // namespace tests
 }  // namespace aidl
 }  // namespace android
-namespace android {
-namespace aidl {
-namespace tests {
-[[nodiscard]] static inline std::string toString(ArrayOfInterfaces::MyUnion::Tag val) {
-  switch(val) {
-  case ArrayOfInterfaces::MyUnion::Tag::iface:
-    return "iface";
-  case ArrayOfInterfaces::MyUnion::Tag::nullable_iface:
-    return "nullable_iface";
-  case ArrayOfInterfaces::MyUnion::Tag::iface_array:
-    return "iface_array";
-  case ArrayOfInterfaces::MyUnion::Tag::nullable_iface_array:
-    return "nullable_iface_array";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-namespace android {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag, 4> enum_values<::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag> = {
-  ::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::iface,
-  ::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::nullable_iface,
-  ::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::iface_array,
-  ::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::nullable_iface_array,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h
index 3cb8ad0..2d2a864 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BnTestService.h
@@ -71,9 +71,8 @@
   static constexpr uint32_t TRANSACTION_ReverseNullableIBinderArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 60;
   static constexpr uint32_t TRANSACTION_GetOldNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 61;
   static constexpr uint32_t TRANSACTION_GetNewNameInterface = ::android::IBinder::FIRST_CALL_TRANSACTION + 62;
-  static constexpr uint32_t TRANSACTION_GetUnionTags = ::android::IBinder::FIRST_CALL_TRANSACTION + 63;
-  static constexpr uint32_t TRANSACTION_GetCppJavaTests = ::android::IBinder::FIRST_CALL_TRANSACTION + 64;
-  static constexpr uint32_t TRANSACTION_getBackendType = ::android::IBinder::FIRST_CALL_TRANSACTION + 65;
+  static constexpr uint32_t TRANSACTION_GetCppJavaTests = ::android::IBinder::FIRST_CALL_TRANSACTION + 63;
+  static constexpr uint32_t TRANSACTION_getBackendType = ::android::IBinder::FIRST_CALL_TRANSACTION + 64;
   explicit BnTestService();
   ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
 };  // class BnTestService
@@ -271,9 +270,6 @@
   ::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* _aidl_return) override {
     return _aidl_delegate->GetNewNameInterface(_aidl_return);
   }
-  ::android::binder::Status GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& input, ::std::vector<::android::aidl::tests::Union::Tag>* _aidl_return) override {
-    return _aidl_delegate->GetUnionTags(input, _aidl_return);
-  }
   ::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) override {
     return _aidl_delegate->GetCppJavaTests(_aidl_return);
   }
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h
index 3829d9b..c1cbaa8 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/BpTestService.h
@@ -75,7 +75,6 @@
   ::android::binder::Status ReverseNullableIBinderArray(const ::std::optional<::std::vector<::android::sp<::android::IBinder>>>& input, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* repeated, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* _aidl_return) override;
   ::android::binder::Status GetOldNameInterface(::android::sp<::android::aidl::tests::IOldName>* _aidl_return) override;
   ::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* _aidl_return) override;
-  ::android::binder::Status GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& input, ::std::vector<::android::aidl::tests::Union::Tag>* _aidl_return) override;
   ::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) override;
   ::android::binder::Status getBackendType(::android::aidl::tests::BackendType* _aidl_return) override;
 };  // class BpTestService
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/FixedSize.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/FixedSize.h
index 65f6711..f94a3b8 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/FixedSize.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/FixedSize.h
@@ -3,13 +3,10 @@
 #include <android/aidl/tests/FixedSize.h>
 #include <android/aidl/tests/LongEnum.h>
 #include <android/binder_to_string.h>
-#include <array>
-#include <binder/Enums.h>
 #include <binder/Parcel.h>
 #include <binder/Status.h>
 #include <cassert>
 #include <cstdint>
-#include <string>
 #include <tuple>
 #include <type_traits>
 #include <utility>
@@ -27,25 +24,16 @@
 public:
   class FixedUnion : public ::android::Parcelable {
   public:
-    enum class Tag : int8_t {
-      booleanValue = 0,
-      byteValue = 1,
-      charValue = 2,
-      intValue = 3,
-      longValue = 4,
-      floatValue = 5,
-      doubleValue = 6,
-      enumValue = 7,
+    enum Tag : uint8_t {
+      booleanValue = 0,  // boolean booleanValue;
+      byteValue,  // byte byteValue;
+      charValue,  // char charValue;
+      intValue,  // int intValue;
+      longValue,  // long longValue;
+      floatValue,  // float floatValue;
+      doubleValue,  // double doubleValue;
+      enumValue,  // android.aidl.tests.LongEnum enumValue;
     };
-    // Expose tag symbols for legacy code
-    static const inline Tag booleanValue = Tag::booleanValue;
-    static const inline Tag byteValue = Tag::byteValue;
-    static const inline Tag charValue = Tag::charValue;
-    static const inline Tag intValue = Tag::intValue;
-    static const inline Tag longValue = Tag::longValue;
-    static const inline Tag floatValue = Tag::floatValue;
-    static const inline Tag doubleValue = Tag::doubleValue;
-    static const inline Tag enumValue = Tag::enumValue;
 
     template <Tag _Tag>
     using _at = typename std::tuple_element<static_cast<size_t>(_Tag), std::tuple<bool, int8_t, char16_t, int32_t, int64_t, float, double, ::android::aidl::tests::LongEnum>>::type;
@@ -131,7 +119,7 @@
       return os.str();
     }
   private:
-    Tag _tag = booleanValue;
+    Tag _tag __attribute__((aligned (1))) = booleanValue;
     union _value_t {
       _value_t() {}
       ~_value_t() {}
@@ -232,49 +220,3 @@
 }  // namespace tests
 }  // namespace aidl
 }  // namespace android
-namespace android {
-namespace aidl {
-namespace tests {
-[[nodiscard]] static inline std::string toString(FixedSize::FixedUnion::Tag val) {
-  switch(val) {
-  case FixedSize::FixedUnion::Tag::booleanValue:
-    return "booleanValue";
-  case FixedSize::FixedUnion::Tag::byteValue:
-    return "byteValue";
-  case FixedSize::FixedUnion::Tag::charValue:
-    return "charValue";
-  case FixedSize::FixedUnion::Tag::intValue:
-    return "intValue";
-  case FixedSize::FixedUnion::Tag::longValue:
-    return "longValue";
-  case FixedSize::FixedUnion::Tag::floatValue:
-    return "floatValue";
-  case FixedSize::FixedUnion::Tag::doubleValue:
-    return "doubleValue";
-  case FixedSize::FixedUnion::Tag::enumValue:
-    return "enumValue";
-  default:
-    return std::to_string(static_cast<int8_t>(val));
-  }
-}
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-namespace android {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<::android::aidl::tests::FixedSize::FixedUnion::Tag, 8> enum_values<::android::aidl::tests::FixedSize::FixedUnion::Tag> = {
-  ::android::aidl::tests::FixedSize::FixedUnion::Tag::booleanValue,
-  ::android::aidl::tests::FixedSize::FixedUnion::Tag::byteValue,
-  ::android::aidl::tests::FixedSize::FixedUnion::Tag::charValue,
-  ::android::aidl::tests::FixedSize::FixedUnion::Tag::intValue,
-  ::android::aidl::tests::FixedSize::FixedUnion::Tag::longValue,
-  ::android::aidl::tests::FixedSize::FixedUnion::Tag::floatValue,
-  ::android::aidl::tests::FixedSize::FixedUnion::Tag::doubleValue,
-  ::android::aidl::tests::FixedSize::FixedUnion::Tag::enumValue,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
index 9246a87..dd0e7f1 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
@@ -10,7 +10,6 @@
 #include <android/aidl/tests/LongEnum.h>
 #include <android/aidl/tests/RecursiveList.h>
 #include <android/aidl/tests/StructuredParcelable.h>
-#include <android/aidl/tests/Union.h>
 #include <android/aidl/tests/extension/ExtendableParcelable.h>
 #include <android/binder_to_string.h>
 #include <binder/IBinder.h>
@@ -273,7 +272,6 @@
   virtual ::android::binder::Status ReverseNullableIBinderArray(const ::std::optional<::std::vector<::android::sp<::android::IBinder>>>& input, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* repeated, ::std::optional<::std::vector<::android::sp<::android::IBinder>>>* _aidl_return) = 0;
   virtual ::android::binder::Status GetOldNameInterface(::android::sp<::android::aidl::tests::IOldName>* _aidl_return) = 0;
   virtual ::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* _aidl_return) = 0;
-  virtual ::android::binder::Status GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& input, ::std::vector<::android::aidl::tests::Union::Tag>* _aidl_return) = 0;
   virtual ::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* _aidl_return) = 0;
   virtual ::android::binder::Status getBackendType(::android::aidl::tests::BackendType* _aidl_return) = 0;
 };  // class ITestService
@@ -472,9 +470,6 @@
   ::android::binder::Status GetNewNameInterface(::android::sp<::android::aidl::tests::INewName>* /*_aidl_return*/) override {
     return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
   }
-  ::android::binder::Status GetUnionTags(const ::std::vector<::android::aidl::tests::Union>& /*input*/, ::std::vector<::android::aidl::tests::Union::Tag>* /*_aidl_return*/) override {
-    return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
-  }
   ::android::binder::Status GetCppJavaTests(::android::sp<::android::IBinder>* /*_aidl_return*/) override {
     return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
   }
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ListOfInterfaces.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ListOfInterfaces.h
index 455bf4b..e9dcb2b 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ListOfInterfaces.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ListOfInterfaces.h
@@ -2,16 +2,12 @@
 
 #include <android/aidl/tests/ListOfInterfaces.h>
 #include <android/binder_to_string.h>
-#include <array>
-#include <binder/Enums.h>
 #include <binder/IBinder.h>
 #include <binder/IInterface.h>
 #include <binder/Parcel.h>
 #include <binder/Status.h>
 #include <cassert>
-#include <cstdint>
 #include <optional>
-#include <string>
 #include <tuple>
 #include <type_traits>
 #include <utility>
@@ -140,17 +136,12 @@
   };  // class MyParcelable
   class MyUnion : public ::android::Parcelable {
   public:
-    enum class Tag : int32_t {
-      iface = 0,
-      nullable_iface = 1,
-      iface_list = 2,
-      nullable_iface_list = 3,
+    enum Tag : int32_t {
+      iface = 0,  // android.aidl.tests.ListOfInterfaces.IEmptyInterface iface;
+      nullable_iface,  // android.aidl.tests.ListOfInterfaces.IEmptyInterface nullable_iface;
+      iface_list,  // List<android.aidl.tests.ListOfInterfaces.IEmptyInterface> iface_list;
+      nullable_iface_list,  // List<android.aidl.tests.ListOfInterfaces.IEmptyInterface> nullable_iface_list;
     };
-    // Expose tag symbols for legacy code
-    static const inline Tag iface = Tag::iface;
-    static const inline Tag nullable_iface = Tag::nullable_iface;
-    static const inline Tag iface_list = Tag::iface_list;
-    static const inline Tag nullable_iface_list = Tag::nullable_iface_list;
 
     template<typename _Tp>
     static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, MyUnion>;
@@ -272,37 +263,3 @@
 }  // namespace tests
 }  // namespace aidl
 }  // namespace android
-namespace android {
-namespace aidl {
-namespace tests {
-[[nodiscard]] static inline std::string toString(ListOfInterfaces::MyUnion::Tag val) {
-  switch(val) {
-  case ListOfInterfaces::MyUnion::Tag::iface:
-    return "iface";
-  case ListOfInterfaces::MyUnion::Tag::nullable_iface:
-    return "nullable_iface";
-  case ListOfInterfaces::MyUnion::Tag::iface_list:
-    return "iface_list";
-  case ListOfInterfaces::MyUnion::Tag::nullable_iface_list:
-    return "nullable_iface_list";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-namespace android {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<::android::aidl::tests::ListOfInterfaces::MyUnion::Tag, 4> enum_values<::android::aidl::tests::ListOfInterfaces::MyUnion::Tag> = {
-  ::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::iface,
-  ::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::nullable_iface,
-  ::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::iface_list,
-  ::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::nullable_iface_list,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/Union.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/Union.h
index a82300f..4428401 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/Union.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/Union.h
@@ -2,8 +2,6 @@
 
 #include <android/aidl/tests/ByteEnum.h>
 #include <android/binder_to_string.h>
-#include <array>
-#include <binder/Enums.h>
 #include <binder/IBinder.h>
 #include <binder/Parcel.h>
 #include <binder/Status.h>
@@ -25,23 +23,15 @@
 namespace tests {
 class Union : public ::android::Parcelable {
 public:
-  enum class Tag : int32_t {
-    ns = 0,
-    n = 1,
-    m = 2,
-    s = 3,
-    ibinder = 4,
-    ss = 5,
-    be = 6,
+  enum Tag : int32_t {
+    ns = 0,  // int[] ns;
+    n,  // int n;
+    m,  // int m;
+    s,  // String s;
+    ibinder,  // IBinder ibinder;
+    ss,  // List<String> ss;
+    be,  // android.aidl.tests.ByteEnum be;
   };
-  // Expose tag symbols for legacy code
-  static const inline Tag ns = Tag::ns;
-  static const inline Tag n = Tag::n;
-  static const inline Tag m = Tag::m;
-  static const inline Tag s = Tag::s;
-  static const inline Tag ibinder = Tag::ibinder;
-  static const inline Tag ss = Tag::ss;
-  static const inline Tag be = Tag::be;
 
   template<typename _Tp>
   static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
@@ -135,46 +125,3 @@
 }  // namespace tests
 }  // namespace aidl
 }  // namespace android
-namespace android {
-namespace aidl {
-namespace tests {
-[[nodiscard]] static inline std::string toString(Union::Tag val) {
-  switch(val) {
-  case Union::Tag::ns:
-    return "ns";
-  case Union::Tag::n:
-    return "n";
-  case Union::Tag::m:
-    return "m";
-  case Union::Tag::s:
-    return "s";
-  case Union::Tag::ibinder:
-    return "ibinder";
-  case Union::Tag::ss:
-    return "ss";
-  case Union::Tag::be:
-    return "be";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-namespace android {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<::android::aidl::tests::Union::Tag, 7> enum_values<::android::aidl::tests::Union::Tag> = {
-  ::android::aidl::tests::Union::Tag::ns,
-  ::android::aidl::tests::Union::Tag::n,
-  ::android::aidl::tests::Union::Tag::m,
-  ::android::aidl::tests::Union::Tag::s,
-  ::android::aidl::tests::Union::Tag::ibinder,
-  ::android::aidl::tests::Union::Tag::ss,
-  ::android::aidl::tests::Union::Tag::be,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/UnionWithFd.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/UnionWithFd.h
index c97edf1..06ae2a6 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/UnionWithFd.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/UnionWithFd.h
@@ -1,14 +1,11 @@
 #pragma once
 
 #include <android/binder_to_string.h>
-#include <array>
-#include <binder/Enums.h>
 #include <binder/Parcel.h>
 #include <binder/ParcelFileDescriptor.h>
 #include <binder/Status.h>
 #include <cassert>
 #include <cstdint>
-#include <string>
 #include <type_traits>
 #include <utility>
 #include <utils/String16.h>
@@ -23,13 +20,10 @@
 namespace tests {
 class UnionWithFd : public ::android::Parcelable {
 public:
-  enum class Tag : int32_t {
-    num = 0,
-    pfd = 1,
+  enum Tag : int32_t {
+    num = 0,  // int num;
+    pfd,  // ParcelFileDescriptor pfd;
   };
-  // Expose tag symbols for legacy code
-  static const inline Tag num = Tag::num;
-  static const inline Tag pfd = Tag::pfd;
 
   template<typename _Tp>
   static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionWithFd>;
@@ -117,31 +111,3 @@
 }  // namespace tests
 }  // namespace aidl
 }  // namespace android
-namespace android {
-namespace aidl {
-namespace tests {
-[[nodiscard]] static inline std::string toString(UnionWithFd::Tag val) {
-  switch(val) {
-  case UnionWithFd::Tag::num:
-    return "num";
-  case UnionWithFd::Tag::pfd:
-    return "pfd";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-namespace android {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<::android::aidl::tests::UnionWithFd::Tag, 2> enum_values<::android::aidl::tests::UnionWithFd::Tag> = {
-  ::android::aidl::tests::UnionWithFd::Tag::num,
-  ::android::aidl::tests::UnionWithFd::Tag::pfd,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/EnumUnion.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/EnumUnion.h
index a65f9f0..3898fbc 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/EnumUnion.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/EnumUnion.h
@@ -3,13 +3,9 @@
 #include <android/aidl/tests/IntEnum.h>
 #include <android/aidl/tests/LongEnum.h>
 #include <android/binder_to_string.h>
-#include <array>
-#include <binder/Enums.h>
 #include <binder/Parcel.h>
 #include <binder/Status.h>
 #include <cassert>
-#include <cstdint>
-#include <string>
 #include <type_traits>
 #include <utility>
 #include <utils/String16.h>
@@ -25,13 +21,10 @@
 namespace unions {
 class EnumUnion : public ::android::Parcelable {
 public:
-  enum class Tag : int32_t {
-    intEnum = 0,
-    longEnum = 1,
+  enum Tag : int32_t {
+    intEnum = 0,  // android.aidl.tests.IntEnum intEnum;
+    longEnum,  // android.aidl.tests.LongEnum longEnum;
   };
-  // Expose tag symbols for legacy code
-  static const inline Tag intEnum = Tag::intEnum;
-  static const inline Tag longEnum = Tag::longEnum;
 
   template<typename _Tp>
   static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, EnumUnion>;
@@ -120,33 +113,3 @@
 }  // namespace tests
 }  // namespace aidl
 }  // namespace android
-namespace android {
-namespace aidl {
-namespace tests {
-namespace unions {
-[[nodiscard]] static inline std::string toString(EnumUnion::Tag val) {
-  switch(val) {
-  case EnumUnion::Tag::intEnum:
-    return "intEnum";
-  case EnumUnion::Tag::longEnum:
-    return "longEnum";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace unions
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-namespace android {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<::android::aidl::tests::unions::EnumUnion::Tag, 2> enum_values<::android::aidl::tests::unions::EnumUnion::Tag> = {
-  ::android::aidl::tests::unions::EnumUnion::Tag::intEnum,
-  ::android::aidl::tests::unions::EnumUnion::Tag::longEnum,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/UnionInUnion.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/UnionInUnion.h
index 9badc3a..9adbbe9 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/UnionInUnion.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/unions/UnionInUnion.h
@@ -2,13 +2,10 @@
 
 #include <android/aidl/tests/unions/EnumUnion.h>
 #include <android/binder_to_string.h>
-#include <array>
-#include <binder/Enums.h>
 #include <binder/Parcel.h>
 #include <binder/Status.h>
 #include <cassert>
 #include <cstdint>
-#include <string>
 #include <type_traits>
 #include <utility>
 #include <utils/String16.h>
@@ -24,13 +21,10 @@
 namespace unions {
 class UnionInUnion : public ::android::Parcelable {
 public:
-  enum class Tag : int32_t {
-    first = 0,
-    second = 1,
+  enum Tag : int32_t {
+    first = 0,  // android.aidl.tests.unions.EnumUnion first;
+    second,  // int second;
   };
-  // Expose tag symbols for legacy code
-  static const inline Tag first = Tag::first;
-  static const inline Tag second = Tag::second;
 
   template<typename _Tp>
   static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionInUnion>;
@@ -119,33 +113,3 @@
 }  // namespace tests
 }  // namespace aidl
 }  // namespace android
-namespace android {
-namespace aidl {
-namespace tests {
-namespace unions {
-[[nodiscard]] static inline std::string toString(UnionInUnion::Tag val) {
-  switch(val) {
-  case UnionInUnion::Tag::first:
-    return "first";
-  case UnionInUnion::Tag::second:
-    return "second";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace unions
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-namespace android {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<::android::aidl::tests::unions::UnionInUnion::Tag, 2> enum_values<::android::aidl::tests::unions::UnionInUnion::Tag> = {
-  ::android::aidl::tests::unions::UnionInUnion::Tag::first,
-  ::android::aidl::tests::unions::UnionInUnion::Tag::second,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace android
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ArrayOfInterfaces.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ArrayOfInterfaces.java
index ea45e08..5c86379 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ArrayOfInterfaces.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ArrayOfInterfaces.java
@@ -565,11 +565,5 @@
       this._tag = _tag;
       this._value = _value;
     }
-    public static @interface Tag {
-      public static final int iface = 0;
-      public static final int nullable_iface = 1;
-      public static final int iface_array = 2;
-      public static final int nullable_iface_array = 3;
-    }
   }
 }
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/FixedSize.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/FixedSize.java
index 2ff3068..1b4ca32 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/FixedSize.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/FixedSize.java
@@ -404,15 +404,5 @@
       this._tag = _tag;
       this._value = _value;
     }
-    public static @interface Tag {
-      public static final byte booleanValue = 0;
-      public static final byte byteValue = 1;
-      public static final byte charValue = 2;
-      public static final byte intValue = 3;
-      public static final byte longValue = 4;
-      public static final byte floatValue = 5;
-      public static final byte doubleValue = 6;
-      public static final byte enumValue = 7;
-    }
   }
 }
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
index 1530943..50d65a6 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
@@ -276,10 +276,6 @@
     {
       return null;
     }
-    @Override public int[] GetUnionTags(android.aidl.tests.Union[] input) throws android.os.RemoteException
-    {
-      return null;
-    }
     // Retrieve the ICppJavaTests if the server supports it
     @Override public android.os.IBinder GetCppJavaTests() throws android.os.RemoteException
     {
@@ -577,10 +573,6 @@
     {
       return mImpl.GetNewNameInterface();
     }
-    @Override public int[] GetUnionTags(android.aidl.tests.Union[] input) throws android.os.RemoteException
-    {
-      return mImpl.GetUnionTags(input);
-    }
     // Retrieve the ICppJavaTests if the server supports it
     @Override public android.os.IBinder GetCppJavaTests() throws android.os.RemoteException
     {
@@ -1389,16 +1381,6 @@
           reply.writeStrongInterface(_result);
           break;
         }
-        case TRANSACTION_GetUnionTags:
-        {
-          android.aidl.tests.Union[] _arg0;
-          _arg0 = data.createTypedArray(android.aidl.tests.Union.CREATOR);
-          data.enforceNoDataAvail();
-          int[] _result = this.GetUnionTags(_arg0);
-          reply.writeNoException();
-          reply.writeIntArray(_result);
-          break;
-        }
         case TRANSACTION_GetCppJavaTests:
         {
           android.os.IBinder _result = this.GetCppJavaTests();
@@ -3072,30 +3054,6 @@
         }
         return _result;
       }
-      @Override public int[] GetUnionTags(android.aidl.tests.Union[] input) throws android.os.RemoteException
-      {
-        android.os.Parcel _data = android.os.Parcel.obtain(asBinder());
-        _data.markSensitive();
-        android.os.Parcel _reply = android.os.Parcel.obtain();
-        int[] _result;
-        try {
-          _data.writeInterfaceToken(DESCRIPTOR);
-          _data.writeTypedArray(input, 0);
-          boolean _status = mRemote.transact(Stub.TRANSACTION_GetUnionTags, _data, _reply, android.os.IBinder.FLAG_CLEAR_BUF);
-          if (!_status) {
-            if (getDefaultImpl() != null) {
-              return getDefaultImpl().GetUnionTags(input);
-            }
-          }
-          _reply.readException();
-          _result = _reply.createIntArray();
-        }
-        finally {
-          _reply.recycle();
-          _data.recycle();
-        }
-        return _result;
-      }
       // Retrieve the ICppJavaTests if the server supports it
       @Override public android.os.IBinder GetCppJavaTests() throws android.os.RemoteException
       {
@@ -3208,9 +3166,8 @@
     static final int TRANSACTION_ReverseNullableIBinderArray = (android.os.IBinder.FIRST_CALL_TRANSACTION + 60);
     static final int TRANSACTION_GetOldNameInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 61);
     static final int TRANSACTION_GetNewNameInterface = (android.os.IBinder.FIRST_CALL_TRANSACTION + 62);
-    static final int TRANSACTION_GetUnionTags = (android.os.IBinder.FIRST_CALL_TRANSACTION + 63);
-    static final int TRANSACTION_GetCppJavaTests = (android.os.IBinder.FIRST_CALL_TRANSACTION + 64);
-    static final int TRANSACTION_getBackendType = (android.os.IBinder.FIRST_CALL_TRANSACTION + 65);
+    static final int TRANSACTION_GetCppJavaTests = (android.os.IBinder.FIRST_CALL_TRANSACTION + 63);
+    static final int TRANSACTION_getBackendType = (android.os.IBinder.FIRST_CALL_TRANSACTION + 64);
     public static boolean setDefaultImpl(android.aidl.tests.ITestService impl) {
       // Only one user of this interface can use this function
       // at a time. This is a heuristic to detect if two different
@@ -3400,7 +3357,6 @@
   public android.os.IBinder[] ReverseNullableIBinderArray(android.os.IBinder[] input, android.os.IBinder[] repeated) throws android.os.RemoteException;
   public android.aidl.tests.IOldName GetOldNameInterface() throws android.os.RemoteException;
   public android.aidl.tests.INewName GetNewNameInterface() throws android.os.RemoteException;
-  public int[] GetUnionTags(android.aidl.tests.Union[] input) throws android.os.RemoteException;
   // Retrieve the ICppJavaTests if the server supports it
   public android.os.IBinder GetCppJavaTests() throws android.os.RemoteException;
   public byte getBackendType() throws android.os.RemoteException;
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java.d b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java.d
index 561c508..f82b264 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java.d
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java.d
@@ -9,6 +9,6 @@
   system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
   system/tools/aidl/tests/android/aidl/tests/RecursiveList.aidl \
   system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
-  system/tools/aidl/tests/android/aidl/tests/Union.aidl \
   system/tools/aidl/tests/android/aidl/tests/extension/ExtendableParcelable.aidl \
-  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl
+  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ListOfInterfaces.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ListOfInterfaces.java
index 6a2564d..fafba0c 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ListOfInterfaces.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ListOfInterfaces.java
@@ -545,11 +545,5 @@
       this._tag = _tag;
       this._value = _value;
     }
-    public static @interface Tag {
-      public static final int iface = 0;
-      public static final int nullable_iface = 1;
-      public static final int iface_list = 2;
-      public static final int nullable_iface_list = 3;
-    }
   }
 }
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/Union.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/Union.java
index 018898a..50688a6 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/Union.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/Union.java
@@ -283,13 +283,4 @@
     this._tag = _tag;
     this._value = _value;
   }
-  public static @interface Tag {
-    public static final int ns = 0;
-    public static final int n = 1;
-    public static final int m = 2;
-    public static final int s = 3;
-    public static final int ibinder = 4;
-    public static final int ss = 5;
-    public static final int be = 6;
-  }
 }
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/UnionWithFd.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/UnionWithFd.java
index bdd6946..941c947 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/UnionWithFd.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/UnionWithFd.java
@@ -137,8 +137,4 @@
     this._tag = _tag;
     this._value = _value;
   }
-  public static @interface Tag {
-    public static final int num = 0;
-    public static final int pfd = 1;
-  }
 }
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/EnumUnion.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/EnumUnion.java
index 038d813..28df6de 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/EnumUnion.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/EnumUnion.java
@@ -151,8 +151,4 @@
     this._tag = _tag;
     this._value = _value;
   }
-  public static @interface Tag {
-    public static final int intEnum = 0;
-    public static final int longEnum = 1;
-  }
 }
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/UnionInUnion.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/UnionInUnion.java
index 90a68d3..241511e 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/UnionInUnion.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/unions/UnionInUnion.java
@@ -161,8 +161,4 @@
     this._tag = _tag;
     this._value = _value;
   }
-  public static @interface Tag {
-    public static final int first = 0;
-    public static final int second = 1;
-  }
 }
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp
index 8c9ff0a..0268aaa 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp
@@ -1246,25 +1246,7 @@
 
       break;
     }
-    case (FIRST_CALL_TRANSACTION + 63 /*GetUnionTags*/): {
-      std::vector<::aidl::android::aidl::tests::Union> in_input;
-      std::vector<::aidl::android::aidl::tests::Union::Tag> _aidl_return;
-
-      _aidl_ret_status = ::ndk::AParcel_readData(_aidl_in, &in_input);
-      if (_aidl_ret_status != STATUS_OK) break;
-
-      ::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetUnionTags(in_input, &_aidl_return);
-      _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
-      if (_aidl_ret_status != STATUS_OK) break;
-
-      if (!AStatus_isOk(_aidl_status.get())) break;
-
-      _aidl_ret_status = ::ndk::AParcel_writeData(_aidl_out, _aidl_return);
-      if (_aidl_ret_status != STATUS_OK) break;
-
-      break;
-    }
-    case (FIRST_CALL_TRANSACTION + 64 /*GetCppJavaTests*/): {
+    case (FIRST_CALL_TRANSACTION + 63 /*GetCppJavaTests*/): {
       ::ndk::SpAIBinder _aidl_return;
 
       ::ndk::ScopedAStatus _aidl_status = _aidl_impl->GetCppJavaTests(&_aidl_return);
@@ -1278,7 +1260,7 @@
 
       break;
     }
-    case (FIRST_CALL_TRANSACTION + 65 /*getBackendType*/): {
+    case (FIRST_CALL_TRANSACTION + 64 /*getBackendType*/): {
       ::aidl::android::aidl::tests::BackendType _aidl_return;
 
       ::ndk::ScopedAStatus _aidl_status = _aidl_impl->getBackendType(&_aidl_return);
@@ -3962,47 +3944,6 @@
   _aidl_status_return:
   return _aidl_status;
 }
-::ndk::ScopedAStatus BpTestService::GetUnionTags(const std::vector<::aidl::android::aidl::tests::Union>& in_input, std::vector<::aidl::android::aidl::tests::Union::Tag>* _aidl_return) {
-  binder_status_t _aidl_ret_status = STATUS_OK;
-  ::ndk::ScopedAStatus _aidl_status;
-  ::ndk::ScopedAParcel _aidl_in;
-  ::ndk::ScopedAParcel _aidl_out;
-
-  _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR());
-  AParcel_markSensitive(_aidl_in.get());
-  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
-
-  _aidl_ret_status = ::ndk::AParcel_writeData(_aidl_in.get(), in_input);
-  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
-
-  _aidl_ret_status = AIBinder_transact(
-    asBinder().get(),
-    (FIRST_CALL_TRANSACTION + 63 /*GetUnionTags*/),
-    _aidl_in.getR(),
-    _aidl_out.getR(),
-    FLAG_CLEAR_BUF
-    #ifdef BINDER_STABILITY_SUPPORT
-    | FLAG_PRIVATE_LOCAL
-    #endif  // BINDER_STABILITY_SUPPORT
-    );
-  if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && ITestService::getDefaultImpl()) {
-    _aidl_status = ITestService::getDefaultImpl()->GetUnionTags(in_input, _aidl_return);
-    goto _aidl_status_return;
-  }
-  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
-
-  _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
-  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
-
-  if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
-  _aidl_ret_status = ::ndk::AParcel_readData(_aidl_out.get(), _aidl_return);
-  if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
-
-  _aidl_error:
-  _aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
-  _aidl_status_return:
-  return _aidl_status;
-}
 ::ndk::ScopedAStatus BpTestService::GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) {
   binder_status_t _aidl_ret_status = STATUS_OK;
   ::ndk::ScopedAStatus _aidl_status;
@@ -4015,7 +3956,7 @@
 
   _aidl_ret_status = AIBinder_transact(
     asBinder().get(),
-    (FIRST_CALL_TRANSACTION + 64 /*GetCppJavaTests*/),
+    (FIRST_CALL_TRANSACTION + 63 /*GetCppJavaTests*/),
     _aidl_in.getR(),
     _aidl_out.getR(),
     FLAG_CLEAR_BUF
@@ -4053,7 +3994,7 @@
 
   _aidl_ret_status = AIBinder_transact(
     asBinder().get(),
-    (FIRST_CALL_TRANSACTION + 65 /*getBackendType*/),
+    (FIRST_CALL_TRANSACTION + 64 /*getBackendType*/),
     _aidl_in.getR(),
     _aidl_out.getR(),
     FLAG_CLEAR_BUF
@@ -4447,11 +4388,6 @@
   _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
   return _aidl_status;
 }
-::ndk::ScopedAStatus ITestServiceDefault::GetUnionTags(const std::vector<::aidl::android::aidl::tests::Union>& /*in_input*/, std::vector<::aidl::android::aidl::tests::Union::Tag>* /*_aidl_return*/) {
-  ::ndk::ScopedAStatus _aidl_status;
-  _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
-  return _aidl_status;
-}
 ::ndk::ScopedAStatus ITestServiceDefault::GetCppJavaTests(::ndk::SpAIBinder* /*_aidl_return*/) {
   ::ndk::ScopedAStatus _aidl_status;
   _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp.d b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp.d
index 19acd9f..b46066a 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp.d
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/android/aidl/tests/ITestService.cpp.d
@@ -9,6 +9,6 @@
   system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
   system/tools/aidl/tests/android/aidl/tests/RecursiveList.aidl \
   system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
-  system/tools/aidl/tests/android/aidl/tests/Union.aidl \
   system/tools/aidl/tests/android/aidl/tests/extension/ExtendableParcelable.aidl \
-  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl
+  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ArrayOfInterfaces.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ArrayOfInterfaces.h
index b2b9e7b..40951a7 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ArrayOfInterfaces.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ArrayOfInterfaces.h
@@ -1,6 +1,5 @@
 #pragma once
 
-#include <array>
 #include <cassert>
 #include <cstdint>
 #include <memory>
@@ -10,7 +9,6 @@
 #include <utility>
 #include <variant>
 #include <vector>
-#include <android/binder_enums.h>
 #include <android/binder_ibinder.h>
 #include <android/binder_interface_utils.h>
 #include <android/binder_parcelable_utils.h>
@@ -154,19 +152,13 @@
     typedef std::false_type fixed_size;
     static const char* descriptor;
 
-    enum class Tag : int32_t {
-      iface = 0,
-      nullable_iface = 1,
-      iface_array = 2,
-      nullable_iface_array = 3,
+    enum Tag : int32_t {
+      iface = 0,  // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface iface;
+      nullable_iface,  // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface nullable_iface;
+      iface_array,  // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface[] iface_array;
+      nullable_iface_array,  // android.aidl.tests.ArrayOfInterfaces.IEmptyInterface[] nullable_iface_array;
     };
 
-    // Expose tag symbols for legacy code
-    static const inline Tag iface = Tag::iface;
-    static const inline Tag nullable_iface = Tag::nullable_iface;
-    static const inline Tag iface_array = Tag::iface_array;
-    static const inline Tag nullable_iface_array = Tag::nullable_iface_array;
-
     template<typename _Tp>
     static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, MyUnion>;
 
@@ -285,39 +277,3 @@
 }  // namespace aidl
 }  // namespace android
 }  // namespace aidl
-namespace aidl {
-namespace android {
-namespace aidl {
-namespace tests {
-[[nodiscard]] static inline std::string toString(ArrayOfInterfaces::MyUnion::Tag val) {
-  switch(val) {
-  case ArrayOfInterfaces::MyUnion::Tag::iface:
-    return "iface";
-  case ArrayOfInterfaces::MyUnion::Tag::nullable_iface:
-    return "nullable_iface";
-  case ArrayOfInterfaces::MyUnion::Tag::iface_array:
-    return "iface_array";
-  case ArrayOfInterfaces::MyUnion::Tag::nullable_iface_array:
-    return "nullable_iface_array";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-}  // namespace aidl
-namespace ndk {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<aidl::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag, 4> enum_values<aidl::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag> = {
-  aidl::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::iface,
-  aidl::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::nullable_iface,
-  aidl::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::iface_array,
-  aidl::android::aidl::tests::ArrayOfInterfaces::MyUnion::Tag::nullable_iface_array,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BpTestService.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BpTestService.h
index 2cd9768..71b75be 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BpTestService.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/BpTestService.h
@@ -76,7 +76,6 @@
   ::ndk::ScopedAStatus ReverseNullableIBinderArray(const std::optional<std::vector<::ndk::SpAIBinder>>& in_input, std::optional<std::vector<::ndk::SpAIBinder>>* out_repeated, std::optional<std::vector<::ndk::SpAIBinder>>* _aidl_return) override;
   ::ndk::ScopedAStatus GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* _aidl_return) override;
   ::ndk::ScopedAStatus GetNewNameInterface(std::shared_ptr<::aidl::android::aidl::tests::INewName>* _aidl_return) override;
-  ::ndk::ScopedAStatus GetUnionTags(const std::vector<::aidl::android::aidl::tests::Union>& in_input, std::vector<::aidl::android::aidl::tests::Union::Tag>* _aidl_return) override;
   ::ndk::ScopedAStatus GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) override;
   ::ndk::ScopedAStatus getBackendType(::aidl::android::aidl::tests::BackendType* _aidl_return) override;
 };
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/FixedSize.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/FixedSize.h
index 541757a..7c92e11 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/FixedSize.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/FixedSize.h
@@ -1,6 +1,5 @@
 #pragma once
 
-#include <array>
 #include <cassert>
 #include <cstdint>
 #include <memory>
@@ -11,7 +10,6 @@
 #include <utility>
 #include <variant>
 #include <vector>
-#include <android/binder_enums.h>
 #include <android/binder_interface_utils.h>
 #include <android/binder_parcelable_utils.h>
 #include <android/binder_to_string.h>
@@ -39,27 +37,17 @@
     typedef std::true_type fixed_size;
     static const char* descriptor;
 
-    enum class Tag : int8_t {
-      booleanValue = 0,
-      byteValue = 1,
-      charValue = 2,
-      intValue = 3,
-      longValue = 4,
-      floatValue = 5,
-      doubleValue = 6,
-      enumValue = 7,
+    enum Tag : uint8_t {
+      booleanValue = 0,  // boolean booleanValue;
+      byteValue,  // byte byteValue;
+      charValue,  // char charValue;
+      intValue,  // int intValue;
+      longValue,  // long longValue;
+      floatValue,  // float floatValue;
+      doubleValue,  // double doubleValue;
+      enumValue,  // android.aidl.tests.LongEnum enumValue;
     };
 
-    // Expose tag symbols for legacy code
-    static const inline Tag booleanValue = Tag::booleanValue;
-    static const inline Tag byteValue = Tag::byteValue;
-    static const inline Tag charValue = Tag::charValue;
-    static const inline Tag intValue = Tag::intValue;
-    static const inline Tag longValue = Tag::longValue;
-    static const inline Tag floatValue = Tag::floatValue;
-    static const inline Tag doubleValue = Tag::doubleValue;
-    static const inline Tag enumValue = Tag::enumValue;
-
     template <Tag _Tag>
     using _at = typename std::tuple_element<static_cast<size_t>(_Tag), std::tuple<bool, int8_t, char16_t, int32_t, int64_t, float, double, ::aidl::android::aidl::tests::LongEnum>>::type;
     template <Tag _Tag, typename _Type>
@@ -142,7 +130,7 @@
       return os.str();
     }
   private:
-    Tag _tag = booleanValue;
+    Tag _tag __attribute__((aligned (1))) = booleanValue;
     union _value_t {
       _value_t() {}
       ~_value_t() {}
@@ -245,51 +233,3 @@
 }  // namespace aidl
 }  // namespace android
 }  // namespace aidl
-namespace aidl {
-namespace android {
-namespace aidl {
-namespace tests {
-[[nodiscard]] static inline std::string toString(FixedSize::FixedUnion::Tag val) {
-  switch(val) {
-  case FixedSize::FixedUnion::Tag::booleanValue:
-    return "booleanValue";
-  case FixedSize::FixedUnion::Tag::byteValue:
-    return "byteValue";
-  case FixedSize::FixedUnion::Tag::charValue:
-    return "charValue";
-  case FixedSize::FixedUnion::Tag::intValue:
-    return "intValue";
-  case FixedSize::FixedUnion::Tag::longValue:
-    return "longValue";
-  case FixedSize::FixedUnion::Tag::floatValue:
-    return "floatValue";
-  case FixedSize::FixedUnion::Tag::doubleValue:
-    return "doubleValue";
-  case FixedSize::FixedUnion::Tag::enumValue:
-    return "enumValue";
-  default:
-    return std::to_string(static_cast<int8_t>(val));
-  }
-}
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-}  // namespace aidl
-namespace ndk {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<aidl::android::aidl::tests::FixedSize::FixedUnion::Tag, 8> enum_values<aidl::android::aidl::tests::FixedSize::FixedUnion::Tag> = {
-  aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::booleanValue,
-  aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::byteValue,
-  aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::charValue,
-  aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::intValue,
-  aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::longValue,
-  aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::floatValue,
-  aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::doubleValue,
-  aidl::android::aidl::tests::FixedSize::FixedUnion::Tag::enumValue,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
index 2c396b8..dfa1692 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
@@ -20,7 +20,6 @@
 #include <aidl/android/aidl/tests/LongEnum.h>
 #include <aidl/android/aidl/tests/RecursiveList.h>
 #include <aidl/android/aidl/tests/StructuredParcelable.h>
-#include <aidl/android/aidl/tests/Union.h>
 #include <aidl/android/aidl/tests/extension/ExtendableParcelable.h>
 #ifdef BINDER_STABILITY_SUPPORT
 #include <android/binder_stability.h>
@@ -281,9 +280,8 @@
   static constexpr uint32_t TRANSACTION_ReverseNullableIBinderArray = FIRST_CALL_TRANSACTION + 60;
   static constexpr uint32_t TRANSACTION_GetOldNameInterface = FIRST_CALL_TRANSACTION + 61;
   static constexpr uint32_t TRANSACTION_GetNewNameInterface = FIRST_CALL_TRANSACTION + 62;
-  static constexpr uint32_t TRANSACTION_GetUnionTags = FIRST_CALL_TRANSACTION + 63;
-  static constexpr uint32_t TRANSACTION_GetCppJavaTests = FIRST_CALL_TRANSACTION + 64;
-  static constexpr uint32_t TRANSACTION_getBackendType = FIRST_CALL_TRANSACTION + 65;
+  static constexpr uint32_t TRANSACTION_GetCppJavaTests = FIRST_CALL_TRANSACTION + 63;
+  static constexpr uint32_t TRANSACTION_getBackendType = FIRST_CALL_TRANSACTION + 64;
 
   static std::shared_ptr<ITestService> fromBinder(const ::ndk::SpAIBinder& binder);
   static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<ITestService>& instance);
@@ -353,7 +351,6 @@
   virtual ::ndk::ScopedAStatus ReverseNullableIBinderArray(const std::optional<std::vector<::ndk::SpAIBinder>>& in_input, std::optional<std::vector<::ndk::SpAIBinder>>* out_repeated, std::optional<std::vector<::ndk::SpAIBinder>>* _aidl_return) = 0;
   virtual ::ndk::ScopedAStatus GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* _aidl_return) = 0;
   virtual ::ndk::ScopedAStatus GetNewNameInterface(std::shared_ptr<::aidl::android::aidl::tests::INewName>* _aidl_return) = 0;
-  virtual ::ndk::ScopedAStatus GetUnionTags(const std::vector<::aidl::android::aidl::tests::Union>& in_input, std::vector<::aidl::android::aidl::tests::Union::Tag>* _aidl_return) = 0;
   virtual ::ndk::ScopedAStatus GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) = 0;
   virtual ::ndk::ScopedAStatus getBackendType(::aidl::android::aidl::tests::BackendType* _aidl_return) = 0;
 private:
@@ -424,7 +421,6 @@
   ::ndk::ScopedAStatus ReverseNullableIBinderArray(const std::optional<std::vector<::ndk::SpAIBinder>>& in_input, std::optional<std::vector<::ndk::SpAIBinder>>* out_repeated, std::optional<std::vector<::ndk::SpAIBinder>>* _aidl_return) override;
   ::ndk::ScopedAStatus GetOldNameInterface(std::shared_ptr<::aidl::android::aidl::tests::IOldName>* _aidl_return) override;
   ::ndk::ScopedAStatus GetNewNameInterface(std::shared_ptr<::aidl::android::aidl::tests::INewName>* _aidl_return) override;
-  ::ndk::ScopedAStatus GetUnionTags(const std::vector<::aidl::android::aidl::tests::Union>& in_input, std::vector<::aidl::android::aidl::tests::Union::Tag>* _aidl_return) override;
   ::ndk::ScopedAStatus GetCppJavaTests(::ndk::SpAIBinder* _aidl_return) override;
   ::ndk::ScopedAStatus getBackendType(::aidl::android::aidl::tests::BackendType* _aidl_return) override;
   ::ndk::SpAIBinder asBinder() override;
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ListOfInterfaces.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ListOfInterfaces.h
index e0dc968..7c93f75 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ListOfInterfaces.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ListOfInterfaces.h
@@ -1,6 +1,5 @@
 #pragma once
 
-#include <array>
 #include <cassert>
 #include <cstdint>
 #include <memory>
@@ -10,7 +9,6 @@
 #include <utility>
 #include <variant>
 #include <vector>
-#include <android/binder_enums.h>
 #include <android/binder_ibinder.h>
 #include <android/binder_interface_utils.h>
 #include <android/binder_parcelable_utils.h>
@@ -154,19 +152,13 @@
     typedef std::false_type fixed_size;
     static const char* descriptor;
 
-    enum class Tag : int32_t {
-      iface = 0,
-      nullable_iface = 1,
-      iface_list = 2,
-      nullable_iface_list = 3,
+    enum Tag : int32_t {
+      iface = 0,  // android.aidl.tests.ListOfInterfaces.IEmptyInterface iface;
+      nullable_iface,  // android.aidl.tests.ListOfInterfaces.IEmptyInterface nullable_iface;
+      iface_list,  // List<android.aidl.tests.ListOfInterfaces.IEmptyInterface> iface_list;
+      nullable_iface_list,  // List<android.aidl.tests.ListOfInterfaces.IEmptyInterface> nullable_iface_list;
     };
 
-    // Expose tag symbols for legacy code
-    static const inline Tag iface = Tag::iface;
-    static const inline Tag nullable_iface = Tag::nullable_iface;
-    static const inline Tag iface_list = Tag::iface_list;
-    static const inline Tag nullable_iface_list = Tag::nullable_iface_list;
-
     template<typename _Tp>
     static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, MyUnion>;
 
@@ -285,39 +277,3 @@
 }  // namespace aidl
 }  // namespace android
 }  // namespace aidl
-namespace aidl {
-namespace android {
-namespace aidl {
-namespace tests {
-[[nodiscard]] static inline std::string toString(ListOfInterfaces::MyUnion::Tag val) {
-  switch(val) {
-  case ListOfInterfaces::MyUnion::Tag::iface:
-    return "iface";
-  case ListOfInterfaces::MyUnion::Tag::nullable_iface:
-    return "nullable_iface";
-  case ListOfInterfaces::MyUnion::Tag::iface_list:
-    return "iface_list";
-  case ListOfInterfaces::MyUnion::Tag::nullable_iface_list:
-    return "nullable_iface_list";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-}  // namespace aidl
-namespace ndk {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<aidl::android::aidl::tests::ListOfInterfaces::MyUnion::Tag, 4> enum_values<aidl::android::aidl::tests::ListOfInterfaces::MyUnion::Tag> = {
-  aidl::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::iface,
-  aidl::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::nullable_iface,
-  aidl::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::iface_list,
-  aidl::android::aidl::tests::ListOfInterfaces::MyUnion::Tag::nullable_iface_list,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/Union.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/Union.h
index a94d03f..27ee97c 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/Union.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/Union.h
@@ -1,6 +1,5 @@
 #pragma once
 
-#include <array>
 #include <cassert>
 #include <cstdint>
 #include <memory>
@@ -10,7 +9,6 @@
 #include <utility>
 #include <variant>
 #include <vector>
-#include <android/binder_enums.h>
 #include <android/binder_interface_utils.h>
 #include <android/binder_parcelable_utils.h>
 #include <android/binder_to_string.h>
@@ -32,25 +30,16 @@
   typedef std::false_type fixed_size;
   static const char* descriptor;
 
-  enum class Tag : int32_t {
-    ns = 0,
-    n = 1,
-    m = 2,
-    s = 3,
-    ibinder = 4,
-    ss = 5,
-    be = 6,
+  enum Tag : int32_t {
+    ns = 0,  // int[] ns;
+    n,  // int n;
+    m,  // int m;
+    s,  // String s;
+    ibinder,  // IBinder ibinder;
+    ss,  // List<String> ss;
+    be,  // android.aidl.tests.ByteEnum be;
   };
 
-  // Expose tag symbols for legacy code
-  static const inline Tag ns = Tag::ns;
-  static const inline Tag n = Tag::n;
-  static const inline Tag m = Tag::m;
-  static const inline Tag s = Tag::s;
-  static const inline Tag ibinder = Tag::ibinder;
-  static const inline Tag ss = Tag::ss;
-  static const inline Tag be = Tag::be;
-
   template<typename _Tp>
   static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
 
@@ -142,48 +131,3 @@
 }  // namespace aidl
 }  // namespace android
 }  // namespace aidl
-namespace aidl {
-namespace android {
-namespace aidl {
-namespace tests {
-[[nodiscard]] static inline std::string toString(Union::Tag val) {
-  switch(val) {
-  case Union::Tag::ns:
-    return "ns";
-  case Union::Tag::n:
-    return "n";
-  case Union::Tag::m:
-    return "m";
-  case Union::Tag::s:
-    return "s";
-  case Union::Tag::ibinder:
-    return "ibinder";
-  case Union::Tag::ss:
-    return "ss";
-  case Union::Tag::be:
-    return "be";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-}  // namespace aidl
-namespace ndk {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<aidl::android::aidl::tests::Union::Tag, 7> enum_values<aidl::android::aidl::tests::Union::Tag> = {
-  aidl::android::aidl::tests::Union::Tag::ns,
-  aidl::android::aidl::tests::Union::Tag::n,
-  aidl::android::aidl::tests::Union::Tag::m,
-  aidl::android::aidl::tests::Union::Tag::s,
-  aidl::android::aidl::tests::Union::Tag::ibinder,
-  aidl::android::aidl::tests::Union::Tag::ss,
-  aidl::android::aidl::tests::Union::Tag::be,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/UnionWithFd.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/UnionWithFd.h
index 986b542..818ff01 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/UnionWithFd.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/UnionWithFd.h
@@ -1,6 +1,5 @@
 #pragma once
 
-#include <array>
 #include <cassert>
 #include <cstdint>
 #include <memory>
@@ -10,7 +9,6 @@
 #include <utility>
 #include <variant>
 #include <vector>
-#include <android/binder_enums.h>
 #include <android/binder_interface_utils.h>
 #include <android/binder_parcelable_utils.h>
 #include <android/binder_to_string.h>
@@ -31,15 +29,11 @@
   typedef std::false_type fixed_size;
   static const char* descriptor;
 
-  enum class Tag : int32_t {
-    num = 0,
-    pfd = 1,
+  enum Tag : int32_t {
+    num = 0,  // int num;
+    pfd,  // ParcelFileDescriptor pfd;
   };
 
-  // Expose tag symbols for legacy code
-  static const inline Tag num = Tag::num;
-  static const inline Tag pfd = Tag::pfd;
-
   template<typename _Tp>
   static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionWithFd>;
 
@@ -125,33 +119,3 @@
 }  // namespace aidl
 }  // namespace android
 }  // namespace aidl
-namespace aidl {
-namespace android {
-namespace aidl {
-namespace tests {
-[[nodiscard]] static inline std::string toString(UnionWithFd::Tag val) {
-  switch(val) {
-  case UnionWithFd::Tag::num:
-    return "num";
-  case UnionWithFd::Tag::pfd:
-    return "pfd";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-}  // namespace aidl
-namespace ndk {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<aidl::android::aidl::tests::UnionWithFd::Tag, 2> enum_values<aidl::android::aidl::tests::UnionWithFd::Tag> = {
-  aidl::android::aidl::tests::UnionWithFd::Tag::num,
-  aidl::android::aidl::tests::UnionWithFd::Tag::pfd,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/EnumUnion.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/EnumUnion.h
index f52a45e..dc3c3fb 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/EnumUnion.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/EnumUnion.h
@@ -1,6 +1,5 @@
 #pragma once
 
-#include <array>
 #include <cassert>
 #include <cstdint>
 #include <memory>
@@ -10,7 +9,6 @@
 #include <utility>
 #include <variant>
 #include <vector>
-#include <android/binder_enums.h>
 #include <android/binder_interface_utils.h>
 #include <android/binder_parcelable_utils.h>
 #include <android/binder_to_string.h>
@@ -34,15 +32,11 @@
   typedef std::false_type fixed_size;
   static const char* descriptor;
 
-  enum class Tag : int32_t {
-    intEnum = 0,
-    longEnum = 1,
+  enum Tag : int32_t {
+    intEnum = 0,  // android.aidl.tests.IntEnum intEnum;
+    longEnum,  // android.aidl.tests.LongEnum longEnum;
   };
 
-  // Expose tag symbols for legacy code
-  static const inline Tag intEnum = Tag::intEnum;
-  static const inline Tag longEnum = Tag::longEnum;
-
   template<typename _Tp>
   static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, EnumUnion>;
 
@@ -129,35 +123,3 @@
 }  // namespace aidl
 }  // namespace android
 }  // namespace aidl
-namespace aidl {
-namespace android {
-namespace aidl {
-namespace tests {
-namespace unions {
-[[nodiscard]] static inline std::string toString(EnumUnion::Tag val) {
-  switch(val) {
-  case EnumUnion::Tag::intEnum:
-    return "intEnum";
-  case EnumUnion::Tag::longEnum:
-    return "longEnum";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace unions
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-}  // namespace aidl
-namespace ndk {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<aidl::android::aidl::tests::unions::EnumUnion::Tag, 2> enum_values<aidl::android::aidl::tests::unions::EnumUnion::Tag> = {
-  aidl::android::aidl::tests::unions::EnumUnion::Tag::intEnum,
-  aidl::android::aidl::tests::unions::EnumUnion::Tag::longEnum,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/UnionInUnion.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/UnionInUnion.h
index a41dfbb..147a566 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/UnionInUnion.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/unions/UnionInUnion.h
@@ -1,6 +1,5 @@
 #pragma once
 
-#include <array>
 #include <cassert>
 #include <cstdint>
 #include <memory>
@@ -10,7 +9,6 @@
 #include <utility>
 #include <variant>
 #include <vector>
-#include <android/binder_enums.h>
 #include <android/binder_interface_utils.h>
 #include <android/binder_parcelable_utils.h>
 #include <android/binder_to_string.h>
@@ -33,15 +31,11 @@
   typedef std::false_type fixed_size;
   static const char* descriptor;
 
-  enum class Tag : int32_t {
-    first = 0,
-    second = 1,
+  enum Tag : int32_t {
+    first = 0,  // android.aidl.tests.unions.EnumUnion first;
+    second,  // int second;
   };
 
-  // Expose tag symbols for legacy code
-  static const inline Tag first = Tag::first;
-  static const inline Tag second = Tag::second;
-
   template<typename _Tp>
   static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, UnionInUnion>;
 
@@ -128,35 +122,3 @@
 }  // namespace aidl
 }  // namespace android
 }  // namespace aidl
-namespace aidl {
-namespace android {
-namespace aidl {
-namespace tests {
-namespace unions {
-[[nodiscard]] static inline std::string toString(UnionInUnion::Tag val) {
-  switch(val) {
-  case UnionInUnion::Tag::first:
-    return "first";
-  case UnionInUnion::Tag::second:
-    return "second";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace unions
-}  // namespace tests
-}  // namespace aidl
-}  // namespace android
-}  // namespace aidl
-namespace ndk {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<aidl::android::aidl::tests::unions::UnionInUnion::Tag, 2> enum_values<aidl::android::aidl::tests::unions::UnionInUnion::Tag> = {
-  aidl::android::aidl::tests::unions::UnionInUnion::Tag::first,
-  aidl::android::aidl::tests::unions::UnionInUnion::Tag::second,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace ndk
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ArrayOfInterfaces.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ArrayOfInterfaces.rs
index 42b05dc..ee4b1f1 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ArrayOfInterfaces.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ArrayOfInterfaces.rs
@@ -384,18 +384,6 @@
   impl binder::binder_impl::ParcelableMetadata for MyUnion {
     fn get_descriptor() -> &'static str { "android.aidl.tests.ArrayOfInterfaces.MyUnion" }
   }
-  pub mod Tag {
-    #![allow(non_upper_case_globals)]
-    use binder::declare_binder_enum;
-    declare_binder_enum! {
-      Tag : [i32; 4] {
-        iface = 0,
-        nullable_iface = 1,
-        iface_array = 2,
-        nullable_iface_array = 3,
-      }
-    }
-  }
 }
 pub(crate) mod mangled {
  pub use super::ArrayOfInterfaces as _7_android_4_aidl_5_tests_17_ArrayOfInterfaces;
@@ -403,5 +391,4 @@
  pub use super::IMyInterface::IMyInterface as _7_android_4_aidl_5_tests_17_ArrayOfInterfaces_12_IMyInterface;
  pub use super::MyParcelable::MyParcelable as _7_android_4_aidl_5_tests_17_ArrayOfInterfaces_12_MyParcelable;
  pub use super::MyUnion::MyUnion as _7_android_4_aidl_5_tests_17_ArrayOfInterfaces_7_MyUnion;
- pub use super::MyUnion::Tag::Tag as _7_android_4_aidl_5_tests_17_ArrayOfInterfaces_7_MyUnion_3_Tag;
 }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/FixedSize.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/FixedSize.rs
index 2ea4430..ef73f72 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/FixedSize.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/FixedSize.rs
@@ -216,26 +216,9 @@
   impl binder::binder_impl::ParcelableMetadata for FixedUnion {
     fn get_descriptor() -> &'static str { "android.aidl.tests.FixedSize.FixedUnion" }
   }
-  pub mod Tag {
-    #![allow(non_upper_case_globals)]
-    use binder::declare_binder_enum;
-    declare_binder_enum! {
-      Tag : [i8; 8] {
-        booleanValue = 0,
-        byteValue = 1,
-        charValue = 2,
-        intValue = 3,
-        longValue = 4,
-        floatValue = 5,
-        doubleValue = 6,
-        enumValue = 7,
-      }
-    }
-  }
 }
 pub(crate) mod mangled {
  pub use super::FixedSize as _7_android_4_aidl_5_tests_9_FixedSize;
  pub use super::FixedParcelable::FixedParcelable as _7_android_4_aidl_5_tests_9_FixedSize_15_FixedParcelable;
  pub use super::FixedUnion::FixedUnion as _7_android_4_aidl_5_tests_9_FixedSize_10_FixedUnion;
- pub use super::FixedUnion::Tag::Tag as _7_android_4_aidl_5_tests_9_FixedSize_10_FixedUnion_3_Tag;
 }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
index 36c03d4..9e8fd92 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
@@ -78,7 +78,6 @@
   fn ReverseNullableIBinderArray(&self, _arg_input: Option<&[Option<binder::SpIBinder>]>, _arg_repeated: &mut Option<Vec<Option<binder::SpIBinder>>>) -> binder::Result<Option<Vec<Option<binder::SpIBinder>>>>;
   fn GetOldNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>>;
   fn GetNewNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>>;
-  fn GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>>;
   fn GetCppJavaTests(&self) -> binder::Result<Option<binder::SpIBinder>>;
   fn getBackendType(&self) -> binder::Result<crate::mangled::_7_android_4_aidl_5_tests_11_BackendType>;
   fn getDefaultImpl() -> ITestServiceDefaultRef where Self: Sized {
@@ -154,7 +153,6 @@
   fn ReverseNullableIBinderArray<'a>(&'a self, _arg_input: Option<&'a [Option<binder::SpIBinder>]>, _arg_repeated: &'a mut Option<Vec<Option<binder::SpIBinder>>>) -> binder::BoxFuture<'a, binder::Result<Option<Vec<Option<binder::SpIBinder>>>>>;
   fn GetOldNameInterface<'a>(&'a self) -> binder::BoxFuture<'a, binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>>>;
   fn GetNewNameInterface<'a>(&'a self) -> binder::BoxFuture<'a, binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>>>;
-  fn GetUnionTags<'a>(&'a self, _arg_input: &'a [crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::BoxFuture<'a, binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>>>;
   fn GetCppJavaTests<'a>(&'a self) -> binder::BoxFuture<'a, binder::Result<Option<binder::SpIBinder>>>;
   fn getBackendType<'a>(&'a self) -> binder::BoxFuture<'a, binder::Result<crate::mangled::_7_android_4_aidl_5_tests_11_BackendType>>;
 }
@@ -225,7 +223,6 @@
   async fn ReverseNullableIBinderArray(&self, _arg_input: Option<&[Option<binder::SpIBinder>]>, _arg_repeated: &mut Option<Vec<Option<binder::SpIBinder>>>) -> binder::Result<Option<Vec<Option<binder::SpIBinder>>>>;
   async fn GetOldNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>>;
   async fn GetNewNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>>;
-  async fn GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>>;
   async fn GetCppJavaTests(&self) -> binder::Result<Option<binder::SpIBinder>>;
   async fn getBackendType(&self) -> binder::Result<crate::mangled::_7_android_4_aidl_5_tests_11_BackendType>;
 }
@@ -438,9 +435,6 @@
       fn GetNewNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>> {
         self._rt.block_on(self._inner.GetNewNameInterface())
       }
-      fn GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>> {
-        self._rt.block_on(self._inner.GetUnionTags(_arg_input))
-      }
       fn GetCppJavaTests(&self) -> binder::Result<Option<binder::SpIBinder>> {
         self._rt.block_on(self._inner.GetCppJavaTests())
       }
@@ -642,9 +636,6 @@
   fn GetNewNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>> {
     Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
   }
-  fn GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>> {
-    Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
-  }
   fn GetCppJavaTests(&self) -> binder::Result<Option<binder::SpIBinder>> {
     Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
   }
@@ -716,9 +707,8 @@
   pub const ReverseNullableIBinderArray: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 60;
   pub const GetOldNameInterface: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 61;
   pub const GetNewNameInterface: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 62;
-  pub const GetUnionTags: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 63;
-  pub const GetCppJavaTests: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 64;
-  pub const getBackendType: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 65;
+  pub const GetCppJavaTests: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 63;
+  pub const getBackendType: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 64;
 }
 pub type ITestServiceDefaultRef = Option<std::sync::Arc<dyn ITestServiceDefault>>;
 use lazy_static::lazy_static;
@@ -1959,24 +1949,6 @@
     let _aidl_return: binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName> = _aidl_reply.read()?;
     Ok(_aidl_return)
   }
-  fn build_parcel_GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<binder::binder_impl::Parcel> {
-    let mut aidl_data = self.binder.prepare_transact()?;
-    aidl_data.mark_sensitive();
-    aidl_data.write(_arg_input)?;
-    Ok(aidl_data)
-  }
-  fn read_response_GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union], _aidl_reply: std::result::Result<binder::binder_impl::Parcel, binder::StatusCode>) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>> {
-    if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
-      if let Some(_aidl_default_impl) = <Self as ITestService>::getDefaultImpl() {
-        return _aidl_default_impl.GetUnionTags(_arg_input);
-      }
-    }
-    let _aidl_reply = _aidl_reply?;
-    let _aidl_status: binder::Status = _aidl_reply.read()?;
-    if !_aidl_status.is_ok() { return Err(_aidl_status); }
-    let _aidl_return: Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag> = _aidl_reply.read()?;
-    Ok(_aidl_return)
-  }
   fn build_parcel_GetCppJavaTests(&self) -> binder::Result<binder::binder_impl::Parcel> {
     let mut aidl_data = self.binder.prepare_transact()?;
     aidl_data.mark_sensitive();
@@ -2328,11 +2300,6 @@
     let _aidl_reply = self.binder.submit_transact(transactions::GetNewNameInterface, _aidl_data, binder::binder_impl::FLAG_CLEAR_BUF | binder::binder_impl::FLAG_PRIVATE_LOCAL);
     self.read_response_GetNewNameInterface(_aidl_reply)
   }
-  fn GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>> {
-    let _aidl_data = self.build_parcel_GetUnionTags(_arg_input)?;
-    let _aidl_reply = self.binder.submit_transact(transactions::GetUnionTags, _aidl_data, binder::binder_impl::FLAG_CLEAR_BUF | binder::binder_impl::FLAG_PRIVATE_LOCAL);
-    self.read_response_GetUnionTags(_arg_input, _aidl_reply)
-  }
   fn GetCppJavaTests(&self) -> binder::Result<Option<binder::SpIBinder>> {
     let _aidl_data = self.build_parcel_GetCppJavaTests()?;
     let _aidl_reply = self.binder.submit_transact(transactions::GetCppJavaTests, _aidl_data, binder::binder_impl::FLAG_CLEAR_BUF | binder::binder_impl::FLAG_PRIVATE_LOCAL);
@@ -3159,19 +3126,6 @@
       }
     )
   }
-  fn GetUnionTags<'a>(&'a self, _arg_input: &'a [crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::BoxFuture<'a, binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>>> {
-    let _aidl_data = match self.build_parcel_GetUnionTags(_arg_input) {
-      Ok(_aidl_data) => _aidl_data,
-      Err(err) => return Box::pin(std::future::ready(Err(err))),
-    };
-    let binder = self.binder.clone();
-    P::spawn(
-      move || binder.submit_transact(transactions::GetUnionTags, _aidl_data, binder::binder_impl::FLAG_CLEAR_BUF | binder::binder_impl::FLAG_PRIVATE_LOCAL),
-      move |_aidl_reply| async move {
-        self.read_response_GetUnionTags(_arg_input, _aidl_reply)
-      }
-    )
-  }
   fn GetCppJavaTests<'a>(&'a self) -> binder::BoxFuture<'a, binder::Result<Option<binder::SpIBinder>>> {
     let _aidl_data = match self.build_parcel_GetCppJavaTests() {
       Ok(_aidl_data) => _aidl_data,
@@ -3263,7 +3217,6 @@
   fn ReverseNullableIBinderArray(&self, _arg_input: Option<&[Option<binder::SpIBinder>]>, _arg_repeated: &mut Option<Vec<Option<binder::SpIBinder>>>) -> binder::Result<Option<Vec<Option<binder::SpIBinder>>>> { self.0.ReverseNullableIBinderArray(_arg_input, _arg_repeated) }
   fn GetOldNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_IOldName>> { self.0.GetOldNameInterface() }
   fn GetNewNameInterface(&self) -> binder::Result<binder::Strong<dyn crate::mangled::_7_android_4_aidl_5_tests_8_INewName>> { self.0.GetNewNameInterface() }
-  fn GetUnionTags(&self, _arg_input: &[crate::mangled::_7_android_4_aidl_5_tests_5_Union]) -> binder::Result<Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union_3_Tag>> { self.0.GetUnionTags(_arg_input) }
   fn GetCppJavaTests(&self) -> binder::Result<Option<binder::SpIBinder>> { self.0.GetCppJavaTests() }
   fn getBackendType(&self) -> binder::Result<crate::mangled::_7_android_4_aidl_5_tests_11_BackendType> { self.0.getBackendType() }
 }
@@ -4066,18 +4019,6 @@
       }
       Ok(())
     }
-    transactions::GetUnionTags => {
-      let _arg_input: Vec<crate::mangled::_7_android_4_aidl_5_tests_5_Union> = _aidl_data.read()?;
-      let _aidl_return = _aidl_service.GetUnionTags(&_arg_input);
-      match &_aidl_return {
-        Ok(_aidl_return) => {
-          _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
-          _aidl_reply.write(_aidl_return)?;
-        }
-        Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
-      }
-      Ok(())
-    }
     transactions::GetCppJavaTests => {
       let _aidl_return = _aidl_service.GetCppJavaTests();
       match &_aidl_return {
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs.d b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs.d
index 9786dc1..3f2111f 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs.d
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs.d
@@ -9,6 +9,6 @@
   system/tools/aidl/tests/android/aidl/tests/LongEnum.aidl \
   system/tools/aidl/tests/android/aidl/tests/RecursiveList.aidl \
   system/tools/aidl/tests/android/aidl/tests/StructuredParcelable.aidl \
-  system/tools/aidl/tests/android/aidl/tests/Union.aidl \
   system/tools/aidl/tests/android/aidl/tests/extension/ExtendableParcelable.aidl \
-  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl
+  system/tools/aidl/tests/android/aidl/tests/ConstantExpressionEnum.aidl \
+  system/tools/aidl/tests/android/aidl/tests/Union.aidl
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ListOfInterfaces.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ListOfInterfaces.rs
index 4f5d5c6..274006e 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ListOfInterfaces.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ListOfInterfaces.rs
@@ -380,18 +380,6 @@
   impl binder::binder_impl::ParcelableMetadata for MyUnion {
     fn get_descriptor() -> &'static str { "android.aidl.tests.ListOfInterfaces.MyUnion" }
   }
-  pub mod Tag {
-    #![allow(non_upper_case_globals)]
-    use binder::declare_binder_enum;
-    declare_binder_enum! {
-      Tag : [i32; 4] {
-        iface = 0,
-        nullable_iface = 1,
-        iface_list = 2,
-        nullable_iface_list = 3,
-      }
-    }
-  }
 }
 pub(crate) mod mangled {
  pub use super::ListOfInterfaces as _7_android_4_aidl_5_tests_16_ListOfInterfaces;
@@ -399,5 +387,4 @@
  pub use super::IMyInterface::IMyInterface as _7_android_4_aidl_5_tests_16_ListOfInterfaces_12_IMyInterface;
  pub use super::MyParcelable::MyParcelable as _7_android_4_aidl_5_tests_16_ListOfInterfaces_12_MyParcelable;
  pub use super::MyUnion::MyUnion as _7_android_4_aidl_5_tests_16_ListOfInterfaces_7_MyUnion;
- pub use super::MyUnion::Tag::Tag as _7_android_4_aidl_5_tests_16_ListOfInterfaces_7_MyUnion_3_Tag;
 }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs
index a2f9295..44f1f78 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/Union.rs
@@ -98,22 +98,6 @@
 impl binder::binder_impl::ParcelableMetadata for Union {
   fn get_descriptor() -> &'static str { "android.aidl.tests.Union" }
 }
-pub mod Tag {
-  #![allow(non_upper_case_globals)]
-  use binder::declare_binder_enum;
-  declare_binder_enum! {
-    Tag : [i32; 7] {
-      ns = 0,
-      n = 1,
-      m = 2,
-      s = 3,
-      ibinder = 4,
-      ss = 5,
-      be = 6,
-    }
-  }
-}
 pub(crate) mod mangled {
  pub use super::Union as _7_android_4_aidl_5_tests_5_Union;
- pub use super::Tag::Tag as _7_android_4_aidl_5_tests_5_Union_3_Tag;
 }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs
index 49f9f16..29af5a3 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/UnionWithFd.rs
@@ -48,17 +48,6 @@
 impl binder::binder_impl::ParcelableMetadata for UnionWithFd {
   fn get_descriptor() -> &'static str { "android.aidl.tests.UnionWithFd" }
 }
-pub mod Tag {
-  #![allow(non_upper_case_globals)]
-  use binder::declare_binder_enum;
-  declare_binder_enum! {
-    Tag : [i32; 2] {
-      num = 0,
-      pfd = 1,
-    }
-  }
-}
 pub(crate) mod mangled {
  pub use super::UnionWithFd as _7_android_4_aidl_5_tests_11_UnionWithFd;
- pub use super::Tag::Tag as _7_android_4_aidl_5_tests_11_UnionWithFd_3_Tag;
 }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs
index 4d5fe95..bf142f7 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/EnumUnion.rs
@@ -47,17 +47,6 @@
 impl binder::binder_impl::ParcelableMetadata for EnumUnion {
   fn get_descriptor() -> &'static str { "android.aidl.tests.unions.EnumUnion" }
 }
-pub mod Tag {
-  #![allow(non_upper_case_globals)]
-  use binder::declare_binder_enum;
-  declare_binder_enum! {
-    Tag : [i32; 2] {
-      intEnum = 0,
-      longEnum = 1,
-    }
-  }
-}
 pub(crate) mod mangled {
  pub use super::EnumUnion as _7_android_4_aidl_5_tests_6_unions_9_EnumUnion;
- pub use super::Tag::Tag as _7_android_4_aidl_5_tests_6_unions_9_EnumUnion_3_Tag;
 }
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs
index 511f44c..fd2d68d 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/unions/UnionInUnion.rs
@@ -47,17 +47,6 @@
 impl binder::binder_impl::ParcelableMetadata for UnionInUnion {
   fn get_descriptor() -> &'static str { "android.aidl.tests.unions.UnionInUnion" }
 }
-pub mod Tag {
-  #![allow(non_upper_case_globals)]
-  use binder::declare_binder_enum;
-  declare_binder_enum! {
-    Tag : [i32; 2] {
-      first = 0,
-      second = 1,
-    }
-  }
-}
 pub(crate) mod mangled {
  pub use super::UnionInUnion as _7_android_4_aidl_5_tests_6_unions_12_UnionInUnion;
- pub use super::Tag::Tag as _7_android_4_aidl_5_tests_6_unions_12_UnionInUnion_3_Tag;
 }
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-cpp-source/gen/include/android/aidl/versioned/tests/BazUnion.h b/tests/golden_output/aidl-test-versioned-interface-V1-cpp-source/gen/include/android/aidl/versioned/tests/BazUnion.h
index 25e0d16..c8ba05b 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-cpp-source/gen/include/android/aidl/versioned/tests/BazUnion.h
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-cpp-source/gen/include/android/aidl/versioned/tests/BazUnion.h
@@ -1,13 +1,10 @@
 #pragma once
 
 #include <android/binder_to_string.h>
-#include <array>
-#include <binder/Enums.h>
 #include <binder/Parcel.h>
 #include <binder/Status.h>
 #include <cassert>
 #include <cstdint>
-#include <string>
 #include <type_traits>
 #include <utility>
 #include <utils/String16.h>
@@ -23,11 +20,9 @@
 namespace tests {
 class BazUnion : public ::android::Parcelable {
 public:
-  enum class Tag : int32_t {
-    intNum = 0,
+  enum Tag : int32_t {
+    intNum = 0,  // int intNum;
   };
-  // Expose tag symbols for legacy code
-  static const inline Tag intNum = Tag::intNum;
 
   template<typename _Tp>
   static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, BazUnion>;
@@ -115,30 +110,3 @@
 }  // namespace versioned
 }  // namespace aidl
 }  // namespace android
-namespace android {
-namespace aidl {
-namespace versioned {
-namespace tests {
-[[nodiscard]] static inline std::string toString(BazUnion::Tag val) {
-  switch(val) {
-  case BazUnion::Tag::intNum:
-    return "intNum";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace tests
-}  // namespace versioned
-}  // namespace aidl
-}  // namespace android
-namespace android {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<::android::aidl::versioned::tests::BazUnion::Tag, 1> enum_values<::android::aidl::versioned::tests::BazUnion::Tag> = {
-  ::android::aidl::versioned::tests::BazUnion::Tag::intNum,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace android
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-java-source/gen/android/aidl/versioned/tests/BazUnion.java b/tests/golden_output/aidl-test-versioned-interface-V1-java-source/gen/android/aidl/versioned/tests/BazUnion.java
index 3f0e3d7..29da9c2 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-java-source/gen/android/aidl/versioned/tests/BazUnion.java
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-java-source/gen/android/aidl/versioned/tests/BazUnion.java
@@ -102,7 +102,4 @@
     this._tag = _tag;
     this._value = _value;
   }
-  public static @interface Tag {
-    public static final int intNum = 0;
-  }
 }
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-ndk-source/gen/include/aidl/android/aidl/versioned/tests/BazUnion.h b/tests/golden_output/aidl-test-versioned-interface-V1-ndk-source/gen/include/aidl/android/aidl/versioned/tests/BazUnion.h
index 9218a0b..24a8014 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-ndk-source/gen/include/aidl/android/aidl/versioned/tests/BazUnion.h
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-ndk-source/gen/include/aidl/android/aidl/versioned/tests/BazUnion.h
@@ -1,6 +1,5 @@
 #pragma once
 
-#include <array>
 #include <cassert>
 #include <cstdint>
 #include <memory>
@@ -10,7 +9,6 @@
 #include <utility>
 #include <variant>
 #include <vector>
-#include <android/binder_enums.h>
 #include <android/binder_interface_utils.h>
 #include <android/binder_parcelable_utils.h>
 #include <android/binder_to_string.h>
@@ -32,13 +30,10 @@
   typedef std::false_type fixed_size;
   static const char* descriptor;
 
-  enum class Tag : int32_t {
-    intNum = 0,
+  enum Tag : int32_t {
+    intNum = 0,  // int intNum;
   };
 
-  // Expose tag symbols for legacy code
-  static const inline Tag intNum = Tag::intNum;
-
   template<typename _Tp>
   static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, BazUnion>;
 
@@ -124,32 +119,3 @@
 }  // namespace aidl
 }  // namespace android
 }  // namespace aidl
-namespace aidl {
-namespace android {
-namespace aidl {
-namespace versioned {
-namespace tests {
-[[nodiscard]] static inline std::string toString(BazUnion::Tag val) {
-  switch(val) {
-  case BazUnion::Tag::intNum:
-    return "intNum";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace tests
-}  // namespace versioned
-}  // namespace aidl
-}  // namespace android
-}  // namespace aidl
-namespace ndk {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<aidl::android::aidl::versioned::tests::BazUnion::Tag, 1> enum_values<aidl::android::aidl::versioned::tests::BazUnion::Tag> = {
-  aidl::android::aidl::versioned::tests::BazUnion::Tag::intNum,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace ndk
diff --git a/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/BazUnion.rs b/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/BazUnion.rs
index b60ff88..5e30930 100644
--- a/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/BazUnion.rs
+++ b/tests/golden_output/aidl-test-versioned-interface-V1-rust-source/gen/android/aidl/versioned/tests/BazUnion.rs
@@ -37,16 +37,6 @@
 impl binder::binder_impl::ParcelableMetadata for BazUnion {
   fn get_descriptor() -> &'static str { "android.aidl.versioned.tests.BazUnion" }
 }
-pub mod Tag {
-  #![allow(non_upper_case_globals)]
-  use binder::declare_binder_enum;
-  declare_binder_enum! {
-    Tag : [i32; 1] {
-      intNum = 0,
-    }
-  }
-}
 pub(crate) mod mangled {
  pub use super::BazUnion as _7_android_4_aidl_9_versioned_5_tests_8_BazUnion;
- pub use super::Tag::Tag as _7_android_4_aidl_9_versioned_5_tests_8_BazUnion_3_Tag;
 }
diff --git a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Union.h b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Union.h
index 9b67e56..fbaf018 100644
--- a/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Union.h
+++ b/tests/golden_output/aidl_test_loggable_interface-cpp-source/gen/include/android/aidl/loggable/Union.h
@@ -1,8 +1,6 @@
 #pragma once
 
 #include <android/binder_to_string.h>
-#include <array>
-#include <binder/Enums.h>
 #include <binder/Parcel.h>
 #include <binder/Status.h>
 #include <cassert>
@@ -22,13 +20,10 @@
 namespace loggable {
 class Union : public ::android::Parcelable {
 public:
-  enum class Tag : int32_t {
-    num = 0,
-    str = 1,
+  enum Tag : int32_t {
+    num = 0,  // int num;
+    str,  // String str;
   };
-  // Expose tag symbols for legacy code
-  static const inline Tag num = Tag::num;
-  static const inline Tag str = Tag::str;
 
   template<typename _Tp>
   static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
@@ -116,31 +111,3 @@
 }  // namespace loggable
 }  // namespace aidl
 }  // namespace android
-namespace android {
-namespace aidl {
-namespace loggable {
-[[nodiscard]] static inline std::string toString(Union::Tag val) {
-  switch(val) {
-  case Union::Tag::num:
-    return "num";
-  case Union::Tag::str:
-    return "str";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace loggable
-}  // namespace aidl
-}  // namespace android
-namespace android {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<::android::aidl::loggable::Union::Tag, 2> enum_values<::android::aidl::loggable::Union::Tag> = {
-  ::android::aidl::loggable::Union::Tag::num,
-  ::android::aidl::loggable::Union::Tag::str,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace android
diff --git a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Union.java b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Union.java
index f85770f..1751db3 100644
--- a/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Union.java
+++ b/tests/golden_output/aidl_test_loggable_interface-java-source/gen/android/aidl/loggable/Union.java
@@ -127,8 +127,4 @@
     this._tag = _tag;
     this._value = _value;
   }
-  public static @interface Tag {
-    public static final int num = 0;
-    public static final int str = 1;
-  }
 }
diff --git a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Union.h b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Union.h
index ef0532f..2969134 100644
--- a/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Union.h
+++ b/tests/golden_output/aidl_test_loggable_interface-ndk-source/gen/include/aidl/android/aidl/loggable/Union.h
@@ -1,6 +1,5 @@
 #pragma once
 
-#include <array>
 #include <cassert>
 #include <cstdint>
 #include <memory>
@@ -10,7 +9,6 @@
 #include <utility>
 #include <variant>
 #include <vector>
-#include <android/binder_enums.h>
 #include <android/binder_interface_utils.h>
 #include <android/binder_parcelable_utils.h>
 #include <android/binder_to_string.h>
@@ -31,15 +29,11 @@
   typedef std::false_type fixed_size;
   static const char* descriptor;
 
-  enum class Tag : int32_t {
-    num = 0,
-    str = 1,
+  enum Tag : int32_t {
+    num = 0,  // int num;
+    str,  // String str;
   };
 
-  // Expose tag symbols for legacy code
-  static const inline Tag num = Tag::num;
-  static const inline Tag str = Tag::str;
-
   template<typename _Tp>
   static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Union>;
 
@@ -125,33 +119,3 @@
 }  // namespace aidl
 }  // namespace android
 }  // namespace aidl
-namespace aidl {
-namespace android {
-namespace aidl {
-namespace loggable {
-[[nodiscard]] static inline std::string toString(Union::Tag val) {
-  switch(val) {
-  case Union::Tag::num:
-    return "num";
-  case Union::Tag::str:
-    return "str";
-  default:
-    return std::to_string(static_cast<int32_t>(val));
-  }
-}
-}  // namespace loggable
-}  // namespace aidl
-}  // namespace android
-}  // namespace aidl
-namespace ndk {
-namespace internal {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++17-extensions"
-template <>
-constexpr inline std::array<aidl::android::aidl::loggable::Union::Tag, 2> enum_values<aidl::android::aidl::loggable::Union::Tag> = {
-  aidl::android::aidl::loggable::Union::Tag::num,
-  aidl::android::aidl::loggable::Union::Tag::str,
-};
-#pragma clang diagnostic pop
-}  // namespace internal
-}  // namespace ndk
diff --git a/tests/java/src/android/aidl/service/TestServiceServer.java b/tests/java/src/android/aidl/service/TestServiceServer.java
index 51a7520..ad98416 100644
--- a/tests/java/src/android/aidl/service/TestServiceServer.java
+++ b/tests/java/src/android/aidl/service/TestServiceServer.java
@@ -592,15 +592,6 @@
     return new MyNewName();
   }
 
-  @Override
-  public int[] GetUnionTags(Union[] input) throws RemoteException {
-    int[] tags = new int[input.length];
-    for (int i = 0; i < input.length; i++) {
-      tags[i] = input[i].getTag();
-    }
-    return tags;
-  }
-
   class MyCppJavaTests extends ICppJavaTests.Stub {
     @Override
     public BadParcelable RepeatBadParcelable(BadParcelable input) throws RemoteException {
diff --git a/tests/java/src/android/aidl/tests/TestServiceClient.java b/tests/java/src/android/aidl/tests/TestServiceClient.java
index 6dfacc9..e9140cc 100644
--- a/tests/java/src/android/aidl/tests/TestServiceClient.java
+++ b/tests/java/src/android/aidl/tests/TestServiceClient.java
@@ -956,13 +956,6 @@
     }
 
     @Test
-    public void testGetUnionTags() throws RemoteException {
-      assertArrayEquals(new int[] {}, service.GetUnionTags(new Union[] {}));
-      assertArrayEquals(new int[] {Union.n, Union.ns},
-          service.GetUnionTags(new Union[] {Union.n(0), Union.ns(new int[] {})}));
-    }
-
-    @Test
     public void testDescribeContents() throws Exception {
       CompilerChecks cc = new CompilerChecks();
       cc.pfd_array = new ParcelFileDescriptor[] {null, null, null};
diff --git a/tests/rust/test_client.rs b/tests/rust/test_client.rs
index 81315c9..35c3af3 100644
--- a/tests/rust/test_client.rs
+++ b/tests/rust/test_client.rs
@@ -822,15 +822,6 @@
 }
 
 #[test]
-fn test_get_union_tags() {
-    let service = get_test_service();
-    let result = service.GetUnionTags(&[]);
-    assert_eq!(result, Ok(vec![]));
-    let result = service.GetUnionTags(&[Union::Union::N(0), Union::Union::Ns(vec![])]);
-    assert_eq!(result, Ok(vec![Union::Tag::Tag::n, Union::Tag::Tag::ns]));
-}
-
-#[test]
 fn test_unions() {
     assert_eq!(Union::Union::default(), Union::Union::Ns(vec![]));
     assert_eq!(EnumUnion::default(), EnumUnion::IntEnum(IntEnum::FOO));
diff --git a/tests/rust/test_service.rs b/tests/rust/test_service.rs
index 3a5c09c..1d3c092 100644
--- a/tests/rust/test_service.rs
+++ b/tests/rust/test_service.rs
@@ -441,21 +441,6 @@
         Ok(INewName::BnNewName::new_binder(NewName, BinderFeatures::default()))
     }
 
-    fn GetUnionTags(&self, input: &[Union::Union]) -> binder::Result<Vec<Union::Tag::Tag>> {
-        Ok(input
-            .iter()
-            .map(|u| match u {
-                Union::Union::Ns(_) => Union::Tag::Tag::ns,
-                Union::Union::N(_) => Union::Tag::Tag::n,
-                Union::Union::M(_) => Union::Tag::Tag::m,
-                Union::Union::S(_) => Union::Tag::Tag::s,
-                Union::Union::Ibinder(_) => Union::Tag::Tag::ibinder,
-                Union::Union::Ss(_) => Union::Tag::Tag::ss,
-                Union::Union::Be(_) => Union::Tag::Tag::be,
-            })
-            .collect::<Vec<_>>())
-    }
-
     fn GetCppJavaTests(&self) -> binder::Result<Option<SpIBinder>> {
         Ok(None)
     }
diff --git a/tests/rust/test_service_async.rs b/tests/rust/test_service_async.rs
index cfc0f28..f6cd039 100644
--- a/tests/rust/test_service_async.rs
+++ b/tests/rust/test_service_async.rs
@@ -483,21 +483,6 @@
         Ok(INewName::BnNewName::new_async_binder(NewName, rt(), BinderFeatures::default()))
     }
 
-    async fn GetUnionTags(&self, input: &[Union::Union]) -> binder::Result<Vec<Union::Tag::Tag>> {
-        Ok(input
-            .iter()
-            .map(|u| match u {
-                Union::Union::Ns(_) => Union::Tag::Tag::ns,
-                Union::Union::N(_) => Union::Tag::Tag::n,
-                Union::Union::M(_) => Union::Tag::Tag::m,
-                Union::Union::S(_) => Union::Tag::Tag::s,
-                Union::Union::Ibinder(_) => Union::Tag::Tag::ibinder,
-                Union::Union::Ss(_) => Union::Tag::Tag::ss,
-                Union::Union::Be(_) => Union::Tag::Tag::be,
-            })
-            .collect::<Vec<_>>())
-    }
-
     async fn GetCppJavaTests(&self) -> binder::Result<Option<SpIBinder>> {
         Ok(None)
     }