New IC: Detect changes to class annotations

Both the new and old incremental compilation (IC) analysis rely on
Kotlin class metadata to detect a change.

However, Kotlin metadata currently doesn't contain info about
annotations (KT-57919), so the IC will not be able to detect a change
to them.

With this commit, we'll fix the new IC such that it can detect a change
to class annotations by not relying only on metadata.

We currently scope this fix to the new IC (cross-module analysis) first.
We'll fix this issue for within-module analysis later.

Performance: There seems to be no performance impact from this change.
Snapshotting the 400MB ideaIC-2022.1.4/app.jar takes 4.1s before and
after this change.

Test: Added ClasspathChangesComputerTest.testChangedAnnotations
^KT-58289: Fixed
This commit is contained in:
Hung Nguyen
2023-04-26 14:47:57 +01:00
committed by Space Team
parent 993925f656
commit 0b09be73c6
22 changed files with 316 additions and 231 deletions
@@ -259,6 +259,9 @@ class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
/** Regression test for KT-55021. */
@Test
fun testRenameFileFacade() {
// Check that classpath changes computation doesn't fail.
// Ideally, the returned changes should be empty (renaming a file facade alone shouldn't cause any `LookupSymbol`s to change), but
// it is currently not the case. However, this is just a small efficiency, not a serious bug.
val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testRenameFileFacade/src"), tmpDir)
Changes(
lookupSymbols = setOf(
@@ -269,6 +272,20 @@ class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() {
).assertEquals(changes)
}
/** Regression test for KT-58289.*/
@Test
fun testChangedAnnotations() {
val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testChangedAnnotations/src"), tmpDir)
Changes(
lookupSymbols = setOf(
LookupSymbol(name = "SomeClassWithChangedAnnotation", scope = "com.example"),
),
fqNames = setOf(
"com.example.SomeClassWithChangedAnnotation",
)
).assertEquals(changes)
}
/** Tests [SupertypesInheritorsImpact]. */
@Test
override fun testImpactComputation_SupertypesInheritors() {