JS: support '-Xskip-metadata-version-check' to allow pre-release libraries
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package a
|
||||||
|
|
||||||
|
open class A {
|
||||||
|
class Nested
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo() {}
|
||||||
|
var bar = 42
|
||||||
|
typealias TA = String
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
OK
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
@file:Suppress("UNUSED_VARIABLE")
|
||||||
|
package usage
|
||||||
|
|
||||||
|
import a.*
|
||||||
|
|
||||||
|
fun baz(param: A) {
|
||||||
|
val constructor = A()
|
||||||
|
val methodCall = param.hashCode()
|
||||||
|
val supertype = object : A() {}
|
||||||
|
|
||||||
|
val x = foo()
|
||||||
|
val y = bar
|
||||||
|
bar = 239
|
||||||
|
val z: TA = ""
|
||||||
|
}
|
||||||
+22
-8
@@ -316,12 +316,12 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
|||||||
KotlinTestUtils.assertEqualsToFile(new File(getTestDataDirectory(), "output.txt"), normalizeOutput(output));
|
KotlinTestUtils.assertEqualsToFile(new File(getTestDataDirectory(), "output.txt"), normalizeOutput(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private void doTestPreReleaseKotlinLibrary(
|
private void doTestPreReleaseKotlinLibrary(
|
||||||
@NotNull CLICompiler<?> compiler,
|
@NotNull CLICompiler<?> compiler,
|
||||||
@NotNull String libraryName,
|
@NotNull String libraryName,
|
||||||
@NotNull File destination,
|
@NotNull File destination,
|
||||||
@NotNull File result,
|
@NotNull File result,
|
||||||
|
@NotNull File usageDestination,
|
||||||
@NotNull String... additionalOptions
|
@NotNull String... additionalOptions
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
// Compiles the library with the "pre-release" flag, then compiles a usage of this library in the release mode
|
// Compiles the library with the "pre-release" flag, then compiles a usage of this library in the release mode
|
||||||
@@ -337,7 +337,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
|||||||
Pair<String, ExitCode> output;
|
Pair<String, ExitCode> output;
|
||||||
try {
|
try {
|
||||||
System.setProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY, "false");
|
System.setProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY, "false");
|
||||||
output = compileKotlin(compiler, "source.kt", tmpdir, Arrays.asList(additionalOptions), result);
|
output = compileKotlin(compiler, "source.kt", usageDestination, Arrays.asList(additionalOptions), result);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
System.clearProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY);
|
System.clearProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY);
|
||||||
@@ -459,19 +459,33 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
|||||||
|
|
||||||
public void testReleaseCompilerAgainstPreReleaseLibrary() throws Exception {
|
public void testReleaseCompilerAgainstPreReleaseLibrary() throws Exception {
|
||||||
File destination = new File(tmpdir, "library.jar");
|
File destination = new File(tmpdir, "library.jar");
|
||||||
doTestPreReleaseKotlinLibrary(new K2JVMCompiler(), "library", destination, destination);
|
doTestPreReleaseKotlinLibrary(new K2JVMCompiler(), "library", destination, destination, tmpdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testReleaseCompilerAgainstPreReleaseLibraryJs() throws Exception {
|
public void testReleaseCompilerAgainstPreReleaseLibraryJs() throws Exception {
|
||||||
doTestPreReleaseKotlinLibrary(new K2JSCompiler(), "library",
|
doTestPreReleaseKotlinLibrary(
|
||||||
new File(tmpdir, "library.js"),
|
new K2JSCompiler(), "library",
|
||||||
new File(tmpdir, "library.meta.js"));
|
new File(tmpdir, "library.js"), new File(tmpdir, "library.meta.js"),
|
||||||
|
new File(tmpdir, "usage.js")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testReleaseCompilerAgainstPreReleaseLibrarySkipVersionCheck() throws Exception {
|
public void testReleaseCompilerAgainstPreReleaseLibrarySkipVersionCheck() throws Exception {
|
||||||
File destination = new File(tmpdir, "library.jar");
|
File destination = new File(tmpdir, "library.jar");
|
||||||
doTestPreReleaseKotlinLibrary(new K2JVMCompiler(), "library", destination, destination,
|
doTestPreReleaseKotlinLibrary(
|
||||||
"-Xskip-metadata-version-check");
|
new K2JVMCompiler(), "library",
|
||||||
|
destination, destination, tmpdir,
|
||||||
|
"-Xskip-metadata-version-check"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReleaseCompilerAgainstPreReleaseLibraryJsSkipVersionCheck() throws Exception {
|
||||||
|
doTestPreReleaseKotlinLibrary(
|
||||||
|
new K2JSCompiler(), "library",
|
||||||
|
new File(tmpdir, "library.js"), new File(tmpdir, "library.meta.js"),
|
||||||
|
new File(tmpdir, "usage.js"),
|
||||||
|
"-Xskip-metadata-version-check"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWrongMetadataVersion() throws Exception {
|
public void testWrongMetadataVersion() throws Exception {
|
||||||
|
|||||||
+11
-6
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.AnnotationDeserializer
|
import org.jetbrains.kotlin.serialization.deserialization.AnnotationDeserializer
|
||||||
|
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializedPackageFragmentImpl
|
import org.jetbrains.kotlin.serialization.deserialization.DeserializedPackageFragmentImpl
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData
|
import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
||||||
@@ -40,8 +41,9 @@ class KotlinJavascriptPackageFragment(
|
|||||||
storageManager: StorageManager,
|
storageManager: StorageManager,
|
||||||
module: ModuleDescriptor,
|
module: ModuleDescriptor,
|
||||||
proto: ProtoBuf.PackageFragment,
|
proto: ProtoBuf.PackageFragment,
|
||||||
header: JsProtoBuf.Header
|
header: JsProtoBuf.Header,
|
||||||
) : DeserializedPackageFragmentImpl(fqName, storageManager, module, proto, JsContainerSource(fqName, header)) {
|
configuration: DeserializationConfiguration
|
||||||
|
) : DeserializedPackageFragmentImpl(fqName, storageManager, module, proto, JsContainerSource(fqName, header, configuration)) {
|
||||||
private val fileMap: Map<Int, FileHolder> by storageManager.createLazyValue {
|
private val fileMap: Map<Int, FileHolder> by storageManager.createLazyValue {
|
||||||
this.proto.getExtension(JsProtoBuf.packageFragmentFiles).fileList.withIndex().associate { (index, file) ->
|
this.proto.getExtension(JsProtoBuf.packageFragmentFiles).fileList.withIndex().associate { (index, file) ->
|
||||||
(if (file.hasId()) file.id else index) to FileHolder(file.annotationList)
|
(if (file.hasId()) file.id else index) to FileHolder(file.annotationList)
|
||||||
@@ -72,7 +74,11 @@ class KotlinJavascriptPackageFragment(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class JsContainerSource(private val fqName: FqName, private val header: JsProtoBuf.Header) : DeserializedContainerSource {
|
private class JsContainerSource(
|
||||||
|
private val fqName: FqName,
|
||||||
|
header: JsProtoBuf.Header,
|
||||||
|
configuration: DeserializationConfiguration
|
||||||
|
) : DeserializedContainerSource {
|
||||||
// TODO
|
// TODO
|
||||||
override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE
|
override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE
|
||||||
|
|
||||||
@@ -81,10 +87,9 @@ class KotlinJavascriptPackageFragment(
|
|||||||
override val incompatibility: IncompatibleVersionErrorData<*>?
|
override val incompatibility: IncompatibleVersionErrorData<*>?
|
||||||
get() = null
|
get() = null
|
||||||
|
|
||||||
override val isPreReleaseInvisible: Boolean
|
override val isPreReleaseInvisible: Boolean =
|
||||||
get() = (header.flags and 1) != 0 && !KotlinCompilerVersion.isPreRelease()
|
!configuration.skipMetadataVersionCheck && (header.flags and 1) != 0 && !KotlinCompilerVersion.isPreRelease()
|
||||||
|
|
||||||
// TODO: this is not a class
|
|
||||||
override val presentableString: String
|
override val presentableString: String
|
||||||
get() = "Package '$fqName'"
|
get() = "Package '$fqName'"
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ fun createKotlinJavascriptPackageFragmentProvider(
|
|||||||
): PackageFragmentProvider {
|
): PackageFragmentProvider {
|
||||||
val packageFragments = packageFragmentProtos.mapNotNull { proto ->
|
val packageFragments = packageFragmentProtos.mapNotNull { proto ->
|
||||||
proto.fqName?.let { fqName ->
|
proto.fqName?.let { fqName ->
|
||||||
KotlinJavascriptPackageFragment(fqName, storageManager, module, proto, header)
|
KotlinJavascriptPackageFragment(fqName, storageManager, module, proto, header, configuration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user