diff --git a/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest.kt b/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest.kt index e5c28d32538..d7efbb3ea8f 100644 --- a/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest.kt +++ b/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest.kt @@ -131,29 +131,6 @@ class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() { ).assertEquals(changes) } - @Test - override fun testImpactComputation_SupertypesInheritors() { - val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testImpactComputation_SupertypesInheritors/src"), tmpDir) - Changes( - lookupSymbols = setOf( - LookupSymbol(name = "changedProperty", scope = "com.example.ChangedSuperClass"), - LookupSymbol(name = "changedProperty", scope = "com.example.SubClassOfChangedSuperClass"), - LookupSymbol(name = "changedProperty", scope = "com.example.SubSubClassOfChangedSuperClass"), - LookupSymbol(name = "changedFunction", scope = "com.example.ChangedSuperClass"), - LookupSymbol(name = "changedFunction", scope = "com.example.SubClassOfChangedSuperClass"), - LookupSymbol(name = "changedFunction", scope = "com.example.SubSubClassOfChangedSuperClass"), - LookupSymbol(name = SAM_LOOKUP_NAME.asString(), scope = "com.example.ChangedSuperClass"), - LookupSymbol(name = SAM_LOOKUP_NAME.asString(), scope = "com.example.SubClassOfChangedSuperClass"), - LookupSymbol(name = SAM_LOOKUP_NAME.asString(), scope = "com.example.SubSubClassOfChangedSuperClass") - ), - fqNames = setOf( - "com.example.ChangedSuperClass", - "com.example.SubClassOfChangedSuperClass", - "com.example.SubSubClassOfChangedSuperClass" - ) - ).assertEquals(changes) - } - @Test fun testTopLevelMembers() { val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testTopLevelMembers/src"), tmpDir) @@ -235,6 +212,53 @@ class KotlinOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() { ) ).assertEquals(changes) } + + /** Tests [SupertypesInheritorsImpact]. */ + @Test + override fun testImpactComputation_SupertypesInheritors() { + val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testImpactComputation_SupertypesInheritors/src"), tmpDir) + Changes( + lookupSymbols = setOf( + LookupSymbol(name = "changedProperty", scope = "com.example.ChangedSuperClass"), + LookupSymbol(name = "changedProperty", scope = "com.example.SubClassOfChangedSuperClass"), + LookupSymbol(name = "changedProperty", scope = "com.example.SubSubClassOfChangedSuperClass"), + LookupSymbol(name = "changedFunction", scope = "com.example.ChangedSuperClass"), + LookupSymbol(name = "changedFunction", scope = "com.example.SubClassOfChangedSuperClass"), + LookupSymbol(name = "changedFunction", scope = "com.example.SubSubClassOfChangedSuperClass"), + LookupSymbol(name = SAM_LOOKUP_NAME.asString(), scope = "com.example.ChangedSuperClass"), + LookupSymbol(name = SAM_LOOKUP_NAME.asString(), scope = "com.example.SubClassOfChangedSuperClass"), + LookupSymbol(name = SAM_LOOKUP_NAME.asString(), scope = "com.example.SubSubClassOfChangedSuperClass") + ), + fqNames = setOf( + "com.example.ChangedSuperClass", + "com.example.SubClassOfChangedSuperClass", + "com.example.SubSubClassOfChangedSuperClass" + ) + ).assertEquals(changes) + } + + /** + * Tests [ConstantsInCompanionObjectsImpact]. + * + * Note that this test is slightly different from [testConstantsAndInlineFunctions]: In [testConstantsAndInlineFunctions], the companion + * object's .class file changes, whereas in this test, the companion object's .class file does not change because we want to test that + * the companion object is unchanged but *impacted* by the change in the .class file of the companion object's outer class. + */ + @Test + fun testImpactComputation_ConstantsInCompanionObjects() { + val changes = computeClasspathChanges(File(testDataDir, "KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/src"), tmpDir) + Changes( + lookupSymbols = setOf( + LookupSymbol(name = "constantChangedValue", scope = "com.example.SomeClass"), + LookupSymbol(name = SAM_LOOKUP_NAME.asString(), scope = "com.example.SomeClass"), + LookupSymbol(name = "constantChangedValue", scope = "com.example.SomeClass.CompanionObject"), + ), + fqNames = setOf( + "com.example.SomeClass", + "com.example.SomeClass.CompanionObject" + ) + ).assertEquals(changes) + } } class JavaOnlyClasspathChangesComputerTest : ClasspathChangesComputerTest() { diff --git a/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/current-classpath/com/example/SomeClass$CompanionObject.class b/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/current-classpath/com/example/SomeClass$CompanionObject.class new file mode 100644 index 00000000000..d91c2731cd5 Binary files /dev/null and b/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/current-classpath/com/example/SomeClass$CompanionObject.class differ diff --git a/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/current-classpath/com/example/SomeClass.class b/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/current-classpath/com/example/SomeClass.class new file mode 100644 index 00000000000..470d5dacd10 Binary files /dev/null and b/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/current-classpath/com/example/SomeClass.class differ diff --git a/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/previous-classpath/com/example/SomeClass$CompanionObject.class b/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/previous-classpath/com/example/SomeClass$CompanionObject.class new file mode 100644 index 00000000000..d91c2731cd5 Binary files /dev/null and b/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/previous-classpath/com/example/SomeClass$CompanionObject.class differ diff --git a/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/previous-classpath/com/example/SomeClass.class b/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/previous-classpath/com/example/SomeClass.class new file mode 100644 index 00000000000..8c67ae6b625 Binary files /dev/null and b/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/previous-classpath/com/example/SomeClass.class differ diff --git a/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/src/current-classpath/com/example/SomeClass.kt b/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/src/current-classpath/com/example/SomeClass.kt new file mode 100644 index 00000000000..f68e68fa004 --- /dev/null +++ b/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/src/current-classpath/com/example/SomeClass.kt @@ -0,0 +1,9 @@ +package com.example + +class SomeClass { + + companion object CompanionObject { + const val constantChangedValue: Int = 1000 + const val constantUnchanged: Int = 0 + } +} \ No newline at end of file diff --git a/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/src/previous-classpath/com/example/SomeClass.kt b/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/src/previous-classpath/com/example/SomeClass.kt new file mode 100644 index 00000000000..e2c411e8244 --- /dev/null +++ b/compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/src/previous-classpath/com/example/SomeClass.kt @@ -0,0 +1,9 @@ +package com.example + +class SomeClass { + + companion object CompanionObject { + const val constantChangedValue: Int = 0 + const val constantUnchanged: Int = 0 + } +} \ No newline at end of file