Drop deprecated -Xexperimental flag from compiler and tests

This commit is contained in:
Mikhail Glukhikh
2021-07-12 19:37:16 +03:00
committed by teamcityserver
parent cbcec8d624
commit 113d2653aa
45 changed files with 25 additions and 344 deletions
@@ -27,24 +27,16 @@ import org.jetbrains.annotations.TestOnly;
import org.jetbrains.kotlin.backend.common.output.OutputFile;
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.config.AnalysisFlags;
import org.jetbrains.kotlin.config.JvmAnalysisFlags;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.DescriptorUtilKt;
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.load.kotlin.ModuleMappingUtilKt;
import org.jetbrains.kotlin.metadata.ProtoBuf;
import org.jetbrains.kotlin.metadata.jvm.JvmModuleProtoBuf;
import org.jetbrains.kotlin.metadata.jvm.deserialization.ModuleMapping;
import org.jetbrains.kotlin.metadata.jvm.deserialization.ModuleMappingKt;
import org.jetbrains.kotlin.metadata.jvm.deserialization.PackageParts;
import org.jetbrains.kotlin.metadata.serialization.StringTable;
import org.jetbrains.kotlin.name.ClassId;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.kotlin.serialization.StringTableImpl;
import org.jetbrains.org.objectweb.asm.Type;
@@ -52,7 +44,6 @@ import org.jetbrains.org.objectweb.asm.Type;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.getMappingFileName;
@@ -134,11 +125,6 @@ public class ClassFileFactory implements OutputFileCollection {
StringTableImpl stringTable = new StringTableImpl();
ClassFileUtilsKt.addDataFromCompiledModule(builder, packagePartRegistry, stringTable, state);
List<String> experimental = state.getLanguageVersionSettings().getFlag(AnalysisFlags.getExperimental());
if (!experimental.isEmpty()) {
writeExperimentalMarkers(state.getModule(), builder, experimental, stringTable);
}
Pair<ProtoBuf.StringTable, ProtoBuf.QualifiedNameTable> tables = stringTable.buildProto();
builder.setStringTable(tables.getFirst());
builder.setQualifiedNameTable(tables.getSecond());
@@ -162,26 +148,6 @@ public class ClassFileFactory implements OutputFileCollection {
});
}
private static void writeExperimentalMarkers(
@NotNull ModuleDescriptor module,
@NotNull JvmModuleProtoBuf.Module.Builder builder,
@NotNull List<String> experimental,
@NotNull StringTable stringTable
) {
for (String fqName : experimental) {
ClassDescriptor descriptor =
DescriptorUtilKt.resolveClassByFqName(module, new FqName(fqName), NoLookupLocation.FOR_ALREADY_TRACKED);
if (descriptor != null) {
ProtoBuf.Annotation.Builder annotation = ProtoBuf.Annotation.newBuilder();
ClassId classId = DescriptorUtilsKt.getClassId(descriptor);
if (classId != null) {
annotation.setId(stringTable.getQualifiedClassNameIndex(classId.asString(), false));
builder.addAnnotation(annotation);
}
}
}
}
@NotNull
@Override
public List<OutputFile> asList() {
@@ -167,13 +167,6 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
var readDeserializedContracts: Boolean by FreezableVar(false)
@Argument(
value = "-Xexperimental",
valueDescription = "<fq.name>",
description = "Enable and propagate usages of experimental API for marker annotation with the given fully qualified name"
)
var experimental: Array<String>? by FreezableVar(null)
@Argument(
value = "-Xuse-experimental",
valueDescription = "<fq.name>",
@@ -387,11 +380,6 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck)
put(AnalysisFlags.skipPrereleaseCheck, skipPrereleaseCheck || skipMetadataVersionCheck)
put(AnalysisFlags.multiPlatformDoNotCheckActual, noCheckActual)
val experimentalFqNames = experimental?.toList().orEmpty()
if (experimentalFqNames.isNotEmpty()) {
put(AnalysisFlags.experimental, experimentalFqNames)
collector.report(WARNING, "'-Xexperimental' is deprecated and will be removed in a future release")
}
val useExperimentalFqNames = useExperimental?.toList().orEmpty()
if (useExperimentalFqNames.isNotEmpty()) {
collector.report(
@@ -18,9 +18,6 @@ object AnalysisFlags {
@JvmStatic
val expectActualLinker by AnalysisFlag.Delegates.Boolean
@JvmStatic
val experimental by AnalysisFlag.Delegates.ListOfStrings
@JvmStatic
val useExperimental by AnalysisFlag.Delegates.ListOfStrings
@@ -34543,12 +34543,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalIsNotEnabled.kt");
}
@Test
@TestMetadata("experimentalOnWholeModule.kt")
public void testExperimentalOnWholeModule() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalOnWholeModule.kt");
}
@Test
@TestMetadata("fullFqNameUsage.kt")
public void testFullFqNameUsage() throws Exception {
@@ -34543,12 +34543,6 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalIsNotEnabled.kt");
}
@Test
@TestMetadata("experimentalOnWholeModule.kt")
public void testExperimentalOnWholeModule() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalOnWholeModule.kt");
}
@Test
@TestMetadata("fullFqNameUsage.kt")
public void testFullFqNameUsage() throws Exception {
@@ -272,8 +272,7 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
languageVersionSettings: LanguageVersionSettings,
bindingContext: BindingContext
): Boolean =
annotationFqName.asString() in languageVersionSettings.getFlag(AnalysisFlags.experimental) ||
annotationFqName.asString() in languageVersionSettings.getFlag(AnalysisFlags.useExperimental) ||
annotationFqName.asString() in languageVersionSettings.getFlag(AnalysisFlags.useExperimental) ||
anyParentMatches { element ->
element.isDeclarationAnnotatedWith(annotationFqName, bindingContext) ||
element.isElementAnnotatedWithUseExperimentalOf(annotationFqName, bindingContext)
@@ -348,13 +347,10 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
return true
}
val validExperimental = languageVersionSettings.getFlag(AnalysisFlags.experimental).filter(::checkAnnotation)
val validUseExperimental = languageVersionSettings.getFlag(AnalysisFlags.useExperimental).filter { fqName ->
fqName == REQUIRES_OPT_IN_FQ_NAME.asString() || fqName == OLD_EXPERIMENTAL_FQ_NAME.asString() || checkAnnotation(fqName)
}
for (fqName in validExperimental.intersect(validUseExperimental)) {
reportError("'-Xopt-in=$fqName' has no effect because '-Xexperimental=$fqName' is used")
languageVersionSettings.getFlag(AnalysisFlags.useExperimental).forEach { fqName ->
if (fqName != REQUIRES_OPT_IN_FQ_NAME.asString() && fqName != OLD_EXPERIMENTAL_FQ_NAME.asString()) {
checkAnnotation(fqName)
}
}
}
}
@@ -8,11 +8,9 @@ package org.jetbrains.kotlin.backend.common.serialization.metadata
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.backend.common.serialization.isExpectMember
import org.jetbrains.kotlin.backend.common.serialization.isSerializableExpectClass
import org.jetbrains.kotlin.config.AnalysisFlags
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
@@ -22,7 +20,6 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.serialization.ApproximatingStringTable
import org.jetbrains.kotlin.serialization.DescriptorSerializer
import org.jetbrains.kotlin.serialization.StringTableImpl
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor
@@ -264,19 +261,6 @@ abstract class KlibMetadataSerializer(
header.flags = 1
}
val experimentalAnnotationFqNames = languageVersionSettings.getFlag(AnalysisFlags.experimental)
if (experimentalAnnotationFqNames.isNotEmpty()) {
val stringTable = StringTableImpl()
for (fqName in experimentalAnnotationFqNames) {
val descriptor = moduleDescriptor.resolveClassByFqName(FqName(fqName), NoLookupLocation.FOR_ALREADY_TRACKED) ?: continue
header.addAnnotation(ProtoBuf.Annotation.newBuilder().apply {
id = stringTable.getFqNameIndex(descriptor)
})
}
val (strings, qualifiedNames) = stringTable.buildProto()
header.strings = strings
header.qualifiedNames = qualifiedNames
}
fragmentNames.forEach {
header.addPackageFragmentName(it)
}
@@ -63,7 +63,6 @@ class LanguageVersionSettingsBuilder {
}
val analysisFlags = listOfNotNull(
analysisFlag(AnalysisFlags.experimental, directives[LanguageSettingsDirectives.EXPERIMENTAL].takeIf { it.isNotEmpty() }),
analysisFlag(AnalysisFlags.useExperimental, directives[LanguageSettingsDirectives.USE_EXPERIMENTAL].takeIf { it.isNotEmpty() }),
analysisFlag(AnalysisFlags.ignoreDataFlowInAssert, trueOrNull(LanguageSettingsDirectives.IGNORE_DATA_FLOW_IN_ASSERT in directives)),
analysisFlag(AnalysisFlags.constraintSystemForOverloadResolution, directives.singleOrZeroValue(LanguageSettingsDirectives.CONSTRAINT_SYSTEM_FOR_OVERLOAD_RESOLUTION)),
-1
View File
@@ -50,7 +50,6 @@ where advanced options include:
-Xdump-perf=<path> Dump detailed performance statistics to the specified file
-Xeffect-system Enable experimental language feature: effect system
-Xexpect-actual-linker Enable experimental expect/actual linker
-Xexperimental=<fq.name> Enable and propagate usages of experimental API for marker annotation with the given fully qualified name
-Xexplicit-api={strict|warning|disable}
Force compiler to report errors on all public API declarations without explicit visibility or return type.
Use 'warning' level to issue warnings instead of errors.
@@ -1,8 +0,0 @@
$TESTDATA_DIR$/experimentalAndUseExperimentalWithSameAnnotation.kt
-d
$TEMP_DIR$
-opt-in
kotlin.RequiresOptIn
-opt-in
org.test.ExperimentalAPI
-Xexperimental=org.test.ExperimentalAPI
@@ -1,4 +0,0 @@
package org.test
@RequiresOptIn
annotation class ExperimentalAPI
@@ -1,2 +0,0 @@
error: '-Xopt-in=org.test.ExperimentalAPI' has no effect because '-Xexperimental=org.test.ExperimentalAPI' is used
COMPILATION_ERROR
+2 -4
View File
@@ -2,7 +2,5 @@ $TESTDATA_DIR$/experimentalDeprecated.kt
-d
$TEMP_DIR$
-opt-in=kotlin.RequiresOptIn
-Xexperimental=org.test.Error1
-Xexperimental=org.test.Hidden1
-opt-in=org.test.Error2
-opt-in=org.test.Hidden2
-opt-in=org.test.Error
-opt-in=org.test.Hidden
+4 -12
View File
@@ -1,17 +1,9 @@
package org.test
@Deprecated("Error1", level = DeprecationLevel.ERROR)
@Deprecated("Error", level = DeprecationLevel.ERROR)
@RequiresOptIn
annotation class Error1
annotation class Error
@Deprecated("Error2", level = DeprecationLevel.ERROR)
@Deprecated("Hidden", level = DeprecationLevel.HIDDEN)
@RequiresOptIn
annotation class Error2
@Deprecated("Hidden1", level = DeprecationLevel.HIDDEN)
@RequiresOptIn
annotation class Hidden1
@Deprecated("Hidden2", level = DeprecationLevel.HIDDEN)
@RequiresOptIn
annotation class Hidden2
annotation class Hidden
+2 -4
View File
@@ -1,5 +1,3 @@
error: opt-in requirement marker org.test.Error1 is deprecated. Error1
error: opt-in requirement marker org.test.Hidden1 is deprecated. Hidden1
error: opt-in requirement marker org.test.Error2 is deprecated. Error2
error: opt-in requirement marker org.test.Hidden2 is deprecated. Hidden2
error: opt-in requirement marker org.test.Error is deprecated. Error
error: opt-in requirement marker org.test.Hidden is deprecated. Hidden
COMPILATION_ERROR
@@ -3,6 +3,5 @@ $TESTDATA_DIR$/experimentalDeprecatedWarning.kt
$TEMP_DIR$
-Xopt-in=kotlin.RequiresOptIn
-opt-in=kotlin.RequiresOptIn
-opt-in=org.test.Warning1
-Xexperimental=org.test.Warning2
-opt-in=org.test.Warning
-Xuse-experimental=org.test.OneMore
+2 -7
View File
@@ -1,14 +1,9 @@
package org.test
@Deprecated("Warning1", level = DeprecationLevel.WARNING)
@Deprecated("Warning", level = DeprecationLevel.WARNING)
@RequiresOptIn
@Retention(AnnotationRetention.BINARY)
annotation class Warning1
@Deprecated("Warning2", level = DeprecationLevel.WARNING)
@RequiresOptIn
@Retention(AnnotationRetention.BINARY)
annotation class Warning2
annotation class Warning
@RequiresOptIn
annotation class OneMore
@@ -1,5 +1,3 @@
warning: '-Xexperimental' is deprecated and will be removed in a future release
warning: '-Xuse-experimental' is deprecated and will be removed in a future release, please use -opt-in instead
warning: opt-in requirement marker org.test.Warning2 is deprecated. Warning2
warning: opt-in requirement marker org.test.Warning1 is deprecated. Warning1
warning: opt-in requirement marker org.test.Warning is deprecated. Warning
OK
+2 -1
View File
@@ -1,5 +1,6 @@
$TESTDATA_DIR$/experimentalIsNotAnnotation.kt
-d
$TEMP_DIR$
-Xexperimental=org.test.NotAnAnnotation1
-opt-in
org.test.NotAnAnnotation1
-opt-in=org.test.NotAnAnnotation2
@@ -1,4 +1,3 @@
warning: '-Xexperimental' is deprecated and will be removed in a future release
warning: class org.test.NotAnAnnotation1 is not an opt-in requirement marker
warning: class org.test.NotAnAnnotation2 is not an opt-in requirement marker
OK
+1 -2
View File
@@ -1,5 +1,4 @@
$TESTDATA_DIR$/experimentalIsNotMarker.kt
-d
$TEMP_DIR$
-Xexperimental=org.test.NotAMarker1
-opt-in=org.test.NotAMarker2
-opt-in=org.test.NotAMarker
+1 -2
View File
@@ -1,4 +1,3 @@
package org.test
annotation class NotAMarker1
annotation class NotAMarker2
annotation class NotAMarker
+1 -3
View File
@@ -1,4 +1,2 @@
warning: '-Xexperimental' is deprecated and will be removed in a future release
warning: class org.test.NotAMarker1 is not an opt-in requirement marker
warning: class org.test.NotAMarker2 is not an opt-in requirement marker
warning: class org.test.NotAMarker is not an opt-in requirement marker
OK
+1 -1
View File
@@ -2,4 +2,4 @@ $TESTDATA_DIR$/experimentalNested.kt
-d
$TEMP_DIR$
-opt-in=kotlin.RequiresOptIn
-Xexperimental=org.test.Outer.Nested
-opt-in=org.test.Outer.Nested
-1
View File
@@ -1,2 +1 @@
warning: '-Xexperimental' is deprecated and will be removed in a future release
OK
+1 -2
View File
@@ -4,6 +4,5 @@ $TEMP_DIR$
-opt-in
org.test.Unresolved1
-opt-in
org.test.Unresolved3
-Xexperimental=org.test.Unresolved2
org.test.Unresolved2
+1 -3
View File
@@ -1,5 +1,3 @@
warning: '-Xexperimental' is deprecated and will be removed in a future release
warning: opt-in requirement marker org.test.Unresolved2 is unresolved. Please make sure it's present in the module dependencies
warning: opt-in requirement marker org.test.Unresolved1 is unresolved. Please make sure it's present in the module dependencies
warning: opt-in requirement marker org.test.Unresolved3 is unresolved. Please make sure it's present in the module dependencies
warning: opt-in requirement marker org.test.Unresolved2 is unresolved. Please make sure it's present in the module dependencies
OK
-1
View File
@@ -160,7 +160,6 @@ where advanced options include:
-Xdump-perf=<path> Dump detailed performance statistics to the specified file
-Xeffect-system Enable experimental language feature: effect system
-Xexpect-actual-linker Enable experimental expect/actual linker
-Xexperimental=<fq.name> Enable and propagate usages of experimental API for marker annotation with the given fully qualified name
-Xexplicit-api={strict|warning|disable}
Force compiler to report errors on all public API declarations without explicit visibility or return type.
Use 'warning' level to issue warnings instead of errors.
@@ -1,25 +0,0 @@
// FIR_IDENTICAL
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
// !EXPERIMENTAL: api.ExperimentalAPI
// MODULE: api
// FILE: api.kt
package api
@RequiresOptIn
@Retention(AnnotationRetention.BINARY)
annotation class ExperimentalAPI
@ExperimentalAPI
fun function(): String = ""
// MODULE: usage(api)
// FILE: usage.kt
package usage
import api.*
fun use() {
function()
}
@@ -1,21 +0,0 @@
// -- Module: <api> --
package
package api {
@api.ExperimentalAPI public fun function(): kotlin.String
@kotlin.RequiresOptIn @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) public final annotation class ExperimentalAPI : kotlin.Annotation {
public constructor ExperimentalAPI()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
// -- Module: <usage> --
package
package usage {
public fun use(): kotlin.Unit
}
@@ -1,8 +0,0 @@
package lib
@RequiresOptIn
annotation class ExperimentalAPI
class Foo
fun bar() {}
@@ -1,7 +0,0 @@
compiler/testData/experimental/jsExperimentalModule/usage.kt:5:15: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@OptIn(lib.ExperimentalAPI::class)'
fun fail(foo: Foo) {
^
compiler/testData/experimental/jsExperimentalModule/usage.kt:6:5: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@OptIn(lib.ExperimentalAPI::class)'
bar()
^
COMPILATION_ERROR
@@ -1,12 +0,0 @@
package usage
import lib.*
fun fail(foo: Foo) {
bar()
}
@ExperimentalAPI
fun ok(foo: Foo) {
bar()
}
@@ -1,8 +0,0 @@
package lib
@RequiresOptIn
annotation class ExperimentalAPI
class Foo
fun bar() {}
@@ -1,7 +0,0 @@
compiler/testData/experimental/jvmExperimentalModule/usage.kt:5:15: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@OptIn(lib.ExperimentalAPI::class)'
fun fail(foo: Foo) {
^
compiler/testData/experimental/jvmExperimentalModule/usage.kt:6:5: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@OptIn(lib.ExperimentalAPI::class)'
bar()
^
COMPILATION_ERROR
@@ -1,12 +0,0 @@
package usage
import lib.*
fun fail(foo: Foo) {
bar()
}
@ExperimentalAPI
fun ok(foo: Foo) {
bar()
}
-12
View File
@@ -1,12 +0,0 @@
package org.foo
@RequiresOptIn
annotation class A
class B {
@RequiresOptIn
annotation class C
}
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
annotation class D
@@ -1,2 +0,0 @@
@org/foo/A
@org/foo/B.C
@@ -34639,12 +34639,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalIsNotEnabled.kt");
}
@Test
@TestMetadata("experimentalOnWholeModule.kt")
public void testExperimentalOnWholeModule() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalOnWholeModule.kt");
}
@Test
@TestMetadata("fullFqNameUsage.kt")
public void testFullFqNameUsage() throws Exception {
@@ -60,7 +60,6 @@ fun parseLanguageVersionSettings(directives: Directives): CompilerTestLanguageVe
val languageFeaturesString = directives[LANGUAGE_DIRECTIVE]
val analysisFlags = listOfNotNull(
analysisFlag(AnalysisFlags.experimental, directives[EXPERIMENTAL_DIRECTIVE]?.split(' ')),
analysisFlag(AnalysisFlags.useExperimental, directives[USE_EXPERIMENTAL_DIRECTIVE]?.split(' ')),
analysisFlag(JvmAnalysisFlags.jvmDefaultMode, directives[JVM_DEFAULT_MODE]?.let { JvmDefaultMode.fromStringOrNull(it) }),
analysisFlag(AnalysisFlags.ignoreDataFlowInAssert, if (IGNORE_DATA_FLOW_IN_ASSERT_DIRECTIVE in directives) true else null),
@@ -221,11 +221,6 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/emptySources.args");
}
@TestMetadata("experimentalAndUseExperimentalWithSameAnnotation.args")
public void testExperimentalAndUseExperimentalWithSameAnnotation() throws Exception {
runTest("compiler/testData/cli/jvm/experimentalAndUseExperimentalWithSameAnnotation.args");
}
@TestMetadata("experimentalDeprecated.args")
public void testExperimentalDeprecated() throws Exception {
runTest("compiler/testData/cli/jvm/experimentalDeprecated.args");
@@ -96,15 +96,4 @@ class JvmModuleProtoBufTest : KtUsefulTestCase() {
fun testJvmPackageNameMultifileClass() {
doTest("/moduleProtoBuf/jvmPackageNameMultifileClass")
}
fun testExperimental() {
doTest(
"/moduleProtoBuf/experimental", extraOptions = listOf(
"-Xopt-in=kotlin.RequiresOptIn",
"-Xexperimental=org.foo.A",
"-Xexperimental=org.foo.B.C",
"-Xopt-in=org.foo.D"
)
)
}
}
@@ -1,36 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.compiler
import org.jetbrains.kotlin.cli.js.K2JSCompiler
import java.io.File
class ExperimentalIntegrationTest : AbstractKotlinCompilerIntegrationTest() {
override val testDataPath: String
get() = "compiler/testData/experimental/"
fun testJvmExperimentalModule() {
val lib = compileLibrary(
"lib", additionalOptions = listOf(
"-Xopt-in=kotlin.RequiresOptIn",
"-Xexperimental=lib.ExperimentalAPI"
),
checkKotlinOutput = { output -> assertTrue(output, output.trimEnd().endsWith("OK")) }
)
compileKotlin("usage.kt", tmpdir, listOf(lib))
}
fun testJsExperimentalModule() {
val lib = compileJsLibrary(
"lib", additionalOptions = listOf(
"-Xopt-in=kotlin.RequiresOptIn",
"-Xexperimental=lib.ExperimentalAPI"
),
checkKotlinOutput = { output -> assertTrue(output, output.trimEnd().endsWith("OK")) }
)
compileKotlin("usage.kt", File(tmpdir, "usage.js"), listOf(lib), K2JSCompiler())
}
}
@@ -34543,12 +34543,6 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalIsNotEnabled.kt");
}
@Test
@TestMetadata("experimentalOnWholeModule.kt")
public void testExperimentalOnWholeModule() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalOnWholeModule.kt");
}
@Test
@TestMetadata("fullFqNameUsage.kt")
public void testFullFqNameUsage() throws Exception {
@@ -250,20 +250,6 @@ object KotlinJavascriptSerializationUtil {
header.flags = 1
}
val experimentalAnnotationFqNames = languageVersionSettings.getFlag(AnalysisFlags.experimental)
if (experimentalAnnotationFqNames.isNotEmpty()) {
val stringTable = StringTableImpl()
for (fqName in experimentalAnnotationFqNames) {
val descriptor = module.resolveClassByFqName(FqName(fqName), NoLookupLocation.FOR_ALREADY_TRACKED) ?: continue
header.addAnnotation(ProtoBuf.Annotation.newBuilder().apply {
id = stringTable.getFqNameIndex(descriptor)
})
}
val (strings, qualifiedNames) = stringTable.buildProto()
header.strings = strings
header.qualifiedNames = qualifiedNames
}
// TODO: write JS code binary version
return header.build()