mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Check that kotlin.stdlib is explicitly required in module-info
Writing a Jigsaw-modular Kotlin program which doesn't require
kotlin.stdlib doesn't make sense because it most likely will fail at
runtime, on access to anything from the standard library. Previously, we
checked that kotlin.stdlib was in the module graph, but that's not
enough, we should also check that the source module requires it.
'-Xallow-kotlin-package' can be used to disable the error.
Add a test checking that an indirect (transitive) dependency is also OK
(cherry picked from commit 0439abba46)
This commit is contained in:
@@ -2,4 +2,6 @@ module moduleD {
|
||||
requires moduleA;
|
||||
requires moduleB;
|
||||
requires moduleC;
|
||||
}
|
||||
|
||||
requires kotlin.stdlib;
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,3 @@
|
||||
module namedWithIndirectDependencyViaOtherModule {
|
||||
requires namedWithExplicitDependency;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import kotlin.text.Regex
|
||||
|
||||
fun f1(): List<String?> = emptyList()
|
||||
fun f2(): Array<Lazy<Unit>> = arrayOf()
|
||||
fun f3(map: Map<Int, Regex>): Collection<Regex> =
|
||||
map.filterNot { (key, entry) -> "$key".equals(entry.toString(), ignoreCase = true) }.values
|
||||
@@ -1,34 +1,2 @@
|
||||
compiler/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/test.kt:1:20: error: symbol is declared in module 'kotlin.stdlib' which current module does not depend on
|
||||
import kotlin.text.Regex
|
||||
^
|
||||
compiler/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/test.kt:3:27: error: symbol is declared in module 'kotlin.stdlib' which current module does not depend on
|
||||
fun f1(): List<String?> = emptyList()
|
||||
^
|
||||
compiler/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/test.kt:4:17: error: symbol is declared in module 'kotlin.stdlib' which current module does not depend on
|
||||
fun f2(): Array<Lazy<Unit>> = arrayOf()
|
||||
^
|
||||
compiler/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/test.kt:4:22: error: symbol is declared in module 'kotlin.stdlib' which current module does not depend on
|
||||
fun f2(): Array<Lazy<Unit>> = arrayOf()
|
||||
^
|
||||
compiler/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/test.kt:5:22: error: symbol is declared in module 'kotlin.stdlib' which current module does not depend on
|
||||
fun f3(map: Map<Int, Regex>): Collection<Regex> =
|
||||
^
|
||||
compiler/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/test.kt:5:42: error: symbol is declared in module 'kotlin.stdlib' which current module does not depend on
|
||||
fun f3(map: Map<Int, Regex>): Collection<Regex> =
|
||||
^
|
||||
compiler/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/test.kt:6:13: error: symbol is declared in module 'kotlin.stdlib' which current module does not depend on
|
||||
map.filterNot { (key, entry) -> "$key".equals(entry.toString(), ignoreCase = true) }.values
|
||||
^
|
||||
compiler/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/test.kt:6:26: error: symbol is declared in module 'kotlin.stdlib' which current module does not depend on
|
||||
map.filterNot { (key, entry) -> "$key".equals(entry.toString(), ignoreCase = true) }.values
|
||||
^
|
||||
compiler/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/test.kt:6:31: error: symbol is declared in module 'kotlin.stdlib' which current module does not depend on
|
||||
map.filterNot { (key, entry) -> "$key".equals(entry.toString(), ignoreCase = true) }.values
|
||||
^
|
||||
compiler/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/test.kt:6:48: error: symbol is declared in module 'kotlin.stdlib' which current module does not depend on
|
||||
map.filterNot { (key, entry) -> "$key".equals(entry.toString(), ignoreCase = true) }.values
|
||||
^
|
||||
compiler/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/test.kt:6:61: error: symbol is declared in module 'kotlin.stdlib' which current module does not depend on
|
||||
map.filterNot { (key, entry) -> "$key".equals(entry.toString(), ignoreCase = true) }.values
|
||||
^
|
||||
compiler/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/module-info.java: error: the Kotlin standard library is not found in the module graph. Please ensure you have the 'requires kotlin.stdlib' clause in your module definition
|
||||
COMPILATION_ERROR
|
||||
|
||||
@@ -2,4 +2,6 @@ module main {
|
||||
requires java.naming;
|
||||
requires jdk.net;
|
||||
requires oracle.desktop;
|
||||
|
||||
requires kotlin.stdlib;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
module main {
|
||||
requires library;
|
||||
|
||||
requires kotlin.stdlib;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
module moduleC {
|
||||
requires moduleB;
|
||||
|
||||
requires kotlin.stdlib;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
module moduleD {
|
||||
requires moduleC;
|
||||
requires moduleB;
|
||||
|
||||
requires kotlin.stdlib;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
module main {
|
||||
requires dependency;
|
||||
|
||||
requires kotlin.stdlib;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
module moduleB {
|
||||
requires moduleA;
|
||||
|
||||
requires kotlin.stdlib;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
module moduleB {
|
||||
requires moduleA;
|
||||
|
||||
requires kotlin.stdlib;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
module moduleB {
|
||||
requires moduleA;
|
||||
|
||||
requires kotlin.stdlib;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user