Clean up LanguageSpecificCheckValid
- removed redundant checks: (Recursive calls, List<interface>)
- moved a check to CheckValid: (interface[])
Bug: n/a
Test: aidl_unittests
Change-Id: Id72ba2f16861ab6919421180e470e791724997c7
diff --git a/aidl_language.cpp b/aidl_language.cpp
index da62629..3b54a27 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -684,8 +684,9 @@
AIDL_ERROR(this) << "Binder type cannot be an array";
return false;
}
- if (GetName() == "ParcelableHolder") {
- AIDL_ERROR(this) << "Arrays of ParcelableHolder are not supported.";
+ if (GetName() == "ParcelableHolder" || GetName() == "List" || GetName() == "Map" ||
+ GetName() == "CharSequence") {
+ AIDL_ERROR(this) << "Arrays of " << GetName() << " are not supported.";
return false;
}
}
@@ -1286,15 +1287,6 @@
// TODO: we should treat every backend all the same in future.
bool AidlTypeSpecifier::LanguageSpecificCheckValid(const AidlTypenames& typenames,
Options::Language lang) const {
- if (IsGeneric()) {
- const auto& types = GetTypeParameters();
- for (const auto& arg : types) {
- if (!arg->LanguageSpecificCheckValid(typenames, lang)) {
- return false;
- }
- }
- }
-
if ((lang == Options::Language::NDK || lang == Options::Language::RUST) && IsArray() &&
IsNullable()) {
if (GetName() == "ParcelFileDescriptor") {
@@ -1310,6 +1302,7 @@
return false;
}
}
+
if (this->GetName() == "FileDescriptor" &&
(lang == Options::Language::NDK || lang == Options::Language::RUST)) {
AIDL_ERROR(this) << "FileDescriptor isn't supported by the " << to_string(lang) << " backend.";
@@ -1320,11 +1313,6 @@
if (lang == Options::Language::NDK) {
const AidlTypeSpecifier& contained_type = *GetTypeParameters()[0];
const string& contained_type_name = contained_type.GetName();
- if (typenames.GetInterface(contained_type)) {
- AIDL_ERROR(this) << "List<" << contained_type_name
- << "> is not supported. List in NDK doesn't support interface.";
- return false;
- }
if (contained_type_name == "IBinder") {
AIDL_ERROR(this) << "List<" << contained_type_name
<< "> is not supported. List in NDK doesn't support IBinder.";
@@ -1334,14 +1322,6 @@
}
}
- if (this->IsArray()) {
- if (this->GetName() == "List" || this->GetName() == "Map" ||
- this->GetName() == "CharSequence") {
- AIDL_ERROR(this) << this->GetName() << "[] is not supported.";
- return false;
- }
- }
-
if (lang != Options::Language::JAVA) {
if (this->GetName() == "List" && !this->IsGeneric()) {
AIDL_ERROR(this) << "Currently, only the Java backend supports non-generic List.";