Merge "check-flagged-apis: make interfaces inherit from java/lang/Object" into main

This commit is contained in:
Treehugger Robot
2024-05-22 14:18:48 +00:00
committed by Gerrit Code Review
2 changed files with 25 additions and 1 deletions

View File

@@ -120,6 +120,26 @@ class CheckFlaggedApisTest {
assertEquals(expected, actual)
}
@Test
fun testParseApiSignatureInterfacesInheritFromJavaLangObject() {
val apiSignature =
"""
// Signature format: 2.0
package android {
@FlaggedApi("android.flag.foo") public interface Interface {
}
}
"""
.trim()
val expected =
setOf(
Pair(
Symbol.createClass("android/Interface", "java/lang/Object", setOf()),
Flag("android.flag.foo")))
val actual = parseApiSignature("in-memory", apiSignature.byteInputStream())
assertEquals(expected, actual)
}
@Test
fun testParseFlagValues() {
val expected: Map<Flag, Boolean> =

View File

@@ -205,7 +205,11 @@ internal fun parseApiSignature(path: String, input: InputStream): Set<Pair<Symbo
val symbol =
Symbol.createClass(
cls.baselineElementId(),
cls.superClass()?.baselineElementId(),
if (cls.isInterface()) {
"java/lang/Object"
} else {
cls.superClass()?.baselineElementId()
},
cls.allInterfaces()
.map { it.baselineElementId() }
.filter { it != cls.baselineElementId() }