[Test] Prohibit declaring dependency on the same module with different kinds in module structure
This commit is contained in:
committed by
Space Team
parent
c71b80823c
commit
83cbd322fd
Vendored
+2
-2
@@ -16,7 +16,7 @@ class Mut<T>(var _value: T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE: main(lib)(lib)
|
// MODULE: main()(lib)
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
import lib.*
|
import lib.*
|
||||||
|
|
||||||
@@ -73,4 +73,4 @@ fun box(): String {
|
|||||||
if (localDelegatedVarByProvider != 3) throw AssertionError()
|
if (localDelegatedVarByProvider != 3) throw AssertionError()
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -16,7 +16,7 @@ class Mut<T>(var _value: T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE: main(lib)(lib)
|
// MODULE: main()(lib)
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
import lib.*
|
import lib.*
|
||||||
|
|
||||||
@@ -73,4 +73,4 @@ fun box(): String {
|
|||||||
if (localDelegatedVarByProvider != 3) throw AssertionError()
|
if (localDelegatedVarByProvider != 3) throw AssertionError()
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ open internal class In {
|
|||||||
fun k() = "K"
|
fun k() = "K"
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE: main(lib)(lib)
|
// MODULE: main()(lib)
|
||||||
// FILE: m.kt
|
// FILE: m.kt
|
||||||
|
|
||||||
class Derived: Base()
|
class Derived: Base()
|
||||||
internal class IDerived: In()
|
internal class IDerived: In()
|
||||||
|
|
||||||
fun box(): String = Derived().o() + IDerived().k()
|
fun box(): String = Derived().o() + IDerived().k()
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ internal class A {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE: main(lib)(lib)
|
// MODULE: main()(lib)
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ class Mut<T>(var _value: T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE: main(lib)(lib)
|
// MODULE: main()(lib)
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
import lib.*
|
import lib.*
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -299,7 +299,7 @@ class ClassicFrontendFacade(
|
|||||||
val runtimeKlibs = loadKlib(runtimeKlibsNames, configuration)
|
val runtimeKlibs = loadKlib(runtimeKlibsNames, configuration)
|
||||||
val transitiveLibraries = JsEnvironmentConfigurator.getDependencies(module, testServices, DependencyRelation.RegularDependency)
|
val transitiveLibraries = JsEnvironmentConfigurator.getDependencies(module, testServices, DependencyRelation.RegularDependency)
|
||||||
val friendLibraries = JsEnvironmentConfigurator.getDependencies(module, testServices, DependencyRelation.FriendDependency)
|
val friendLibraries = JsEnvironmentConfigurator.getDependencies(module, testServices, DependencyRelation.FriendDependency)
|
||||||
val allDependencies = runtimeKlibs + dependencyDescriptors + transitiveLibraries
|
val allDependencies = runtimeKlibs + dependencyDescriptors + friendsDescriptors + transitiveLibraries
|
||||||
|
|
||||||
val analyzer = AnalyzerWithCompilerReport(configuration)
|
val analyzer = AnalyzerWithCompilerReport(configuration)
|
||||||
val builtInModuleDescriptor = allDependencies.firstNotNullOfOrNull { it.builtIns }?.builtInsModule
|
val builtInModuleDescriptor = allDependencies.firstNotNullOfOrNull { it.builtIns }?.builtInsModule
|
||||||
|
|||||||
+16
-2
@@ -280,11 +280,25 @@ class ModuleStructureExtractorImpl(
|
|||||||
dependenciesNames = dependenciesNames.filter { it != "support" }
|
dependenciesNames = dependenciesNames.filter { it != "support" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val friendsNames = friends.takeIf { it.isNotBlank() }?.split(" ") ?: emptyList()
|
||||||
|
val dependsOnNames = dependsOn.takeIf { it.isNotBlank() }?.split(" ") ?: emptyList()
|
||||||
|
|
||||||
|
val intersection = buildSet {
|
||||||
|
addAll(dependenciesNames intersect friendsNames)
|
||||||
|
addAll(dependenciesNames intersect dependsOnNames)
|
||||||
|
addAll(friendsNames intersect dependsOnNames)
|
||||||
|
}
|
||||||
|
require(intersection.isEmpty()) {
|
||||||
|
val m = if (intersection.size == 1) "module" else "modules"
|
||||||
|
val names = if (intersection.size == 1) "`${intersection.first()}`" else intersection.joinToArrayString()
|
||||||
|
"""Module `$name` depends on $m $names with different kinds simultaneously"""
|
||||||
|
}
|
||||||
|
|
||||||
return ModuleNameAndDependencies(
|
return ModuleNameAndDependencies(
|
||||||
name,
|
name,
|
||||||
dependenciesNames,
|
dependenciesNames,
|
||||||
friends.takeIf { it.isNotBlank() }?.split(" ") ?: emptyList(),
|
friendsNames,
|
||||||
dependsOn.takeIf { it.isNotBlank() }?.split(" ") ?: emptyList(),
|
dependsOnNames,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -20,7 +20,7 @@ internal inline fun test1(): String {
|
|||||||
|
|
||||||
internal fun callTest1(): String = test1()
|
internal fun callTest1(): String = test1()
|
||||||
|
|
||||||
// MODULE: main(lib)(lib)
|
// MODULE: main()(lib)
|
||||||
// FILE: lib.kt
|
// FILE: lib.kt
|
||||||
internal inline fun test2(): String {
|
internal inline fun test2(): String {
|
||||||
val x = C()
|
val x = C()
|
||||||
@@ -38,4 +38,4 @@ fun box(): String {
|
|||||||
if (r2 != "2abcd") return "fail2: $r2"
|
if (r2 != "2abcd") return "fail2: $r2"
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ internal fun bar() = "OK"
|
|||||||
|
|
||||||
internal inline fun foo() = bar()
|
internal inline fun foo() = bar()
|
||||||
|
|
||||||
// MODULE: main(lib)(lib)
|
// MODULE: main()(lib)
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
fun box(): String = foo()
|
fun box(): String = foo()
|
||||||
|
|||||||
Reference in New Issue
Block a user