JS: error message (not exception) for incompatible abi version during compilation
This commit is contained in:
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.psi.JetFile;
|
||||
import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil;
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadata;
|
||||
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -146,6 +147,9 @@ public abstract class Config {
|
||||
}
|
||||
|
||||
private ModuleDescriptorImpl createModuleDescriptor(KotlinJavascriptMetadata metadata) {
|
||||
assert metadata.getIsAbiVersionCompatible() :
|
||||
"expected abi version " + KotlinJavascriptMetadataUtils.ABI_VERSION + ", but metadata.abiVersion = " + metadata.getAbiVersion();
|
||||
|
||||
ModuleDescriptorImpl moduleDescriptor = new ModuleDescriptorImpl(
|
||||
Name.special("<" + metadata.getModuleName() + ">"), storageManager,
|
||||
TopDownAnalyzerFacadeForJS.JS_MODULE_PARAMETERS
|
||||
|
||||
@@ -40,7 +40,6 @@ import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.kotlin.utils.LibraryUtils.isKotlinJavascriptLibraryWithMetadata;
|
||||
import static org.jetbrains.kotlin.utils.LibraryUtils.isOldKotlinJavascriptLibrary;
|
||||
import static org.jetbrains.kotlin.utils.PathUtil.getKotlinPathsForDistDirectory;
|
||||
|
||||
@@ -161,12 +160,21 @@ public class LibrarySourcesConfig extends Config {
|
||||
if (isOldKotlinJavascriptLibrary(filePath)) {
|
||||
moduleName = LibraryUtils.getKotlinJsModuleName(filePath);
|
||||
}
|
||||
else if (isKotlinJavascriptLibraryWithMetadata(filePath)) {
|
||||
moduleName = null;
|
||||
}
|
||||
else {
|
||||
report.invoke("'" + path + "' is not a valid Kotlin Javascript library");
|
||||
return true;
|
||||
List<KotlinJavascriptMetadata> metadataList = KotlinJavascriptMetadataUtils.loadMetadata(filePath);
|
||||
if (metadataList.isEmpty()) {
|
||||
report.invoke("'" + path + "' is not a valid Kotlin Javascript library");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (KotlinJavascriptMetadata metadata : metadataList) {
|
||||
if (!metadata.getIsAbiVersionCompatible()) {
|
||||
report.invoke("File '" + path + "' was compiled with an incompatible version of Kotlin. Its ABI version is " + metadata.getAbiVersion() + ", expected ABI version is " + KotlinJavascriptMetadataUtils.ABI_VERSION);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
moduleName = null;
|
||||
}
|
||||
|
||||
if (action != null) {
|
||||
|
||||
Reference in New Issue
Block a user