nested types: Reject unstructured parcelable
Having unstructured parcelables as nested types doesn't make sense
because they are defined somewhere else in native languages (e.g. C++,
Java...).
Bug: 182508839
Test: aidl_unittests
Change-Id: I4a6cd76ac58fc246db77c7e62d16403eabf90dda
diff --git a/aidl_language.cpp b/aidl_language.cpp
index b1c4a12..71c79fb 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -1035,6 +1035,13 @@
AIDL_ERROR(t) << "Nested type '" << GetName() << "' has the same name as its parent.";
success = false;
}
+ // Having unstructured parcelables as nested types doesn't make sense because they are defined
+ // somewhere else in native languages (e.g. C++, Java...).
+ if (AidlCast<AidlParcelable>(*t)) {
+ AIDL_ERROR(t) << "'" << t->GetName()
+ << "' is nested. Unstructured parcelables should be at the root scope.";
+ return false;
+ }
// For now we don't allow "interface" to be nested
if (AidlCast<AidlInterface>(*t)) {
AIDL_ERROR(t) << "'" << t->GetName()