From 6ebe0c30ec99df77b9d9260e8dda5d0d9a975877 Mon Sep 17 00:00:00 2001 From: Michael Nedzelsky Date: Tue, 6 Oct 2015 16:23:37 +0300 Subject: [PATCH] fix KT-9299 In a project with circular dependencies between modules, IDE reports error on use of internal class from another module, but the corresponding code still compiles and runs. #KT-9299 Fixed --- .../kotlin/cli/common/moduleVisibilityImpl.kt | 13 ++++++- .../resolve/QualifiedExpressionResolver.kt | 34 ++++++++++++++++--- .../build/IncrementalJpsTestGenerated.java | 12 +++++++ .../kotlin/jps/build/KotlinJpsBuildTest.kt | 21 +++++++----- .../errors.txt | 7 ++++ .../module1/src/module1.kt | 9 +++++ .../module2/src/module2.kt | 8 +++-- .../InternalFromAnotherModule/errors.txt | 10 +++--- .../module1/src/module1.kt | 9 +++++ .../module2/src/module2.kt | 3 ++ .../build.log | 26 ++++++++++++++ .../dependencies.txt | 2 ++ .../module1_a.kt | 14 ++++++++ .../module1_a.kt.new | 15 ++++++++ .../module2_b.kt | 13 +++++++ .../module2_c.kt | 5 +++ .../build.log | 26 ++++++++++++++ .../dependencies.txt | 2 ++ .../module1_a.kt | 19 +++++++++++ .../module1_a.kt.new | 19 +++++++++++ .../module2_b.kt | 7 ++++ .../module2_b.kt.new | 12 +++++++ .../module2_c.kt | 5 +++ 23 files changed, 270 insertions(+), 21 deletions(-) create mode 100644 jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/errors.txt create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/build.log create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/dependencies.txt create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module1_a.kt create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module1_a.kt.new create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module2_b.kt create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module2_c.kt create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/build.log create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/dependencies.txt create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module1_a.kt create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module1_a.kt.new create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module2_b.kt create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module2_b.kt.new create mode 100644 jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module2_c.kt diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/moduleVisibilityImpl.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/moduleVisibilityImpl.kt index 2000ecc8421..7b9f68cef34 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/moduleVisibilityImpl.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/moduleVisibilityImpl.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager import org.jetbrains.kotlin.load.kotlin.getSourceElement import org.jetbrains.kotlin.load.kotlin.isContainedByCompiledPartOfOurModule import org.jetbrains.kotlin.modules.Module +import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor import org.jetbrains.kotlin.resolve.source.KotlinSourceElement import org.jetbrains.kotlin.util.ModuleVisibilityHelper @@ -44,8 +45,18 @@ class ModuleVisibilityHelperImpl : ModuleVisibilityHelper { val moduleVisibilityManager = ModuleVisibilityManager.SERVICE.getInstance(project) + fun findModule(kotlinFile: KtFile): Module? = moduleVisibilityManager.chunk.firstOrNull { it.getSourceFiles().containsRaw(kotlinFile.virtualFile.path) } + val whatSource = getSourceElement(what) - if (whatSource is KotlinSourceElement) return true + if (whatSource is KotlinSourceElement) { + if (moduleVisibilityManager.chunk.size > 1 && fromSource is KotlinSourceElement) { + val fromSourceKotlinFile = fromSource.psi.getContainingJetFile() + val whatSourceKotlinFile = whatSource.psi.getContainingJetFile() + return findModule(whatSourceKotlinFile) === findModule(fromSourceKotlinFile) + } + + return true + } moduleVisibilityManager.friendPaths.forEach { if (isContainedByCompiledPartOfOurModule(what, File(it))) return true diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt index 613aee75128..338506b33d3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.resolve.scopes.receivers.QualifierReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.utils.findClassifier +import org.jetbrains.kotlin.resolve.source.KotlinSourceElement import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.check @@ -122,11 +123,19 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa val importedReference = importDirective.importedReference ?: return null val path = importedReference.asQualifierPartList(trace) val lastPart = path.lastOrNull() ?: return null + val packageFragmentForCheck = + if (packageFragmentForVisibilityCheck is DeclarationDescriptorWithSource && packageFragmentForVisibilityCheck.source == SourceElement.NO_SOURCE) { + PackageFragmentWithCustomSource(packageFragmentForVisibilityCheck, KotlinSourceElement(importDirective.getContainingJetFile())) + } + + else { + packageFragmentForVisibilityCheck + } if (!importDirective.isAllUnder) { - return processSingleImport(moduleDescriptor, trace, importDirective, path, lastPart, packageFragmentForVisibilityCheck) + return processSingleImport(moduleDescriptor, trace, importDirective, path, lastPart, packageFragmentForCheck) } - val packageOrClassDescriptor = resolveToPackageOrClass(path, moduleDescriptor, trace, packageFragmentForVisibilityCheck, + val packageOrClassDescriptor = resolveToPackageOrClass(path, moduleDescriptor, trace, packageFragmentForCheck, scopeForFirstPart = null, inImport = true) ?: return null if (packageOrClassDescriptor is ClassDescriptor && packageOrClassDescriptor.kind.isSingleton) { trace.report(Errors.CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON.on(lastPart.expression, packageOrClassDescriptor)) // todo report on star @@ -398,8 +407,17 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa symbolUsageValidator.validateTypeUsage(descriptor, trace, referenceExpression) } - if (descriptor is DeclarationDescriptorWithVisibility && !isVisible(descriptor, shouldBeVisibleFrom, inImport)) { - trace.report(Errors.INVISIBLE_REFERENCE.on(referenceExpression, descriptor, descriptor.visibility, descriptor)) + if (descriptor is DeclarationDescriptorWithVisibility) { + val fromToCheck = + if (shouldBeVisibleFrom is PackageFragmentDescriptor && shouldBeVisibleFrom.source == SourceElement.NO_SOURCE) { + PackageFragmentWithCustomSource(shouldBeVisibleFrom, KotlinSourceElement(referenceExpression.getContainingJetFile())) + } + else { + shouldBeVisibleFrom + } + if (!isVisible(descriptor, fromToCheck, inImport)) { + trace.report(Errors.INVISIBLE_REFERENCE.on(referenceExpression, descriptor, descriptor.visibility, descriptor)) + } } if (isQualifier) { @@ -429,3 +447,11 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa return Visibilities.isVisible(ReceiverValue.IRRELEVANT_RECEIVER, descriptor, shouldBeVisibleFrom) } } + +/* + This purpose of this class is to pass information about source file for current package fragment in order for check visibilities between modules + (see ModuleVisibilityHelperImpl.isInFriendModule). + */ +private class PackageFragmentWithCustomSource(private val original: PackageFragmentDescriptor, private val source: SourceElement) : PackageFragmentDescriptor by original { + override fun getSource(): SourceElement = source +} diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalJpsTestGenerated.java b/jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalJpsTestGenerated.java index 00730fed6a4..896dbdd010d 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalJpsTestGenerated.java +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalJpsTestGenerated.java @@ -79,6 +79,18 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest { doTest(fileName); } + @TestMetadata("simpleDependencyErrorOnAccessToInternal1") + public void testSimpleDependencyErrorOnAccessToInternal1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/"); + doTest(fileName); + } + + @TestMetadata("simpleDependencyErrorOnAccessToInternal2") + public void testSimpleDependencyErrorOnAccessToInternal2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/"); + doTest(fileName); + } + @TestMetadata("simpleDependencyUnchanged") public void testSimpleDependencyUnchanged() throws Exception { String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/simpleDependencyUnchanged/"); diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt b/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt index f5fe840ffaa..b4264cd694a 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt @@ -494,20 +494,14 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { initProject() val result = makeAll() result.assertFailed() - - val actualErrors = result.getMessages(BuildMessage.Kind.ERROR) - .map { it as CompilerMessage } - .map { "${it.messageText} at line ${it.line}, column ${it.column}" }.sorted().joinToString("\n") - val projectRoot = File(AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/" + getTestName(false)) - val expectedFile = File(projectRoot, "errors.txt") - JetTestUtils.assertEqualsToFile(expectedFile, actualErrors) + result.checkErrors() } - // TODO See KT-9299 In a project with circular dependencies between modules, IDE reports error on use of internal class from another module, but the corresponding code still compiles and runs. public fun testCircularDependenciesInternalFromAnotherModule() { initProject() val result = makeAll() - result.assertSuccessful() + result.assertFailed() + result.checkErrors() } public fun testCircularDependencyWithReferenceToOldVersionLib() { @@ -679,6 +673,15 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { assertFalse(File(storageRoot, "targets/java-production/module2/kotlin").exists()) } + private fun BuildResult.checkErrors() { + val actualErrors = getMessages(BuildMessage.Kind.ERROR) + .map { it as CompilerMessage } + .map { "${it.messageText} at line ${it.line}, column ${it.column}" }.sorted().joinToString("\n") + val projectRoot = File(AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/" + getTestName(false)) + val expectedFile = File(projectRoot, "errors.txt") + JetTestUtils.assertEqualsToFile(expectedFile, actualErrors) + } + private fun buildCustom(canceledStatus: CanceledStatus, logger: TestProjectBuilderLogger,buildResult: BuildResult) { val scopeBuilder = CompileScopeTestBuilder.make().all() val descriptor = this.createProjectDescriptor(BuildLoggingManager(logger)) diff --git a/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/errors.txt b/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/errors.txt new file mode 100644 index 00000000000..331aaf1316d --- /dev/null +++ b/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/errors.txt @@ -0,0 +1,7 @@ +'internal open val member: kotlin.Int defined in test.ClassBB1' has no access to 'internal abstract val member: kotlin.Int defined in test.ClassB1', so it cannot override it at line 14, column 14 +Cannot access 'InternalClass1': it is 'internal' in 'test' at line 5, column 13 +Cannot access 'InternalClass1': it is 'internal' in 'test' at line 8, column 36 +Cannot access 'InternalClass2': it is 'internal' in 'test' at line 19, column 15 +Cannot access 'InternalClassAnnotation': it is 'internal' in 'test' at line 10, column 2 +Cannot access 'InternalFileAnnotation': it is 'internal' in 'test' at line 1, column 7 +Cannot access 'member': it is 'invisible_fake' in 'ClassAA1' at line 27, column 25 \ No newline at end of file diff --git a/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module1/src/module1.kt b/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module1/src/module1.kt index 30fcc94d780..9a7bdb153a3 100644 --- a/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module1/src/module1.kt +++ b/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module1/src/module1.kt @@ -2,9 +2,18 @@ package test internal open class InternalClass1 +@Target(AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalFileAnnotation() + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalClassAnnotation() + abstract class ClassA1(internal val member: Int) abstract class ClassB1 { internal abstract val member: Int } +class ClassD: InternalClass2() \ No newline at end of file diff --git a/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/src/module2.kt b/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/src/module2.kt index 1f1647ddad4..ece01121bd2 100644 --- a/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/src/module2.kt +++ b/jps-plugin/testData/general/CircularDependenciesInternalFromAnotherModule/module2/src/module2.kt @@ -1,11 +1,13 @@ -// ERROR: 'internal open val member: kotlin.Int defined in test.ClassBB1' has no access to 'internal abstract val member: kotlin.Int defined in test.ClassB1', so it cannot override it -// ERROR: Cannot access 'InternalClass1': it is 'internal' in 'test' -// ERROR: Cannot access 'member': it is 'invisible_fake' in 'ClassAA1' +@file:InternalFileAnnotation + package test +import test.InternalClass1 + // InternalClass1, ClassA1, ClassB1 are in module1 class ClassInheritedFromInternal1: InternalClass1() +@InternalClassAnnotation class ClassAA1 : ClassA1(10) class ClassBB1 : ClassB1() { diff --git a/jps-plugin/testData/general/InternalFromAnotherModule/errors.txt b/jps-plugin/testData/general/InternalFromAnotherModule/errors.txt index 13cd0c3cbf1..2fae260968a 100644 --- a/jps-plugin/testData/general/InternalFromAnotherModule/errors.txt +++ b/jps-plugin/testData/general/InternalFromAnotherModule/errors.txt @@ -1,4 +1,6 @@ -'internal open val member: kotlin.Int defined in test.ClassBB1' has no access to 'internal abstract val member: kotlin.Int defined in test.ClassB1', so it cannot override it at line 11, column 14 -Cannot access 'InternalClass1': it is 'internal' in 'test' at line 3, column 13 -Cannot access 'InternalClass1': it is 'internal' in 'test' at line 6, column 36 -Cannot access 'member': it is 'invisible_fake' in 'ClassAA1' at line 24, column 25 \ No newline at end of file +'internal open val member: kotlin.Int defined in test.ClassBB1' has no access to 'internal abstract val member: kotlin.Int defined in test.ClassB1', so it cannot override it at line 14, column 14 +Cannot access 'InternalClass1': it is 'internal' in 'test' at line 5, column 13 +Cannot access 'InternalClass1': it is 'internal' in 'test' at line 8, column 36 +Cannot access 'InternalClassAnnotation': it is 'internal' in 'test' at line 10, column 2 +Cannot access 'InternalTestAnnotation': it is 'internal' in 'test' at line 1, column 7 +Cannot access 'member': it is 'invisible_fake' in 'ClassAA1' at line 27, column 25 \ No newline at end of file diff --git a/jps-plugin/testData/general/InternalFromAnotherModule/module1/src/module1.kt b/jps-plugin/testData/general/InternalFromAnotherModule/module1/src/module1.kt index 30fcc94d780..e2fc0309302 100644 --- a/jps-plugin/testData/general/InternalFromAnotherModule/module1/src/module1.kt +++ b/jps-plugin/testData/general/InternalFromAnotherModule/module1/src/module1.kt @@ -1,4 +1,13 @@ package test +@Target(AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalTestAnnotation() + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalClassAnnotation() + +private class PrivateClass1 internal open class InternalClass1 diff --git a/jps-plugin/testData/general/InternalFromAnotherModule/module2/src/module2.kt b/jps-plugin/testData/general/InternalFromAnotherModule/module2/src/module2.kt index 64f4bb6cf1f..155a4c3a341 100644 --- a/jps-plugin/testData/general/InternalFromAnotherModule/module2/src/module2.kt +++ b/jps-plugin/testData/general/InternalFromAnotherModule/module2/src/module2.kt @@ -1,3 +1,5 @@ +@file:InternalTestAnnotation + package test import test.InternalClass1 @@ -5,6 +7,7 @@ import test.InternalClass1 // InternalClass1, ClassA1, ClassB1 are in module1 class ClassInheritedFromInternal1: InternalClass1() +@InternalClassAnnotation class ClassAA1 : ClassA1(10) class ClassBB1 : ClassB1() { diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/build.log b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/build.log new file mode 100644 index 00000000000..df01db10bfd --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/build.log @@ -0,0 +1,26 @@ +Cleaning output files: +out/production/module1/META-INF/module1.kotlin_module +out/production/module1/a/A.class +out/production/module1/a/ClassAnnotation.class +out/production/module1/a/FileAnnotation.class +out/production/module1/a/Module1_aKt.class +End of files +Compiling files: +module1/src/module1_a.kt +End of files +Cleaning output files: +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 +COMPILATION FAILED +Cannot access 'FileAnnotation': it is 'internal' in 'a' +Cannot access 'A': it is 'internal' in 'a' +Cannot access 'FileAnnotation': it is 'internal' in 'a' +Cannot access 'ClassAnnotation': it is 'internal' in 'a' +Cannot access 'ClassAnnotation': it is 'internal' in 'a' +Cannot access 'A': it is 'internal' in 'a' +Cannot access 'a': it is 'internal' in 'a' \ No newline at end of file diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/dependencies.txt b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/dependencies.txt new file mode 100644 index 00000000000..827bf04cc58 --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/dependencies.txt @@ -0,0 +1,2 @@ +module1-> +module2->module1 diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module1_a.kt b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module1_a.kt new file mode 100644 index 00000000000..621ede2ee51 --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module1_a.kt @@ -0,0 +1,14 @@ +package a + +@Target(AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +annotation class FileAnnotation() + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +annotation class ClassAnnotation() + +class A + +fun a() { +} diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module1_a.kt.new b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module1_a.kt.new new file mode 100644 index 00000000000..e514959008c --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module1_a.kt.new @@ -0,0 +1,15 @@ +package a + +@Target(AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +internal annotation class FileAnnotation() + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +internal annotation class ClassAnnotation() + +internal class A + +internal fun a(): String { + return ":)" +} diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module2_b.kt b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module2_b.kt new file mode 100644 index 00000000000..9573f5d0517 --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module2_b.kt @@ -0,0 +1,13 @@ +@file:FileAnnotation +package b + +import a.A +import a.FileAnnotation +import a.ClassAnnotation + +@ClassAnnotation +class B + +fun b(param: a.A) { + a.a() +} diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module2_c.kt b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module2_c.kt new file mode 100644 index 00000000000..c4fab8fb00b --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal1/module2_c.kt @@ -0,0 +1,5 @@ +package c + +fun c() { + // This file doesn't use anything from module1, so it won't be recompiled after change +} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/build.log b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/build.log new file mode 100644 index 00000000000..1a5350845e0 --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/build.log @@ -0,0 +1,26 @@ +Cleaning output files: +out/production/module1/META-INF/module1.kotlin_module +out/production/module1/a/A.class +out/production/module1/a/InternalA.class +out/production/module1/a/InternalClassAnnotation.class +out/production/module1/a/InternalFileAnnotation.class +out/production/module1/a/Module1_aKt.class +End of files +Compiling files: +module1/src/module1_a.kt +End of files +Cleaning output files: +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 +COMPILATION FAILED +Cannot access 'InternalFileAnnotation': it is 'internal' in 'a' +Cannot access 'InternalFileAnnotation': it is 'internal' in 'a' +Cannot access 'InternalClassAnnotation': it is 'internal' in 'a' +Cannot access 'InternalClassAnnotation': it is 'internal' in 'a' +Unresolved reference: InternalA +Unresolved reference: internalA \ No newline at end of file diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/dependencies.txt b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/dependencies.txt new file mode 100644 index 00000000000..827bf04cc58 --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/dependencies.txt @@ -0,0 +1,2 @@ +module1-> +module2->module1 diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module1_a.kt b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module1_a.kt new file mode 100644 index 00000000000..e7392045a0b --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module1_a.kt @@ -0,0 +1,19 @@ +package a + +@Target(AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalFileAnnotation() + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalClassAnnotation() + +class A + +internal class InternalA + +fun a() { +} + +internal fun internalA() { +} diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module1_a.kt.new b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module1_a.kt.new new file mode 100644 index 00000000000..bc696864750 --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module1_a.kt.new @@ -0,0 +1,19 @@ +package a + +@Target(AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalFileAnnotation() + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +internal annotation class InternalClassAnnotation() + +class A + +internal class AA + +fun a() { +} + +internal fun aa() { +} diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module2_b.kt b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module2_b.kt new file mode 100644 index 00000000000..436721358e9 --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module2_b.kt @@ -0,0 +1,7 @@ +package b + +class B + +fun b(param: a.A) { + a.a() +} diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module2_b.kt.new b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module2_b.kt.new new file mode 100644 index 00000000000..961d6541b9c --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module2_b.kt.new @@ -0,0 +1,12 @@ +@file:InternalFileAnnotation +package b + +import a.InternalFileAnnotation +import a.InternalClassAnnotation + +@InternalClassAnnotation +class B + +fun b(param: a.InternalA) { + a.internalA() +} diff --git a/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module2_c.kt b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module2_c.kt new file mode 100644 index 00000000000..c4fab8fb00b --- /dev/null +++ b/jps-plugin/testData/incremental/multiModule/simpleDependencyErrorOnAccessToInternal2/module2_c.kt @@ -0,0 +1,5 @@ +package c + +fun c() { + // This file doesn't use anything from module1, so it won't be recompiled after change +} \ No newline at end of file