BackingType copies location from Backing annotation
When enum's backing type is set via @Backing annotation, the resulting
AidlTypeSpecifier for the backing type should have the same location of
the annotation.
Check_api reports errors using AIDL_ERROR() which aborts with internal
loation. But @Backing annotation comes from external.
Bug: n/a
Test: aidl_unittests
Change-Id: I966c3119123dcef075ea530f73e499c80b3f7cf1
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index fa86626..ef134fb 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -2308,6 +2308,27 @@
EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
+TEST_F(AidlTestIncompatibleChanges, ChangedBackingTypeOfEnum) {
+ const string expected_stderr =
+ "ERROR: new/p/Foo.aidl:1.11-32: Type changed: byte to long.\n"
+ "ERROR: new/p/Foo.aidl:1.36-40: Changed backing types.\n";
+ io_delegate_.SetFileContents("old/p/Foo.aidl",
+ "package p;"
+ "@Backing(type=\"byte\")"
+ "enum Foo {"
+ " FOO, BAR,"
+ "}");
+ io_delegate_.SetFileContents("new/p/Foo.aidl",
+ "package p;"
+ "@Backing(type=\"long\")"
+ "enum Foo {"
+ " FOO, BAR,"
+ "}");
+ CaptureStderr();
+ EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+}
+
TEST_F(AidlTestIncompatibleChanges, AddedParcelableAnnotation) {
const string expected_stderr =
"ERROR: new/p/Foo.aidl:1.47-51: Changed annotations: (empty) to @JavaOnlyStableParcelable\n";