From bd085495bdadf6b65a68db11c63315d722fca791 Mon Sep 17 00:00:00 2001 From: Hung Nguyen Date: Tue, 9 Aug 2022 11:49:28 +0100 Subject: [PATCH] New IC: Add tests for constants-in-companion-objects impact computation ^KT-53266 Fixed --- .../ClasspathChangesComputerTest.kt | 70 ++++++++++++------ .../example/SomeClass$CompanionObject.class | Bin 0 -> 859 bytes .../com/example/SomeClass.class | Bin 0 -> 912 bytes .../example/SomeClass$CompanionObject.class | Bin 0 -> 859 bytes .../com/example/SomeClass.class | Bin 0 -> 907 bytes .../com/example/SomeClass.kt | 9 +++ .../com/example/SomeClass.kt | 9 +++ 7 files changed, 65 insertions(+), 23 deletions(-) create mode 100644 compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/current-classpath/com/example/SomeClass$CompanionObject.class create mode 100644 compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/current-classpath/com/example/SomeClass.class create mode 100644 compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/previous-classpath/com/example/SomeClass$CompanionObject.class create mode 100644 compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/classes/previous-classpath/com/example/SomeClass.class create mode 100644 compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/src/current-classpath/com/example/SomeClass.kt create mode 100644 compiler/incremental-compilation-impl/testData/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathChangesComputerTest/KotlinOnly/testImpactComputation_ConstantsInCompanionObjects/src/previous-classpath/com/example/SomeClass.kt 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 0000000000000000000000000000000000000000..d91c2731cd55e61c7d2252ba71b81e52fefb8451 GIT binary patch literal 859 zcmb7C%Wl&^6g@Le6JtV?K1s?OQraR>rxm*b5(FVdNuEI0K!=9#{4_>N2Z- z2!Fr|i3N(fzk zXvNWy&??q%2Zu5+B`}8Sp%@E46#A2YfjSJur%EgHoWWV&=#?>pqK5)X3y^C zqMT*e{J+x}<}L)g(ukojg5JcVu|ut5*0|PyfsF`1RyJ!=G~8n7PABsouW^r8rxTC6 zHgLV^#63N6YSYO!Z?cyqm!Ezv@+$AnR-F~zEWAHG*|!MQ5j1lNvL|mdd*5RIJE2YM zfO;>7JrQP-o_hhm)4>_Ru=LknmvD=ra%rRt<=^Ap92uHdD<0CZm5$Q#O%@GgvM&Z9 zA@iL$5MfUw%I4=_xvjNK@@0`UWp6Lel0d#zR#5L|+NenORH{hvLhINFL(7z6izZgE zZ6wd_ve5tTQRdselAn3>74DauzE9TD1mXeN@_Bp(9#Cb3UM0keACu>{j>KgvX1QSb z3`8!lG_GNmI0p^Nyj*k}cTmSFU|Vbcqvv=8{Ei)o4)|VoXFDv literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..470d5dacd108fdd3e7465e67698ee17984a34fe8 GIT binary patch literal 912 zcmZuv-A)rh6#iznl(KH6MUWQ!K>_(uSs*4RLQJ&AWRrr4XcNQLbUVVdyE9~Ww&9Xz z@ePa@B$^oFrBC8h7|%dKgY3om|IRtz+4=eV>vsT85HL(cItj!fPYz-c?C3-^VxDEg zU<{Qm@ADw$YA<-x?uy6^!(}LLN+r#626u6(zHVv&Zljf1p=@w6WBHcJ! z>bi$AMj1vgwPaYhdcVuFH+)nvHUbAX7-pL~-3z+Hv{Nos7I3As;f5B?f^BWK^Ef7c z&__bNK8paejPbB0^O@D4YenmI||W|m0M3Ju*MDx*!Q#CD#vMf#2thGDF!BObSSDy=^V z`k_)HJ$*=mUWB)!^E48#r3KUnb6fvS#Tp&EKm=XX?d@sj1@eldCrHGLUMnWRnI0S`&~X9XC6M_vinF2FUau%G`80acdWDh}$9VgqXrzGBFe49`5ggWthd> PE(#gE4D%U^8LEE(rwq?1 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..d91c2731cd55e61c7d2252ba71b81e52fefb8451 GIT binary patch literal 859 zcmb7C%Wl&^6g@Le6JtV?K1s?OQraR>rxm*b5(FVdNuEI0K!=9#{4_>N2Z- z2!Fr|i3N(fzk zXvNWy&??q%2Zu5+B`}8Sp%@E46#A2YfjSJur%EgHoWWV&=#?>pqK5)X3y^C zqMT*e{J+x}<}L)g(ukojg5JcVu|ut5*0|PyfsF`1RyJ!=G~8n7PABsouW^r8rxTC6 zHgLV^#63N6YSYO!Z?cyqm!Ezv@+$AnR-F~zEWAHG*|!MQ5j1lNvL|mdd*5RIJE2YM zfO;>7JrQP-o_hhm)4>_Ru=LknmvD=ra%rRt<=^Ap92uHdD<0CZm5$Q#O%@GgvM&Z9 zA@iL$5MfUw%I4=_xvjNK@@0`UWp6Lel0d#zR#5L|+NenORH{hvLhINFL(7z6izZgE zZ6wd_ve5tTQRdselAn3>74DauzE9TD1mXeN@_Bp(9#Cb3UM0keACu>{j>KgvX1QSb z3`8!lG_GNmI0p^Nyj*k}cTmSFU|Vbcqvv=8{Ei)o4)|VoXFDv literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..8c67ae6b6253a0de85de4e65002da52de7eac7eb GIT binary patch literal 907 zcmZuvTTc@~6#izml(KH6MUYm!pnzOd7Kn+75EHF2*`(A&w29$qx*cKK-C43b+wjP5 z@gEo;NHj6TM}L&@3>1vWKAhW}@0{c``vKr7RvD(kB=+T@hz}y^?&*A9Q$@L9z4UwxtnWVFcCT@xUUO6(z#=DRii; zw?H5Bs+N>xy;SbAbkQP`7I*&JW2elAa=6$4yL=y+}4kjr{sQ zKBqUjLy}9B;ghDZF|u-u(w9@nGD-Vv8?2D@&Jr*Nm%I|LU4UzpVL$IX${*P=Dqk^a zYgptXk}e_3M50O*9+S_pfG4D%QT!H>nAwFB;C6sJ0TI1RChi58#r<8d3=c53i$VrB K!+eHfhUy