[CLI] Prohibit passing HMPP module structure with CLI arguments to metadata compiler

^KT-57644 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-03-29 10:44:28 +03:00
committed by Space Team
parent b9c61bbc60
commit 96e9d690a6
4 changed files with 12 additions and 7 deletions
@@ -66,8 +66,12 @@ class K2MetadataCompiler : CLICompiler<K2MetadataCompilerArguments>() {
val commonSources = arguments.commonSources?.toSet() ?: emptySet()
val hmppCliModuleStructure = configuration.get(CommonConfigurationKeys.HMPP_MODULE_STRUCTURE)
if (hmppCliModuleStructure != null) {
collector.report(ERROR, "HMPP module structure should not be passed during metadata compilation. Please remove `-Xfragments` and related flags")
return ExitCode.COMPILATION_ERROR
}
for (arg in arguments.freeArgs) {
configuration.addKotlinSourceRoot(arg, isCommon = arg in commonSources, hmppCliModuleStructure?.getModuleNameForSource(arg))
configuration.addKotlinSourceRoot(arg, isCommon = arg in commonSources, hmppModuleName = null)
}
if (arguments.classpath != null) {
configuration.addJvmClasspathRoots(arguments.classpath!!.split(File.pathSeparatorChar).map(::File))
@@ -8,4 +8,5 @@ as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!
warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features
OK
error: HMPP module structure should not be passed during metadata compilation. Please remove `-Xfragments` and related flags
COMPILATION_ERROR
@@ -1594,6 +1594,11 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/metadata/anonymousObjectTypeWithFir.args");
}
@TestMetadata("hmppModules.args")
public void testHmppModules() throws Exception {
runTest("compiler/testData/cli/metadata/hmppModules.args");
}
@TestMetadata("inheritorOfExpectSealedClass.args")
public void testInheritorOfExpectSealedClass() throws Exception {
runTest("compiler/testData/cli/metadata/inheritorOfExpectSealedClass.args");
@@ -1653,10 +1658,5 @@ public class CliTestGenerated extends AbstractCliTest {
public void testOptionalExpectationUsageWithFir() throws Exception {
runTest("compiler/testData/cli/metadata/optionalExpectationUsageWithFir.args");
}
@TestMetadata("successfulHmpp.args")
public void testSuccessfulHmpp() throws Exception {
runTest("compiler/testData/cli/metadata/successfulHmpp.args");
}
}
}