Refactor: type resolution done in Scope
Type resolution should be based on "scope". Previously, the compiler
didn't consider its scope and just look it up in the known types. This
caused unnessary complication regarding "preprocessed types" such as
"prefer import over preprocssed".
Now "name resolution" is done in its scope and AidlTypenames don't have
to guess what type it is. (It just looks up fully-qualified names.)
For legacy reasons, preprocessed unstructured parcelable types can still
be resolved with unqualified names.
Bug: 182508839
Test: aidl_unittests
Change-Id: I65b6e2e01bd354b3f0a4027d039a8ef3679ebe6f
diff --git a/aidl_to_ndk.cpp b/aidl_to_ndk.cpp
index 9d1b794..b3ab6d6 100644
--- a/aidl_to_ndk.cpp
+++ b/aidl_to_ndk.cpp
@@ -364,9 +364,9 @@
AIDL_FATAL_IF(type_param->IsGeneric(), aidl) << "AIDL doesn't support nested type parameter";
AidlTypeSpecifier array_type =
- AidlTypeSpecifier(AIDL_LOCATION_HERE, type_param->GetUnresolvedName(), true /* isArray */,
+ AidlTypeSpecifier(AIDL_LOCATION_HERE, type_param->GetName(), true /* isArray */,
nullptr /* type_params */, aidl.GetComments());
- if (!(array_type.Resolve(types) && array_type.CheckValid(types))) {
+ if (!(array_type.Resolve(types, nullptr) && array_type.CheckValid(types))) {
AIDL_FATAL(aidl) << "The type parameter is wrong.";
}
return GetTypeAspect(types, array_type);