diff --git a/compiler/testData/codegen/box/inlineClasses/checkPlusOfUInt.kt b/compiler/testData/codegen/box/inlineClasses/checkPlusOfUInt.kt new file mode 100644 index 00000000000..5a3a02a13c9 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/checkPlusOfUInt.kt @@ -0,0 +1,11 @@ +// !LANGUAGE: +InlineClasses +// !SKIP_METADATA_VERSION_CHECK +// WITH_UNSIGNED + +@Suppress("INVISIBLE_MEMBER") +fun box(): String { + val u1 = UInt(1) + val u2 = UInt(2) + val u3 = u1 + u2 + return if (u3.toInt() == 3) "OK" else "fail" +} \ No newline at end of file diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/CompilerTestLanguageVersionSettings.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/CompilerTestLanguageVersionSettings.kt index 12741325026..2bf59a94493 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/CompilerTestLanguageVersionSettings.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/CompilerTestLanguageVersionSettings.kt @@ -19,6 +19,7 @@ const val EXPERIMENTAL_DIRECTIVE = "EXPERIMENTAL" const val USE_EXPERIMENTAL_DIRECTIVE = "USE_EXPERIMENTAL" const val IGNORE_DATA_FLOW_IN_ASSERT_DIRECTIVE = "IGNORE_DATA_FLOW_IN_ASSERT" const val JVM_DEFAULT_MODE = "JVM_DEFAULT_MODE" +const val SKIP_METADATA_VERSION_CHECK = "SKIP_METADATA_VERSION_CHECK" data class CompilerTestLanguageVersionSettings( private val initialLanguageFeatures: Map, @@ -52,6 +53,7 @@ fun parseLanguageVersionSettings(directiveMap: Map): LanguageVer val useExperimental = directiveMap[USE_EXPERIMENTAL_DIRECTIVE]?.split(' ')?.let { AnalysisFlag.useExperimental to it } val ignoreDataFlowInAssert = AnalysisFlag.ignoreDataFlowInAssert to directiveMap.containsKey(IGNORE_DATA_FLOW_IN_ASSERT_DIRECTIVE) val enableJvmDefault = directiveMap[JVM_DEFAULT_MODE]?.let { AnalysisFlag.jvmDefaultMode to JvmDefaultMode.fromStringOrNull(it)!! } + val skipMetadataVersionCheck = AnalysisFlag.skipMetadataVersionCheck to directiveMap.containsKey(SKIP_METADATA_VERSION_CHECK) if (apiVersionString == null && languageFeaturesString == null && experimental == null && useExperimental == null && !ignoreDataFlowInAssert.second) return null @@ -64,7 +66,11 @@ fun parseLanguageVersionSettings(directiveMap: Map): LanguageVer return CompilerTestLanguageVersionSettings( languageFeatures, apiVersion, languageVersion, - mapOf(*listOfNotNull(experimental, useExperimental, enableJvmDefault, ignoreDataFlowInAssert).toTypedArray()) + mapOf( + *listOfNotNull( + experimental, useExperimental, enableJvmDefault, ignoreDataFlowInAssert, skipMetadataVersionCheck + ).toTypedArray() + ) ) } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java index 61a1aad8024..d15210255cc 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java @@ -410,13 +410,29 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { @NotNull protected GeneratedClassLoader createClassLoader() { + ClassLoader classLoader; + if (configurationKind.getWithReflection() && configurationKind.getWithCoroutines()) { + classLoader = ForTestCompileRuntime.reflectAndCoroutinesJarClassLoader(); + } + else if (configurationKind.getWithUnsignedTypes() && configurationKind.getWithReflection()) { + classLoader = ForTestCompileRuntime.reflectAndUnsignedTypesJarClassLoader(); + } + else if (configurationKind.getWithReflection()) { + classLoader = ForTestCompileRuntime.runtimeAndReflectJarClassLoader(); + } + else if (configurationKind.getWithCoroutines()) { + classLoader = ForTestCompileRuntime.runtimeAndCoroutinesJarClassLoader(); + } + else if (configurationKind.getWithUnsignedTypes()) { + classLoader = ForTestCompileRuntime.runtimeAndUnsignedTypesJarClassLoader(); + } + else { + classLoader = ForTestCompileRuntime.runtimeJarClassLoader(); + } + return new GeneratedClassLoader( generateClassesInFile(), - configurationKind.getWithReflection() - ? ForTestCompileRuntime.runtimeAndReflectJarClassLoader() - : configurationKind.getWithCoroutines() - ? ForTestCompileRuntime.runtimeAndCoroutinesJarClassLoader() - : ForTestCompileRuntime.runtimeJarClassLoader(), + classLoader, getClassPathURLs() ); } @@ -671,6 +687,9 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { if (configurationKind.getWithCoroutines()) { javaClasspath.add(ForTestCompileRuntime.coroutinesJarForTests().getPath()); } + if (configurationKind.getWithUnsignedTypes()) { + javaClasspath.add(ForTestCompileRuntime.unsignedTypesJarForTests().getPath()); + } javaClassesOutputDirectory = CodegenTestUtil.compileJava( findJavaSourcesInDirectory(javaSourceDir), javaClasspath, javacOptions @@ -683,6 +702,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { boolean addRuntime = false; boolean addReflect = false; boolean addCoroutines = false; + boolean addUnsignedTypes = false; for (TestFile file : files) { if (InTextDirectivesUtils.isDirectiveDefined(file.content, "COMMON_COROUTINES_TEST")) { addCoroutines = true; @@ -693,11 +713,16 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { if (InTextDirectivesUtils.isDirectiveDefined(file.content, "WITH_REFLECT")) { addReflect = true; } + if (InTextDirectivesUtils.isDirectiveDefined(file.content, "WITH_UNSIGNED")) { + addUnsignedTypes = true; + } } - return (addReflect && addCoroutines) ? ConfigurationKind.ALL : + return (addReflect && addCoroutines && addUnsignedTypes) ? ConfigurationKind.ALL : + (addReflect && addCoroutines) ? ConfigurationKind.WITH_COROUTINES_AND_REFLECT : addReflect ? ConfigurationKind.WITH_REFLECT : addCoroutines ? ConfigurationKind.WITH_COROUTINES : + addUnsignedTypes ? ConfigurationKind.WITH_UNSIGNED_TYPES : addRuntime ? ConfigurationKind.NO_KOTLIN_REFLECT : ConfigurationKind.JDK_ONLY; } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java index b754f25fdcc..e8c73b64734 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java @@ -20,6 +20,9 @@ public class ForTestCompileRuntime { private static volatile SoftReference reflectJarClassLoader = new SoftReference<>(null); private static volatile SoftReference runtimeJarClassLoader = new SoftReference<>(null); private static volatile SoftReference coroutinesJarClassLoader = new SoftReference<>(null); + private static volatile SoftReference unsignedTypesJarClassLoader = new SoftReference<>(null); + private static volatile SoftReference unsignedTypesAndReflectJarClassLoader = new SoftReference<>(null); + private static volatile SoftReference coroutinesAndReflectJarClassLoader = new SoftReference<>(null); @NotNull public static File runtimeJarForTests() { @@ -31,6 +34,11 @@ public class ForTestCompileRuntime { return assertExists(new File("dist/kotlin-stdlib-coroutines.jar")); } + @NotNull + public static File unsignedTypesJarForTests() { + return assertExists(new File("dist/kotlin-stdlib-unsigned.jar")); + } + @NotNull public static File minimalRuntimeJarForTests() { return assertExists(new File("dist/kotlin-stdlib-minimal-for-test.jar")); @@ -105,6 +113,42 @@ public class ForTestCompileRuntime { return loader; } + @NotNull + public static synchronized ClassLoader runtimeAndUnsignedTypesJarClassLoader() { + ClassLoader loader = unsignedTypesJarClassLoader.get(); + if (loader == null) { + loader = createClassLoader(runtimeJarForTests(), unsignedTypesJarForTests(), scriptRuntimeJarForTests(), kotlinTestJarForTests()); + unsignedTypesJarClassLoader = new SoftReference<>(loader); + } + return loader; + } + + @NotNull + public static synchronized ClassLoader reflectAndUnsignedTypesJarClassLoader() { + ClassLoader loader = unsignedTypesAndReflectJarClassLoader.get(); + if (loader == null) { + loader = createClassLoader( + runtimeJarForTests(), reflectJarForTests(), unsignedTypesJarForTests(), + scriptRuntimeJarForTests(), kotlinTestJarForTests() + ); + unsignedTypesAndReflectJarClassLoader = new SoftReference<>(loader); + } + return loader; + } + + @NotNull + public static synchronized ClassLoader reflectAndCoroutinesJarClassLoader() { + ClassLoader loader = coroutinesAndReflectJarClassLoader.get(); + if (loader == null) { + loader = createClassLoader( + runtimeJarForTests(), reflectJarForTests(), coroutinesJarForTests(), + scriptRuntimeJarForTests(), kotlinTestJarForTests() + ); + coroutinesAndReflectJarClassLoader = new SoftReference<>(loader); + } + return loader; + } + @NotNull public static synchronized ClassLoader runtimeJarClassLoader() { ClassLoader loader = runtimeJarClassLoader.get(); diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/ConfigurationKind.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/test/ConfigurationKind.kt index a8afa9d8c33..b6cb4895b27 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/ConfigurationKind.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/ConfigurationKind.kt @@ -9,7 +9,8 @@ enum class ConfigurationKind( val withRuntime: Boolean = false, val withMockRuntime: Boolean = false, val withReflection: Boolean = false, - val withCoroutines: Boolean = false + val withCoroutines: Boolean = false, + val withUnsignedTypes: Boolean = false ) { /** JDK without any kotlin runtime */ JDK_NO_RUNTIME(), @@ -19,8 +20,12 @@ enum class ConfigurationKind( NO_KOTLIN_REFLECT(withRuntime = true), /** JDK + kotlin runtime + coroutines */ WITH_COROUTINES(withCoroutines = true, withRuntime = true), + /** JDK + kotlin runtime + unsigned types */ + WITH_UNSIGNED_TYPES(withUnsignedTypes = true, withRuntime = true, withReflection = true), /** JDK + kotlin runtime + kotlin reflection */ WITH_REFLECT(withRuntime = true, withReflection = true), - /** JDK + kotlin runtime + kotlin reflection + coroutines*/ - ALL(withRuntime = true, withReflection = true, withCoroutines = true) + /** JDK + kotlin runtime + kotlin reflection + coroutines */ + WITH_COROUTINES_AND_REFLECT(withRuntime = true, withReflection = true, withCoroutines = true), + /** JDK + kotlin runtime + kotlin reflection + coroutines + unsigned types */ + ALL(withRuntime = true, withReflection = true, withCoroutines = true, withUnsignedTypes = true) } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java index 64d58f9ce1b..2ee9411a121 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -576,6 +576,9 @@ public class KotlinTestUtils { if (configurationKind.getWithCoroutines()) { JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.coroutinesJarForTests()); } + if (configurationKind.getWithUnsignedTypes()) { + JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.unsignedTypesJarForTests()); + } if (configurationKind.getWithRuntime()) { JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.runtimeJarForTests()); JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.scriptRuntimeJarForTests()); diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.173 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.173 index c6d5f1b4edc..7dd9d09b40a 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.173 +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.173 @@ -576,6 +576,9 @@ public class KotlinTestUtils { if (configurationKind.getWithCoroutines()) { JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.coroutinesJarForTests()); } + if (configurationKind.getWithUnsignedTypes()) { + JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.unsignedTypesJarForTests()); + } if (configurationKind.getWithRuntime()) { JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.runtimeJarForTests()); JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.scriptRuntimeJarForTests()); diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as31 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as31 index 519dc51dd80..6324eea22ca 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as31 +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as31 @@ -576,6 +576,9 @@ public class KotlinTestUtils { if (configurationKind.getWithCoroutines()) { JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.coroutinesJarForTests()); } + if (configurationKind.getWithUnsignedTypes()) { + JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.unsignedTypesJarForTests()); + } if (configurationKind.getWithRuntime()) { JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.runtimeJarForTests()); JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.scriptRuntimeJarForTests()); diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 index 56752f08643..48d67b01ee3 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 @@ -576,6 +576,9 @@ public class KotlinTestUtils { if (configurationKind.getWithCoroutines()) { JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.coroutinesJarForTests()); } + if (configurationKind.getWithUnsignedTypes()) { + JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.unsignedTypesJarForTests()); + } if (configurationKind.getWithRuntime()) { JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.runtimeJarForTests()); JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.scriptRuntimeJarForTests()); diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 026d96f108b..2399fbf90ea 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -11224,6 +11224,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/checkLambdaWithInlineClassesInFunctionalType.kt"); } + @TestMetadata("checkPlusOfUInt.kt") + public void testCheckPlusOfUInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/checkPlusOfUInt.kt"); + } + @TestMetadata("checkUnboxingResultFromTypeVariable.kt") public void testCheckUnboxingResultFromTypeVariable() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/checkUnboxingResultFromTypeVariable.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 4b2295a8be6..c3a167678ab 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -11224,6 +11224,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/checkLambdaWithInlineClassesInFunctionalType.kt"); } + @TestMetadata("checkPlusOfUInt.kt") + public void testCheckPlusOfUInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/checkPlusOfUInt.kt"); + } + @TestMetadata("checkUnboxingResultFromTypeVariable.kt") public void testCheckUnboxingResultFromTypeVariable() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/checkUnboxingResultFromTypeVariable.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index b8f28b55c20..b8523b4d25c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -11224,6 +11224,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/checkLambdaWithInlineClassesInFunctionalType.kt"); } + @TestMetadata("checkPlusOfUInt.kt") + public void testCheckPlusOfUInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/checkPlusOfUInt.kt"); + } + @TestMetadata("checkUnboxingResultFromTypeVariable.kt") public void testCheckUnboxingResultFromTypeVariable() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/checkUnboxingResultFromTypeVariable.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index b47ed4ff611..ea49fe89c6f 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -9760,6 +9760,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/checkLambdaWithInlineClassesInFunctionalType.kt"); } + @TestMetadata("checkPlusOfUInt.kt") + public void testCheckPlusOfUInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/checkPlusOfUInt.kt"); + } + @TestMetadata("checkUnboxingResultFromTypeVariable.kt") public void testCheckUnboxingResultFromTypeVariable() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/checkUnboxingResultFromTypeVariable.kt");