[K/JS] Throw error when a module contains file with the same name and package (ignoring case)
This commit is contained in:
+16
-1
@@ -15,9 +15,24 @@ import org.jetbrains.kotlin.ir.declarations.path
|
||||
private const val EXPORTER_FILE_POSTFIX = ".export"
|
||||
|
||||
class ModuleFragmentToExternalName(private val jsOutputNamesMapping: Map<IrModuleFragment, String>) {
|
||||
private val externalNameToItsFile = hashMapOf<String, IrFile>()
|
||||
|
||||
fun getExternalNameFor(file: IrFile, granularity: JsGenerationGranularity): String {
|
||||
assert(granularity == JsGenerationGranularity.PER_FILE) { "This method should be used only for PER_FILE granularity" }
|
||||
return file.module.getJsOutputName().getExternalModuleNameForPerFile(file)
|
||||
return file.module.getJsOutputName().getExternalModuleNameForPerFile(file).also {
|
||||
val alreadyReservedBy = externalNameToItsFile.putIfAbsent(it.lowercase(), file)
|
||||
|
||||
if (alreadyReservedBy != null && alreadyReservedBy != file) {
|
||||
error(
|
||||
"""
|
||||
|There are two files in module '${file.module.name}' that have the similar package and file names.
|
||||
| - Package "${file.packageFqName.asString()}" and path "${file.path}"
|
||||
| - Package "${alreadyReservedBy.packageFqName.asString()}" and path "${alreadyReservedBy.path}"
|
||||
|Note, that if the difference is only in letter cases, it also could lead to a clash of the compiled artifacts
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getExternalNameForExporterFile(file: IrFile, granularity: JsGenerationGranularity): String {
|
||||
|
||||
Reference in New Issue
Block a user