Hack for checking access to internal declarations during incremental compilation
This commit is contained in:
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.*
|
|||||||
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager
|
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager
|
||||||
import org.jetbrains.kotlin.load.kotlin.getSourceElement
|
import org.jetbrains.kotlin.load.kotlin.getSourceElement
|
||||||
import org.jetbrains.kotlin.load.kotlin.isContainedByCompiledPartOfOurModule
|
import org.jetbrains.kotlin.load.kotlin.isContainedByCompiledPartOfOurModule
|
||||||
|
import org.jetbrains.kotlin.load.kotlin.isFromIncrementalPackageFragment
|
||||||
import org.jetbrains.kotlin.modules.Module
|
import org.jetbrains.kotlin.modules.Module
|
||||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor
|
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor
|
||||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElement
|
import org.jetbrains.kotlin.resolve.source.KotlinSourceElement
|
||||||
@@ -59,6 +60,10 @@ class ModuleVisibilityHelperImpl : ModuleVisibilityHelper {
|
|||||||
|
|
||||||
if (modules.isEmpty()) return false
|
if (modules.isEmpty()) return false
|
||||||
|
|
||||||
|
// Hack for incremental compilation (now there is no way to determine the module of descriptor in case of incremental package fragment)
|
||||||
|
// TODO Implement full check for access to internal for incremental compilation
|
||||||
|
if (what.isFromIncrementalPackageFragment) return true
|
||||||
|
|
||||||
return findModule(from, modules) === findModule(what, modules)
|
return findModule(from, modules) === findModule(what, modules)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ interface ModuleVisibilityManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public val DeclarationDescriptor.isFromIncrementalPackageFragment: Boolean
|
||||||
|
get() =
|
||||||
|
DescriptorUtils.getParentOfType(this, PackageFragmentDescriptor::class.java, false) is IncrementalPackageFragmentProvider.IncrementalPackageFragment
|
||||||
|
|
||||||
public fun isContainedByCompiledPartOfOurModule(descriptor: DeclarationDescriptor, outDirectory: File?): Boolean {
|
public fun isContainedByCompiledPartOfOurModule(descriptor: DeclarationDescriptor, outDirectory: File?): Boolean {
|
||||||
val packageFragment = DescriptorUtils.getParentOfType(descriptor, PackageFragmentDescriptor::class.java, false)
|
val packageFragment = DescriptorUtils.getParentOfType(descriptor, PackageFragmentDescriptor::class.java, false)
|
||||||
|
|
||||||
|
|||||||
+6
@@ -55,6 +55,12 @@ public class ExperimentalIncrementalJpsTestGenerated extends AbstractExperimenta
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("circularDependencyWithAccessToInternal")
|
||||||
|
public void testCircularDependencyWithAccessToInternal() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/circularDependencyWithAccessToInternal/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("constantValueChanged")
|
@TestMetadata("constantValueChanged")
|
||||||
public void testConstantValueChanged() throws Exception {
|
public void testConstantValueChanged() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/constantValueChanged/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/constantValueChanged/");
|
||||||
|
|||||||
@@ -55,6 +55,12 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("circularDependencyWithAccessToInternal")
|
||||||
|
public void testCircularDependencyWithAccessToInternal() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/circularDependencyWithAccessToInternal/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("constantValueChanged")
|
@TestMetadata("constantValueChanged")
|
||||||
public void testConstantValueChanged() throws Exception {
|
public void testConstantValueChanged() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/constantValueChanged/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/constantValueChanged/");
|
||||||
|
|||||||
Vendored
+22
@@ -0,0 +1,22 @@
|
|||||||
|
Cleaning output files:
|
||||||
|
out/production/module1/META-INF/module1.kotlin_module
|
||||||
|
out/production/module1/a/Module1_aKt.class
|
||||||
|
out/production/module1/c/Module1_c2Kt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
module1/src/module1_a.kt
|
||||||
|
module1/src/module1_c2.kt
|
||||||
|
End of files
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module1/META-INF/module1.kotlin_module
|
||||||
|
out/production/module1/c/Module1_c1Kt.class
|
||||||
|
out/production/module2/META-INF/module2.kotlin_module
|
||||||
|
out/production/module2/b/B.class
|
||||||
|
out/production/module2/b/Module2_bKt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
module2/src/module2_b.kt
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
module1/src/module1_c1.kt
|
||||||
|
End of files
|
||||||
Vendored
+2
@@ -0,0 +1,2 @@
|
|||||||
|
module1->module2
|
||||||
|
module2->module1
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
========== Step #1 ============
|
||||||
|
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module1/META-INF/module1.kotlin_module
|
||||||
|
out/production/module1/a/Module1_aKt.class
|
||||||
|
out/production/module1/c/Module1_c2Kt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
module1/src/module1_a.kt
|
||||||
|
module1/src/module1_c2.kt
|
||||||
|
End of files
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package a
|
||||||
|
|
||||||
|
fun a() {
|
||||||
|
c.internalFun()
|
||||||
|
}
|
||||||
Vendored
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package a
|
||||||
|
|
||||||
|
fun a() {
|
||||||
|
}
|
||||||
|
|
||||||
|
fun aa() {
|
||||||
|
c.internalFun()
|
||||||
|
c.internalFun2()
|
||||||
|
}
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package c
|
||||||
|
|
||||||
|
fun publicFun() {}
|
||||||
|
|
||||||
|
internal fun internalFun2() {}
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package c
|
||||||
|
|
||||||
|
internal fun internalFun() {}
|
||||||
jps-plugin/testData/incremental/multiModule/circularDependencyWithAccessToInternal/module1_c2.kt.new
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package c
|
||||||
|
|
||||||
|
internal fun internalFun() {}
|
||||||
|
|
||||||
|
fun newFun() {}
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package b
|
||||||
|
|
||||||
|
class B
|
||||||
|
|
||||||
|
fun b() {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user