aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-05-07 14:18:20 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-05-07 14:18:20 +0000
commit64dac049a61ed842e56b3b8f09ad624fc305accb (patch)
tree4cfe94ce36ecb260cf927b6c70a90eeb8e941a67
parent260663ddfc5e02cf162addf469322816708e98e7 (diff)
parente8120390369affabf89569e560de2754ea016e2d (diff)
downloadbuild-64dac049a61ed842e56b3b8f09ad624fc305accb.tar.gz
Merge "check-flagged-apis: consider superclasses when looking up symbol" into main
-rw-r--r--tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt49
-rw-r--r--tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt5
2 files changed, 54 insertions, 0 deletions
diff --git a/tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt b/tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt
index 773f4339f0..cd859448b0 100644
--- a/tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt
+++ b/tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt
@@ -221,6 +221,55 @@ class CheckFlaggedApisTest {
}
@Test
+ fun testFindErrorsVerifySuperclass() {
+ val apiSignature =
+ """
+ // Signature format: 2.0
+ package android {
+ @FlaggedApi("android.flag.foo") public final class C extends android.B {
+ method @FlaggedApi("android.flag.foo") public boolean c();
+ method @FlaggedApi("android.flag.foo") public boolean b();
+ method @FlaggedApi("android.flag.foo") public boolean a();
+ }
+ public final class B extends android.A {
+ method public boolean b();
+ }
+ public final class A {
+ method public boolean a();
+ }
+ }
+ """
+ .trim()
+
+ val apiVersions =
+ """
+ <?xml version="1.0" encoding="utf-8"?>
+ <api version="3">
+ <class name="android/C" since="1">
+ <extends name="android/B"/>
+ <method name="c()Z"/>
+ </class>
+ <class name="android/B" since="1">
+ <extends name="android/A"/>
+ <method name="b()Z"/>
+ </class>
+ <class name="android/A" since="1">
+ <method name="a()Z"/>
+ </class>
+ </api>
+ """
+ .trim()
+
+ val expected = setOf<ApiError>()
+ val actual =
+ findErrors(
+ parseApiSignature("in-memory", apiSignature.byteInputStream()),
+ parseFlagValues(generateFlagsProto(ENABLED, ENABLED)),
+ parseApiVersions(apiVersions.byteInputStream()))
+ assertEquals(expected, actual)
+ }
+
+ @Test
fun testFindErrorsDisabledFlaggedApiIsPresent() {
val expected =
setOf<ApiError>(
diff --git a/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt b/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt
index dc0d31c375..b514048bd6 100644
--- a/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt
+++ b/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt
@@ -378,6 +378,11 @@ internal fun findErrors(
}
}
+ if (clazz.superclass != null) {
+ val superclassSymbol = Symbol.createMethod(clazz.superclass, memberName)
+ return containsSymbol(superclassSymbol)
+ }
+
return false
}
val errors = mutableSetOf<ApiError>()