diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt index c7f6e56aa2a..ad62721322b 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.codegen.CodegenTestCase import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File import java.util.regex.Pattern @@ -31,8 +30,10 @@ private val packagePattern = Pattern.compile("(?m)^\\s*package[ |\t]+([\\w|\\.]* private val importPattern = Pattern.compile("import[ |\t]([\\w|]*\\.)") +private data class OldPackageAndNew(val oldFqName: FqName, val newFqName: FqName) + internal fun patchFiles( - file: File, + testFile: File, testFiles: List, filesHolder: CodegenTestsOnAndroidGenerator.FilesWriter ): FqName? { @@ -43,11 +44,11 @@ internal fun patchFiles( val ktFiles = testFiles.filter { it.name.endsWith(".kt") } if (ktFiles.isEmpty()) return null - val newPackagePrefix = file.path.replace("\\\\|-|\\.|/".toRegex(), "_") + val newPackagePrefix = testFile.path.replace("\\\\|-|\\.|/".toRegex(), "_") val oldPackage = Ref() val isSingle = testFiles.size == 1 val resultFiles = testFiles.map { - val fileName = if (isSingle) it.name else file.name.substringBeforeLast(".kt") + "/" + it.name + val fileName = if (isSingle) it.name else testFile.name.substringBeforeLast(".kt") + "/" + it.name TestClassInfo( fileName, changePackage(newPackagePrefix, it.content, oldPackage), @@ -55,21 +56,51 @@ internal fun patchFiles( getGeneratedClassName(File(fileName), it.content, newPackagePrefix, oldPackage.get()) ) } + val packages = + resultFiles.map { OldPackageAndNew(it.oldPackage, it.newClassId.parent()) }.sortedByDescending { it.oldFqName.asString().length } - /*replace all Class.forName*/ - resultFiles.forEach { - file -> - file.content = resultFiles.fold(file.content) { r, param -> - patchClassForName(param.newClassId, param.oldPackage, r) + //If files contain any val or var declaration with same name as any package name + // then use old conservative renaming scheme, otherwise use aggressive one + // with old package renaming to new one (except some cases for default package) + // Example for conservative switch: + // package foo + // ... + // val foo = .... + // class A(val foo ...) + // fun foo()= { var foo ...} + val conservativeRenameScheme = resultFiles.any { file -> + packages.any { + if (it.oldFqName.isRoot || !it.oldFqName.parent().isRoot) false + else file.content.contains("(val|var)\\s+${it.oldFqName.asString()}[^A-Za-z0-9_.]".toRegex()) } } - /*patch imports and self imports*/ - resultFiles.forEach { - file -> + if (!conservativeRenameScheme) { + /*replace all packages*/ + resultFiles.forEach { file -> + file.content = packages.fold(file.content) { r, param -> + patchPackages(param.newFqName, param.oldFqName, r) + } + } + } else { + //patch imports + resultFiles.forEach { file -> + file.content = packages.fold(file.content) { r, param -> + r.patchImports(param.oldFqName, param.newFqName) + } + } + } + + /*replace all Class.forName*/ + resultFiles.forEach { file -> file.content = resultFiles.fold(file.content) { r, param -> - r.patchImports(param.oldPackage, param.newPackage) - }.patchSelfImports(file.newPackage) + patchClassForName(param.newClassId, param.oldPackage, r, conservativeRenameScheme) + } + } + + //patch self imports + resultFiles.forEach { file -> + file.content = file.content.patchSelfImports(file.newPackage) } resultFiles.forEach { resultFile -> @@ -80,7 +111,7 @@ internal fun patchFiles( val boxFiles = resultFiles.filter { hasBoxMethod(it.content) } if (boxFiles.size != 1) { - println("Several box methods in $file") + println("Several box methods in $testFile") } return boxFiles.last().newClassId } @@ -132,8 +163,21 @@ private fun getGeneratedClassName(file: File, text: String, newPackagePrefix: St return PackagePartClassUtils.getPackagePartFqName(packageFqName, file.name) } -private fun patchClassForName(className: FqName, oldPackage: FqName, text: String): String { - return text.replace(("Class\\.forName\\(\"" + oldPackage.child(className.shortName()).asString() + "\"\\)").toRegex(), "Class.forName(\"" + className.asString() + "\")") +private fun patchClassForName(className: FqName, oldPackage: FqName, text: String, conservativeRenameSchemeheme: Boolean): String { + if (!conservativeRenameSchemeheme && !oldPackage.isRoot) return text + return text.replace( + ("Class\\.forName\\(\"" + oldPackage.child(className.shortName()).asString()).toRegex(), + "Class.forName(\"" + className.asString() + ) +} + +private fun patchPackages(newPackage: FqName, oldPackage: FqName, text: String): String { + if (oldPackage.isRoot) return text + + val regexp = "([^A-Za-z0-9.])" + (oldPackage.asString() + ".").replace(".", "\\.") + return text.replace( + regexp.toRegex(), "$1" + newPackage.asString() + "." + ) } private fun String.patchImports(oldPackage: FqName, newPackage: FqName): String { diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/SpecialFiles.java b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/SpecialFiles.java index 6fab72bdf14..5094da66cde 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/SpecialFiles.java +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/SpecialFiles.java @@ -33,62 +33,25 @@ public class SpecialFiles { private static void fillExcludedFiles() { // Reflection excludedFiles.add("enclosing"); - excludedFiles.add("noReflectAtRuntime"); - excludedFiles.add("methodsFromAny"); - excludedFiles.add("genericProperty.kt"); - excludedFiles.add("kt3238.kt"); - excludedFiles.add("kt1482_2279.kt"); - excludedFiles.add("extensionMethod.kt"); - excludedFiles.add("functionNtoStringNoReflect.kt"); - excludedFiles.add("innerGeneric.kt"); - excludedFiles.add("simpleCreateType.kt"); - excludedFiles.add("equalsHashCodeToString.kt"); - excludedFiles.add("arrayOfKClasses.kt"); - excludedFiles.add("enumKClassAnnotation.kt"); - excludedFiles.add("primitivesAndArrays.kt"); - excludedFiles.add("getDelegateWithoutReflection.kt"); - excludedFiles.add("parameterAnnotationInDefaultImpls.kt"); - excludedFiles.add("kt17091.kt"); - excludedFiles.add("kt17091_2.kt"); - excludedFiles.add("kt17091_3.kt"); - excludedFiles.add("kt22906.kt"); + excludedFiles.add("kt10259.kt"); + excludedFiles.add("simpleClassLiteral.kt"); - // Reflection is used to check full class name - excludedFiles.add("native"); + //UnsatisfiedLinkError + excludedFiles.add("nativePropertyAccessors.kt"); + excludedFiles.add("topLevel.kt"); + + //Test with no reflection at runtime + excludedFiles.add("noReflectAtRuntime"); + excludedFiles.add("functionNtoStringNoReflect.kt"); + excludedFiles.add("getDelegateWithoutReflection.kt"); // "IOOBE: Invalid index 4, size is 4" for java.lang.reflect.ParameterizedType on Android excludedFiles.add("innerGenericTypeArgument.kt"); // Cannot change package name - excludedFiles.add("nestedInPackage.kt"); - excludedFiles.add("packageQualifiedMethod.kt"); - excludedFiles.add("classObjectToString.kt"); - excludedFiles.add("assertionStackTrace.kt"); - excludedFiles.add("anonymousObjectReifiedSupertype.kt"); - excludedFiles.add("innerAnonymousObject.kt"); - excludedFiles.add("nestedReifiedSignature.kt"); - excludedFiles.add("recursiveInnerAnonymousObject.kt"); - excludedFiles.add("approximateCapturedTypes.kt"); - excludedFiles.add("classForEnumEntry.kt"); - excludedFiles.add("kt10143.kt"); - excludedFiles.add("internalTopLevelOtherPackage.kt"); - excludedFiles.add("noPrivateDelegation.kt"); - excludedFiles.add("platformTypeAssertionStackTrace.kt"); - excludedFiles.add("packages.kt"); - excludedFiles.add("kt10259.kt"); - excludedFiles.add("kt11081.kt"); excludedFiles.add("kt6990.kt"); - excludedFiles.add("mainInFiles.kt"); - excludedFiles.add("noClassForSimpleEnum.kt"); - excludedFiles.add("simpleClassLiteral.kt"); - excludedFiles.add("jvmName.kt"); - excludedFiles.add("qualifiedName.kt"); - excludedFiles.add("topLevelProperty.kt"); excludedFiles.add("typeParameters.kt"); excludedFiles.add("kt13133.kt"); - excludedFiles.add("genericOverriddenFunction.kt"); - excludedFiles.add("genericOverriddenProperty.kt"); - excludedFiles.add("genericProperty.kt"); // StackOverflow with StringBuilder (escape()) excludedFiles.add("kt684.kt"); @@ -96,18 +59,6 @@ public class SpecialFiles { // Wrong enclosing info or signature after package renaming excludedFiles.add("enclosingInfo"); excludedFiles.add("signature"); - excludedFiles.add("genericBackingFieldSignature.kt"); - excludedFiles.add("genericMethodSignature.kt"); - excludedFiles.add("kt11121.kt"); - excludedFiles.add("kt5112.kt"); - - // Different format of inner signature on Android and JVM - excludedFiles.add("signatureOfDeepGenericInner.kt"); - excludedFiles.add("signatureOfDeepInner.kt"); - excludedFiles.add("signatureOfDeepInnerLastGeneric.kt"); - excludedFiles.add("signatureOfGenericInnerGenericOuter.kt"); - excludedFiles.add("signatureOfGenericInnerSimpleOuter.kt"); - excludedFiles.add("signatureOfSimpleInnerSimpleOuter.kt"); // Some classes are not visible on android excludedFiles.add("classpath.kt"); @@ -120,8 +71,6 @@ public class SpecialFiles { // Additional nested class in 'Thread' class on Android excludedFiles.add("nestedClasses.kt"); - // No 'modifiers' field in 'java.lang.reflect.Field' class - excludedFiles.add("kt12200Const.kt"); // KT-8120 excludedFiles.add("closureOfInnerLocalClass.kt"); diff --git a/compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt b/compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt index fe662778502..ce9137b8840 100644 --- a/compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt +++ b/compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt @@ -3,6 +3,8 @@ // FULL_JDK // WITH_REFLECT +package test + annotation class Anno(val value: String) interface Test { @@ -10,7 +12,7 @@ interface Test { } fun box(): String { - val testMethod = Class.forName("Test\$DefaultImpls").declaredMethods.single() + val testMethod = Class.forName("test.Test\$DefaultImpls").declaredMethods.single() //return (::test.parameters.single().annotations.single() as Simple).value val receiverAnnotations = (testMethod.parameters[0]).annotations if (receiverAnnotations.isNotEmpty()) return "fail: receiver parameter should not have any annotations, but: ${receiverAnnotations.joinToString()}" diff --git a/compiler/testData/codegen/box/bridges/bridgeInInterface.kt b/compiler/testData/codegen/box/bridges/bridgeInInterface.kt index 2e5be92be41..27cb95d75b2 100644 --- a/compiler/testData/codegen/box/bridges/bridgeInInterface.kt +++ b/compiler/testData/codegen/box/bridges/bridgeInInterface.kt @@ -2,6 +2,8 @@ // WITH_RUNTIME // FULL_JDK +package test + interface Test { fun test(p: T): T { return null!! @@ -34,7 +36,7 @@ fun box(): String { checkMethodExists(TestClass::class.java, "foo", String::class.java) - val test2DefaultImpls = java.lang.Class.forName("Test2\$DefaultImpls") + val test2DefaultImpls = java.lang.Class.forName("test.Test2\$DefaultImpls") checkMethodExists(test2DefaultImpls, "test", Test2::class.java, String::class.java) checkMethodExists(test2DefaultImpls, "foo", Test2::class.java, String::class.java) diff --git a/compiler/testData/codegen/box/bridges/bridgeInInterfaceWithProperties.kt b/compiler/testData/codegen/box/bridges/bridgeInInterfaceWithProperties.kt index ea962d80aa6..40e06cdc0e9 100644 --- a/compiler/testData/codegen/box/bridges/bridgeInInterfaceWithProperties.kt +++ b/compiler/testData/codegen/box/bridges/bridgeInInterfaceWithProperties.kt @@ -2,6 +2,8 @@ // WITH_RUNTIME // FULL_JDK +package test + interface Test { var T.foo: T get() = null!! @@ -27,7 +29,7 @@ fun box(): String { checkMethodExists(TestClass::class.java, "setFoo", Any::class.java, Any::class.java) checkMethodExists(TestClass::class.java, "setFoo", String::class.java, String::class.java) - val test2DefaultImpls = java.lang.Class.forName("Test2\$DefaultImpls") + val test2DefaultImpls = java.lang.Class.forName("test.Test2\$DefaultImpls") checkMethodExists(test2DefaultImpls, "getFoo", Test2::class.java, String::class.java) checkMethodExists(test2DefaultImpls, "setFoo", Test2::class.java, String::class.java, String::class.java) diff --git a/compiler/testData/codegen/box/classes/classObjectToString.kt b/compiler/testData/codegen/box/classes/classObjectToString.kt index 752805896a3..43d10f8ef9a 100644 --- a/compiler/testData/codegen/box/classes/classObjectToString.kt +++ b/compiler/testData/codegen/box/classes/classObjectToString.kt @@ -1,9 +1,12 @@ // TODO: Enable for JS when it supports Java class library. // TARGET_BACKEND: JVM + +package test + class SomeClass { companion object } -fun box() = - if ((SomeClass.toString() as java.lang.String).matches("SomeClass\\\$Companion@[0-9a-fA-F]+")) +fun box() = + if ((SomeClass.toString() as java.lang.String).matches("test.SomeClass\\\$Companion@[0-9a-fA-F]+")) "OK" else "Fail: $SomeClass" diff --git a/compiler/testData/codegen/box/coroutines/coroutineToString.kt b/compiler/testData/codegen/box/coroutines/coroutineToString.kt index 64096f20b3d..e9358905ea4 100644 --- a/compiler/testData/codegen/box/coroutines/coroutineToString.kt +++ b/compiler/testData/codegen/box/coroutines/coroutineToString.kt @@ -3,7 +3,7 @@ // TARGET_BACKEND: JVM // WITH_REFLECT // WITH_COROUTINES - +package test import helpers.* import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* @@ -31,5 +31,5 @@ fun box(): String { result = A().bar() } - return if (result == "Continuation at A.bar(coroutineToString.kt:16)") "OK" else "Fail: $result" + return if (result == "Continuation at test.A.bar(coroutineToString.kt:16)") "OK" else "Fail: $result" } diff --git a/compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt b/compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt index 6a58e7a5bac..15e6c7c17f7 100644 --- a/compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt +++ b/compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt @@ -3,7 +3,7 @@ // WITH_RUNTIME // FULL_JDK // WITH_COROUTINES - +package test import helpers.* import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* diff --git a/compiler/testData/codegen/box/coroutines/debug/runtimeDebugMetadata.kt b/compiler/testData/codegen/box/coroutines/debug/runtimeDebugMetadata.kt index 835ba8778e1..d05d10dba12 100644 --- a/compiler/testData/codegen/box/coroutines/debug/runtimeDebugMetadata.kt +++ b/compiler/testData/codegen/box/coroutines/debug/runtimeDebugMetadata.kt @@ -5,7 +5,7 @@ // WITH_COROUTINES @file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") - +package test import helpers.* import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* diff --git a/compiler/testData/codegen/box/enum/classForEnumEntry.kt b/compiler/testData/codegen/box/enum/classForEnumEntry.kt index d9a995cad79..4d64e8641df 100644 --- a/compiler/testData/codegen/box/enum/classForEnumEntry.kt +++ b/compiler/testData/codegen/box/enum/classForEnumEntry.kt @@ -2,6 +2,8 @@ // WITH_RUNTIME +package test + enum class IssueState { DEFAULT, FIXED { @@ -15,15 +17,15 @@ fun box(): String { val field = IssueState::class.java.getField("FIXED") val typeName = field.type.name - if (typeName != "IssueState") return "Fail type name: $typeName" + if (typeName != "test.IssueState") return "Fail type name: $typeName" val className = field.get(null).javaClass.name - if (className != "IssueState\$FIXED") return "Fail class name: $className" + if (className != "test.IssueState\$FIXED") return "Fail class name: $className" val classLoader = IssueState::class.java.classLoader - classLoader.loadClass("IssueState\$FIXED") + classLoader.loadClass("test.IssueState\$FIXED") try { - classLoader.loadClass("IssueState\$DEFAULT") + classLoader.loadClass("test.IssueState\$DEFAULT") return "Fail: no class should have been generated for DEFAULT" } catch (e: Exception) { diff --git a/compiler/testData/codegen/box/enum/noClassForSimpleEnum.kt b/compiler/testData/codegen/box/enum/noClassForSimpleEnum.kt index c44137b7119..0ec3390f457 100644 --- a/compiler/testData/codegen/box/enum/noClassForSimpleEnum.kt +++ b/compiler/testData/codegen/box/enum/noClassForSimpleEnum.kt @@ -2,6 +2,8 @@ // WITH_RUNTIME +package test + enum class State { O, K @@ -10,7 +12,7 @@ enum class State { fun box(): String { val field = State::class.java.getField("O") val className = field.get(null).javaClass.name - if (className != "State") return "Fail: $className" + if (className != "test.State") return "Fail: $className" return "${State.O.name}${State.K.name}" } diff --git a/compiler/testData/codegen/box/fullJdk/platformTypeAssertionStackTrace.kt b/compiler/testData/codegen/box/fullJdk/platformTypeAssertionStackTrace.kt index 20b7d489d5b..d34c26f2348 100644 --- a/compiler/testData/codegen/box/fullJdk/platformTypeAssertionStackTrace.kt +++ b/compiler/testData/codegen/box/fullJdk/platformTypeAssertionStackTrace.kt @@ -3,6 +3,8 @@ // FULL_JDK +package test + import java.util.* fun box(): String { @@ -17,7 +19,7 @@ fun box(): String { return "Fail: very small stack trace, should at least have current function and JUnit reflective calls: ${Arrays.toString(st)}" } val top = st[0] - if (!(top.getClassName() == "PlatformTypeAssertionStackTraceKt" && top.getMethodName() == "box")) { + if (!(top.getClassName() == "test.PlatformTypeAssertionStackTraceKt" && top.getMethodName() == "box")) { return "Fail: top stack trace element should be PlatformTypeAssertionStackTraceKt.box() from default package, but was $top" } return "OK" diff --git a/compiler/testData/codegen/box/inlineClasses/callSpecializedEqualsViaReflection.kt b/compiler/testData/codegen/box/inlineClasses/callSpecializedEqualsViaReflection.kt index 1f00756e8e9..9155ea7330f 100644 --- a/compiler/testData/codegen/box/inlineClasses/callSpecializedEqualsViaReflection.kt +++ b/compiler/testData/codegen/box/inlineClasses/callSpecializedEqualsViaReflection.kt @@ -13,7 +13,7 @@ fun box(): String { var s = "" val name = "equals-impl0" val specializedEquals = - Class.forName("Simple").getDeclaredMethod(name, String::class.java, String::class.java) + Simple::class.java.getDeclaredMethod(name, String::class.java, String::class.java) ?: return "$name not found" try { diff --git a/compiler/testData/codegen/box/jvmName/annotationProperties.kt b/compiler/testData/codegen/box/jvmName/annotationProperties.kt index 0abad7e239e..8d6f4876b18 100644 --- a/compiler/testData/codegen/box/jvmName/annotationProperties.kt +++ b/compiler/testData/codegen/box/jvmName/annotationProperties.kt @@ -1,5 +1,6 @@ // TARGET_BACKEND: JVM // WITH_REFLECT +package test import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -15,14 +16,13 @@ annotation class Meta(val anno: Anno) @Meta(Anno(value = "OK")) fun bar() {} - fun box(): String { val f = Foo::class.annotations.single() - assertTrue("@Anno\\(uglyJvmName=\"?OK\"?\\)".toRegex().matches(f.toString())) + assertTrue("@test.Anno\\(uglyJvmName=\"?OK\"?\\)".toRegex().matches(f.toString())) assertEquals("OK", (f as Anno).value) val b = ::bar.annotations.single() - assertEquals("@Meta(anno=$f)", b.toString()) + assertEquals("@test.Meta(anno=$f)", b.toString()) assertEquals("OK", (b as Meta).anno.value) return "OK" diff --git a/compiler/testData/codegen/box/jvmOverloads/extensionMethod.kt b/compiler/testData/codegen/box/jvmOverloads/extensionMethod.kt index dacb9f086a3..fb455708776 100644 --- a/compiler/testData/codegen/box/jvmOverloads/extensionMethod.kt +++ b/compiler/testData/codegen/box/jvmOverloads/extensionMethod.kt @@ -10,6 +10,6 @@ class C { } fun box(): String { - val m = C::class.java.getClassLoader().loadClass("ExtensionMethodKt").getMethod("foo", C::class.java, String::class.java) + val m = Class.forName("ExtensionMethodKt").getMethod("foo", C::class.java, String::class.java) return m.invoke(null, C(), "O") as String } diff --git a/compiler/testData/codegen/box/objects/kt3238.kt b/compiler/testData/codegen/box/objects/kt3238.kt index d0c11d11c22..c8a849f45b5 100644 --- a/compiler/testData/codegen/box/objects/kt3238.kt +++ b/compiler/testData/codegen/box/objects/kt3238.kt @@ -1,6 +1,7 @@ // IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE +// WITH_RUNTIME object Obj { class Inner() { @@ -9,7 +10,7 @@ object Obj { } fun box() : String { - val klass = Class.forName("Obj\$Inner")!! + val klass = Obj.Inner::class.java val cons = klass.getConstructors()!![0] val inner = cons.newInstance(*(arrayOfNulls(0) as Array)) return "OK" diff --git a/compiler/testData/codegen/box/properties/kt1482_2279.kt b/compiler/testData/codegen/box/properties/kt1482_2279.kt index c970f63017b..cabe5d8ecd3 100644 --- a/compiler/testData/codegen/box/properties/kt1482_2279.kt +++ b/compiler/testData/codegen/box/properties/kt1482_2279.kt @@ -1,10 +1,12 @@ // TARGET_BACKEND: JVM +// WITH_RUNTIME +package test abstract class ClassValAbstract { abstract var a: Int companion object { - val methods = (this as java.lang.Object).getClass()?.getClassLoader()?.loadClass("ClassValAbstract")?.getMethods()!! + val methods = ClassValAbstract::class.java.getMethods()!! } } diff --git a/compiler/testData/codegen/box/reflection/annotations/setparam.kt b/compiler/testData/codegen/box/reflection/annotations/setparam.kt index 7eb284ff0f7..8fe702c2932 100644 --- a/compiler/testData/codegen/box/reflection/annotations/setparam.kt +++ b/compiler/testData/codegen/box/reflection/annotations/setparam.kt @@ -1,6 +1,8 @@ // WITH_REFLECT // IGNORE_BACKEND: JVM_IR, JS_IR, JS, NATIVE +package test + import kotlin.test.assertEquals annotation class Ann1 @@ -16,6 +18,6 @@ fun box(): String { val setterParameters = Foo::delegate.setter.parameters assertEquals(2, setterParameters.size) assertEquals("[]", setterParameters.first().annotations.toString()) - assertEquals("[@Ann2(), @Ann1()]", setterParameters.last().annotations.toString()) + assertEquals("[@test.Ann2(), @test.Ann1()]", setterParameters.last().annotations.toString()) return "OK" } diff --git a/compiler/testData/codegen/box/reflection/call/equalsHashCodeToString.kt b/compiler/testData/codegen/box/reflection/call/equalsHashCodeToString.kt index e167747404b..ee5e81d73b4 100644 --- a/compiler/testData/codegen/box/reflection/call/equalsHashCodeToString.kt +++ b/compiler/testData/codegen/box/reflection/call/equalsHashCodeToString.kt @@ -5,6 +5,8 @@ // WITH_REFLECT +package test + class A data class D(val s: String) @@ -14,7 +16,7 @@ fun box(): String { assert(A::equals.call(a, a)) assert(!A::equals.call(a, 0)) assert(A::hashCode.call(a) == A::hashCode.call(a)) - assert(A::toString.call(a).startsWith("A@")) + assert(A::toString.call(a).startsWith("test.A@")) assert(D::equals.call(D("foo"), D("foo"))) assert(!D::equals.call(D("foo"), D("bar"))) diff --git a/compiler/testData/codegen/box/reflection/classes/jvmName.kt b/compiler/testData/codegen/box/reflection/classes/jvmName.kt index 6df1c134ab2..bbe57838d82 100644 --- a/compiler/testData/codegen/box/reflection/classes/jvmName.kt +++ b/compiler/testData/codegen/box/reflection/classes/jvmName.kt @@ -2,6 +2,8 @@ // WITH_REFLECT +package test + import kotlin.test.assertEquals import kotlin.test.assertTrue import kotlin.reflect.jvm.jvmName @@ -12,17 +14,17 @@ class Klass { } fun box(): String { - assertEquals("Klass", Klass::class.jvmName) - assertEquals("Klass\$Nested", Klass.Nested::class.jvmName) - assertEquals("Klass\$Companion", Klass.Companion::class.jvmName) + assertEquals("test.Klass", Klass::class.jvmName) + assertEquals("test.Klass\$Nested", Klass.Nested::class.jvmName) + assertEquals("test.Klass\$Companion", Klass.Companion::class.jvmName) class Local val l = Local::class.jvmName - assertTrue(l != null && l.startsWith("JvmNameKt\$") && "\$box\$" in l && l.endsWith("\$Local")) + assertTrue(l != null && l.startsWith("test.JvmNameKt\$") && "\$box\$" in l && l.endsWith("\$Local")) val obj = object {} val o = obj.javaClass.kotlin.jvmName - assertTrue(o != null && o.startsWith("JvmNameKt\$") && "\$box\$" in o && o.endsWith("\$1")) + assertTrue(o != null && o.startsWith("test.JvmNameKt\$") && "\$box\$" in o && o.endsWith("\$1")) return "OK" } diff --git a/compiler/testData/codegen/box/reflection/classes/qualifiedName.kt b/compiler/testData/codegen/box/reflection/classes/qualifiedName.kt index c2ef9764c2c..7ff9bbe538e 100644 --- a/compiler/testData/codegen/box/reflection/classes/qualifiedName.kt +++ b/compiler/testData/codegen/box/reflection/classes/qualifiedName.kt @@ -3,6 +3,8 @@ // WITH_REFLECT +package test + import kotlin.test.assertEquals class Klass { @@ -11,9 +13,9 @@ class Klass { } fun box(): String { - assertEquals("Klass", Klass::class.qualifiedName) - assertEquals("Klass.Nested", Klass.Nested::class.qualifiedName) - assertEquals("Klass.Companion", Klass.Companion::class.qualifiedName) + assertEquals("test.Klass", Klass::class.qualifiedName) + assertEquals("test.Klass.Nested", Klass.Nested::class.qualifiedName) + assertEquals("test.Klass.Companion", Klass.Companion::class.qualifiedName) class Local assertEquals(null, Local::class.qualifiedName) diff --git a/compiler/testData/codegen/box/reflection/constructors/enumEntry.kt b/compiler/testData/codegen/box/reflection/constructors/enumEntry.kt index 8a1ad618a0a..00df38fe8b9 100644 --- a/compiler/testData/codegen/box/reflection/constructors/enumEntry.kt +++ b/compiler/testData/codegen/box/reflection/constructors/enumEntry.kt @@ -1,6 +1,7 @@ // IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JS_IR, JS, NATIVE // WITH_REFLECT +package test import kotlin.test.assertEquals @@ -18,7 +19,7 @@ enum class TestEnum(val id: String? = null) { } fun box(): String { - assertEquals(listOf("fun (kotlin.String?): TestEnum"), TestEnum.ENUM1::class.constructors.map { it.toString() }) + assertEquals(listOf("fun (kotlin.String?): test.TestEnum"), TestEnum.ENUM1::class.constructors.map { it.toString() }) assertEquals(listOf(), TestEnum.ENUM2::class.constructors.map { it.toString() }) return "OK" diff --git a/compiler/testData/codegen/box/reflection/createAnnotation/arrayOfKClasses.kt b/compiler/testData/codegen/box/reflection/createAnnotation/arrayOfKClasses.kt index 08f893462c4..49b02c17d93 100644 --- a/compiler/testData/codegen/box/reflection/createAnnotation/arrayOfKClasses.kt +++ b/compiler/testData/codegen/box/reflection/createAnnotation/arrayOfKClasses.kt @@ -4,6 +4,7 @@ // IGNORE_BACKEND: JS, NATIVE // WITH_REFLECT +package test import kotlin.reflect.KClass import kotlin.test.assertEquals @@ -13,6 +14,6 @@ annotation class Anno(val klasses: Array> = arrayOf(String::class, Int fun box(): String { val anno = Anno::class.constructors.single().callBy(emptyMap()) assertEquals(listOf(String::class, Int::class), anno.klasses.toList()) - assertEquals("@Anno(klasses=[class java.lang.String, int])", anno.toString()) + assertEquals("@test.Anno(klasses=[class java.lang.String, int])", anno.toString()) return "OK" } diff --git a/compiler/testData/codegen/box/reflection/createAnnotation/enumKClassAnnotation.kt b/compiler/testData/codegen/box/reflection/createAnnotation/enumKClassAnnotation.kt index 593b91202d3..1670be5533d 100644 --- a/compiler/testData/codegen/box/reflection/createAnnotation/enumKClassAnnotation.kt +++ b/compiler/testData/codegen/box/reflection/createAnnotation/enumKClassAnnotation.kt @@ -4,6 +4,7 @@ // IGNORE_BACKEND: JS, NATIVE // WITH_REFLECT +package test import kotlin.reflect.KClass import kotlin.test.assertEquals @@ -45,8 +46,8 @@ fun box(): String { assertEquals(a2, a1) assertEquals(a1.hashCode(), a2.hashCode()) - assertEquals("@Anno(level=WARNING, klass=class java.lang.Number, foo=@Foo(value=OK), " + - "levels=[WARNING], klasses=[class java.lang.Number], foos=[@Foo(value=OK)])", a1.toString()) + assertEquals("@test.Anno(level=WARNING, klass=class java.lang.Number, foo=@test.Foo(value=OK), " + + "levels=[WARNING], klasses=[class java.lang.Number], foos=[@test.Foo(value=OK)])", a1.toString()) return "OK" } diff --git a/compiler/testData/codegen/box/reflection/createAnnotation/primitivesAndArrays.kt b/compiler/testData/codegen/box/reflection/createAnnotation/primitivesAndArrays.kt index c7dc22ebd1f..9d72da020dc 100644 --- a/compiler/testData/codegen/box/reflection/createAnnotation/primitivesAndArrays.kt +++ b/compiler/testData/codegen/box/reflection/createAnnotation/primitivesAndArrays.kt @@ -5,6 +5,8 @@ // WITH_REFLECT +package test + import kotlin.test.assertEquals annotation class Anno( @@ -79,7 +81,7 @@ fun box(): String { assertEquals(a2, a1) assertEquals(a1.hashCode(), a2.hashCode()) - assertEquals("@Anno(b=1, c=x, d=3.14, f=-2.72, i=42424242, j=239239239239239, s=42, z=true, " + + assertEquals("@test.Anno(b=1, c=x, d=3.14, f=-2.72, i=42424242, j=239239239239239, s=42, z=true, " + "ba=[-1], ca=[y], da=[-3.14159], fa=[2.7218], ia=[424242], ja=[239239239239], sa=[-43], za=[false, true], " + "str=lol, stra=[rofl])", a1.toString()) diff --git a/compiler/testData/codegen/box/reflection/functions/enumValuesValueOf.kt b/compiler/testData/codegen/box/reflection/functions/enumValuesValueOf.kt index 157f3521eb1..05690c23c79 100644 --- a/compiler/testData/codegen/box/reflection/functions/enumValuesValueOf.kt +++ b/compiler/testData/codegen/box/reflection/functions/enumValuesValueOf.kt @@ -2,14 +2,16 @@ // IGNORE_BACKEND: JS_IR, JS, NATIVE // WITH_REFLECT +package test + import kotlin.test.assertEquals enum class E { X, Y, Z } fun box(): String { - assertEquals("fun values(): kotlin.Array", E::values.toString()) + assertEquals("fun values(): kotlin.Array", E::values.toString()) assertEquals(listOf(E.X, E.Y, E.Z), E::values.call().toList()) - assertEquals("fun valueOf(kotlin.String): E", E::valueOf.toString()) + assertEquals("fun valueOf(kotlin.String): test.E", E::valueOf.toString()) assertEquals(E.Y, E::valueOf.call("Y")) return "OK" diff --git a/compiler/testData/codegen/box/reflection/functions/genericOverriddenFunction.kt b/compiler/testData/codegen/box/reflection/functions/genericOverriddenFunction.kt index da63af51dc8..199814765a8 100644 --- a/compiler/testData/codegen/box/reflection/functions/genericOverriddenFunction.kt +++ b/compiler/testData/codegen/box/reflection/functions/genericOverriddenFunction.kt @@ -5,6 +5,8 @@ // WITH_REFLECT +package test + import kotlin.test.assertEquals interface H { @@ -14,7 +16,7 @@ interface H { interface A : H fun box(): String { - assertEquals("A?", A::foo.returnType.toString()) + assertEquals("test.A?", A::foo.returnType.toString()) assertEquals("T?", H::foo.returnType.toString()) return "OK" diff --git a/compiler/testData/codegen/box/reflection/genericSignature/genericBackingFieldSignature.kt b/compiler/testData/codegen/box/reflection/genericSignature/genericBackingFieldSignature.kt index 7a57855ef03..b1c2dc598d6 100644 --- a/compiler/testData/codegen/box/reflection/genericSignature/genericBackingFieldSignature.kt +++ b/compiler/testData/codegen/box/reflection/genericSignature/genericBackingFieldSignature.kt @@ -3,6 +3,8 @@ // WITH_REFLECT //test for KT-3722 Write correct generic type information for generated fields +package test + import kotlin.properties.Delegates class Z { @@ -50,25 +52,25 @@ fun box(): String { val classField = clz.getDeclaredField("classField1"); - if (classField.getGenericType().toString() != "Z") + if (classField.getGenericType().toString() != "test.Z") return "fail1: " + classField.getGenericType(); val classField2 = clz.getDeclaredField("classField2"); - if (classField2.getGenericType().toString() != "Z") + if (classField2.getGenericType().toString() != "test.Z") return "fail2: " + classField2.getGenericType(); val classField3 = clz.getDeclaredField("classField3"); - if (classField3.getGenericType().toString() != "Zout") + if (classField3.getGenericType().toString() != "test.Zout") return "fail3: " + classField3.getGenericType(); val classField4 = clz.getDeclaredField("classField4"); - if (classField4.getGenericType().toString() != "Zin") + if (classField4.getGenericType().toString() != "test.Zin") return "fail4: " + classField4.getGenericType(); val classField5 = clz.getDeclaredField("delegateLazy\$delegate"); diff --git a/compiler/testData/codegen/box/reflection/genericSignature/genericMethodSignature.kt b/compiler/testData/codegen/box/reflection/genericSignature/genericMethodSignature.kt index a1cb911faf5..f760ed9ab6d 100644 --- a/compiler/testData/codegen/box/reflection/genericSignature/genericMethodSignature.kt +++ b/compiler/testData/codegen/box/reflection/genericSignature/genericMethodSignature.kt @@ -2,6 +2,8 @@ // WITH_REFLECT +package test + class Z {} class TParam {} @@ -30,10 +32,10 @@ fun box(): String { val params = listOf( Params(1, Any::class.java, "T", "T"), - Params(2, Z::class.java, "Z", "Z"), - Params(3, Z::class.java, "Z", "Z"), - Params(4, Any::class.java, "Zout", "X"), - Params(5, Any::class.java, "Zin", "Y") + Params(2, Z::class.java, "test.Z", "test.Z"), + Params(3, Z::class.java, "test.Z", "test.Z"), + Params(4, Any::class.java, "test.Zout", "X"), + Params(5, Any::class.java, "test.Zin", "Y") ) diff --git a/compiler/testData/codegen/box/reflection/genericSignature/kt11121.kt b/compiler/testData/codegen/box/reflection/genericSignature/kt11121.kt index b45732c1715..1f29aa1008e 100644 --- a/compiler/testData/codegen/box/reflection/genericSignature/kt11121.kt +++ b/compiler/testData/codegen/box/reflection/genericSignature/kt11121.kt @@ -2,6 +2,7 @@ // TARGET_BACKEND: JVM // WITH_REFLECT +package test class B @@ -17,12 +18,12 @@ interface A> { fun box(): String { - val defaultImpls = Class.forName("A\$DefaultImpls") + val defaultImpls = Class.forName("test.A\$DefaultImpls") val declaredMethod = defaultImpls.getDeclaredMethod("p", A::class.java, Any::class.java) - if (declaredMethod.toGenericString() != "public static T A\$DefaultImpls.p(A,T)") return "fail 1: ${declaredMethod.toGenericString()}" + if (declaredMethod.toGenericString() != "public static T test.A\$DefaultImpls.p(test.A,T)") return "fail 1: ${declaredMethod.toGenericString()}" val declaredProperty = defaultImpls.getDeclaredMethod("getZ", A::class.java, Any::class.java) - if (declaredProperty.toGenericString() != "public static T A\$DefaultImpls.getZ(A,T)") return "fail 2: ${declaredProperty.toGenericString()}" + if (declaredProperty.toGenericString() != "public static T test.A\$DefaultImpls.getZ(test.A,T)") return "fail 2: ${declaredProperty.toGenericString()}" return "OK" } diff --git a/compiler/testData/codegen/box/reflection/mapping/methodsFromSuperInterface.kt b/compiler/testData/codegen/box/reflection/mapping/methodsFromSuperInterface.kt index 4ed0856007e..cf2876fc45c 100644 --- a/compiler/testData/codegen/box/reflection/mapping/methodsFromSuperInterface.kt +++ b/compiler/testData/codegen/box/reflection/mapping/methodsFromSuperInterface.kt @@ -1,5 +1,6 @@ // TARGET_BACKEND: JVM // WITH_REFLECT +package test import kotlin.reflect.jvm.javaMethod import kotlin.test.assertEquals @@ -20,8 +21,8 @@ interface C : B2 abstract class D : B1, C fun box(): String { - assertEquals("public abstract void A1.a1()", D::a1.javaMethod!!.toString()) - assertEquals("public abstract void A2.a2()", D::a2.javaMethod!!.toString()) + assertEquals("public abstract void test.A1.a1()", D::a1.javaMethod!!.toString()) + assertEquals("public abstract void test.A2.a2()", D::a2.javaMethod!!.toString()) return "OK" } diff --git a/compiler/testData/codegen/box/reflection/mapping/types/inlineClassPrimaryVal.kt b/compiler/testData/codegen/box/reflection/mapping/types/inlineClassPrimaryVal.kt index 5bf61982289..db749617ccd 100644 --- a/compiler/testData/codegen/box/reflection/mapping/types/inlineClassPrimaryVal.kt +++ b/compiler/testData/codegen/box/reflection/mapping/types/inlineClassPrimaryVal.kt @@ -1,6 +1,7 @@ // IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT +package test import kotlin.reflect.KCallable import kotlin.reflect.jvm.* @@ -33,26 +34,26 @@ fun KCallable<*>.getJavaTypesOfParams() = parameters.map { it.type.javaType }.to fun KCallable<*>.getJavaTypeOfResult() = returnType.javaType.toString() fun box(): String { - assertEquals("[class Z1]", Z1.publicXRef.getJavaTypesOfParams()) - assertEquals("int", Z1.publicXRef.getJavaTypeOfResult()) + assertEquals("[class test.Z1]", Z1.publicXRef.getJavaTypesOfParams()) + assertEquals("int", Z1.publicXRef.getJavaTypeOfResult()) assertEquals("[]", Z1.publicXBoundRef.getJavaTypesOfParams()) assertEquals("int", Z1.publicXBoundRef.getJavaTypeOfResult()) - assertEquals("[class Z2]", Z2.internalXRef.getJavaTypesOfParams()) - assertEquals("int", Z2.internalXRef.getJavaTypeOfResult()) + assertEquals("[class test.Z2]", Z2.internalXRef.getJavaTypesOfParams()) + assertEquals("int", Z2.internalXRef.getJavaTypeOfResult()) assertEquals("[]", Z2.internalXBoundRef.getJavaTypesOfParams()) assertEquals("int", Z2.internalXBoundRef.getJavaTypeOfResult()) - assertEquals("[class Z3]", Z3.privateXRef.getJavaTypesOfParams()) - assertEquals("int", Z3.privateXRef.getJavaTypeOfResult()) + assertEquals("[class test.Z3]", Z3.privateXRef.getJavaTypesOfParams()) + assertEquals("int", Z3.privateXRef.getJavaTypeOfResult()) assertEquals("[]", Z3.privateXBoundRef.getJavaTypesOfParams()) assertEquals("int", Z3.privateXBoundRef.getJavaTypeOfResult()) - assertEquals("[class ZZ]", ZZ::x.getJavaTypesOfParams()) + assertEquals("[class test.ZZ]", ZZ::x.getJavaTypesOfParams()) // KT-28170 assertEquals("int", ZZ::x.getJavaTypeOfResult()) diff --git a/compiler/testData/codegen/box/reflection/methodsFromAny/classToString.kt b/compiler/testData/codegen/box/reflection/methodsFromAny/classToString.kt index f7f8d1705c0..6d50f405aeb 100644 --- a/compiler/testData/codegen/box/reflection/methodsFromAny/classToString.kt +++ b/compiler/testData/codegen/box/reflection/methodsFromAny/classToString.kt @@ -1,6 +1,7 @@ // TARGET_BACKEND: JVM // WITH_REFLECT +package test import kotlin.test.* @@ -11,9 +12,9 @@ class A { } fun box(): String { - assertEquals("class A", "${A::class}") - assertEquals("class A\$Nested", "${A.Nested::class}") - assertEquals("class A\$Companion", "${A.Companion::class}") + assertEquals("class test.A", "${A::class}") + assertEquals("class test.A\$Nested", "${A.Nested::class}") + assertEquals("class test.A\$Companion", "${A.Companion::class}") assertEquals("class kotlin.Any", "${Any::class}") assertEquals("class kotlin.Int", "${Int::class}") diff --git a/compiler/testData/codegen/box/reflection/methodsFromAny/fakeOverrideToString.kt b/compiler/testData/codegen/box/reflection/methodsFromAny/fakeOverrideToString.kt index 910716c5343..a1c8a5bc78a 100644 --- a/compiler/testData/codegen/box/reflection/methodsFromAny/fakeOverrideToString.kt +++ b/compiler/testData/codegen/box/reflection/methodsFromAny/fakeOverrideToString.kt @@ -1,5 +1,6 @@ // IGNORE_BACKEND: JVM_IR, JS_IR, JS, NATIVE // WITH_REFLECT +package test import kotlin.test.assertEquals @@ -12,16 +13,16 @@ open class B : A() class C : B() fun box(): String { - assertEquals("fun A.foo(T): kotlin.Unit", A::foo.toString()) - assertEquals("fun B.foo(U): kotlin.Unit", B::foo.toString()) - assertEquals("fun C.foo(kotlin.String): kotlin.Unit", C::foo.toString()) + assertEquals("fun test.A.foo(T): kotlin.Unit", A::foo.toString()) + assertEquals("fun test.B.foo(U): kotlin.Unit", B::foo.toString()) + assertEquals("fun test.C.foo(kotlin.String): kotlin.Unit", C::foo.toString()) val afoo = A::class.members.single { it.name == "foo" } - assertEquals("fun A.foo(T): kotlin.Unit", afoo.toString()) + assertEquals("fun test.A.foo(T): kotlin.Unit", afoo.toString()) val bfoo = B::class.members.single { it.name == "foo" } - assertEquals("fun B.foo(U): kotlin.Unit", bfoo.toString()) + assertEquals("fun test.B.foo(U): kotlin.Unit", bfoo.toString()) val cfoo = C::class.members.single { it.name == "foo" } - assertEquals("fun C.foo(kotlin.String): kotlin.Unit", cfoo.toString()) + assertEquals("fun test.C.foo(kotlin.String): kotlin.Unit", cfoo.toString()) return "OK" } diff --git a/compiler/testData/codegen/box/reflection/methodsFromAny/fakeOverrideToString2.kt b/compiler/testData/codegen/box/reflection/methodsFromAny/fakeOverrideToString2.kt index 045d9963772..5bf9bb4981b 100644 --- a/compiler/testData/codegen/box/reflection/methodsFromAny/fakeOverrideToString2.kt +++ b/compiler/testData/codegen/box/reflection/methodsFromAny/fakeOverrideToString2.kt @@ -1,5 +1,6 @@ // IGNORE_BACKEND: JVM_IR, JS_IR, JS, NATIVE // WITH_REFLECT +package test import kotlin.test.assertEquals @@ -21,13 +22,13 @@ interface I3 { interface I : I2, I1, I3 fun box(): String { - assertEquals("fun I.f(): kotlin.Unit", I::f.toString()) - assertEquals("val I.x: kotlin.Int", I::x.toString()) + assertEquals("fun test.I.f(): kotlin.Unit", I::f.toString()) + assertEquals("val test.I.x: kotlin.Int", I::x.toString()) val f = I::class.members.single { it.name == "f" } - assertEquals("fun I.f(): kotlin.Unit", f.toString()) + assertEquals("fun test.I.f(): kotlin.Unit", f.toString()) val x = I::class.members.single { it.name == "x" } - assertEquals("val I.x: kotlin.Int", x.toString()) + assertEquals("val test.I.x: kotlin.Int", x.toString()) return "OK" } diff --git a/compiler/testData/codegen/box/reflection/methodsFromAny/memberExtensionToString.kt b/compiler/testData/codegen/box/reflection/methodsFromAny/memberExtensionToString.kt index 07bbf1d5fba..d7a3ddda788 100644 --- a/compiler/testData/codegen/box/reflection/methodsFromAny/memberExtensionToString.kt +++ b/compiler/testData/codegen/box/reflection/methodsFromAny/memberExtensionToString.kt @@ -5,6 +5,8 @@ // WITH_REFLECT +package test + import kotlin.reflect.full.* class A { @@ -17,10 +19,10 @@ class A { fun box(): String { val p = A::class.memberExtensionProperties.single() - return if ("$p" == "var A.(kotlin.String.)id: kotlin.String") "OK" else "Fail $p" + return if ("$p" == "var test.A.(kotlin.String.)id: kotlin.String") "OK" else "Fail $p" val q = A::class.declaredFunctions.single() - if ("$q" != "fun A.(kotlin.Int.)foo(): kotlin.Double") return "Fail q $q" + if ("$q" != "fun test.A.(kotlin.Int.)foo(): kotlin.Double") return "Fail q $q" return "OK" } diff --git a/compiler/testData/codegen/box/reflection/methodsFromAny/typeToString.kt b/compiler/testData/codegen/box/reflection/methodsFromAny/typeToString.kt index 4dedca43126..f765804b9fa 100644 --- a/compiler/testData/codegen/box/reflection/methodsFromAny/typeToString.kt +++ b/compiler/testData/codegen/box/reflection/methodsFromAny/typeToString.kt @@ -5,6 +5,8 @@ // WITH_REFLECT +package test + import kotlin.test.assertEquals fun String?.foo(x: Int, y: Array, z: IntArray, w: List>>) {} @@ -22,7 +24,7 @@ fun box(): String { "kotlin.Int", "kotlin.Array", "kotlin.IntArray", - "kotlin.collections.List>>" + "kotlin.collections.List>>" ), String?::foo.parameters.map { it.type.toString() } ) @@ -30,11 +32,11 @@ fun box(): String { assertEquals("kotlin.Unit", String?::foo.returnType.toString()) val bar = A::class.members.single { it.name == "bar" } - assertEquals(listOf("A", "T", "U"), bar.parameters.map { it.type.toString() }) + assertEquals(listOf("test.A", "T", "U"), bar.parameters.map { it.type.toString() }) assertEquals("T?", bar.returnType.toString()) assertEquals( - listOf("A", "A"), + listOf("test.A", "test.A"), ::baz.parameters.map { it.type.toString() } ) diff --git a/compiler/testData/codegen/box/reflection/methodsFromAny/typeToStringInnerGeneric.kt b/compiler/testData/codegen/box/reflection/methodsFromAny/typeToStringInnerGeneric.kt index a184d420c5b..53730537621 100644 --- a/compiler/testData/codegen/box/reflection/methodsFromAny/typeToStringInnerGeneric.kt +++ b/compiler/testData/codegen/box/reflection/methodsFromAny/typeToStringInnerGeneric.kt @@ -5,6 +5,8 @@ // WITH_REFLECT +package test + import kotlin.test.assertEquals class A { @@ -16,6 +18,6 @@ class A { fun foo(): A.B.C = null!! fun box(): String { - assertEquals("A.B.C", ::foo.returnType.toString()) + assertEquals("test.A.B.C", ::foo.returnType.toString()) return "OK" } diff --git a/compiler/testData/codegen/box/reflection/properties/genericOverriddenProperty.kt b/compiler/testData/codegen/box/reflection/properties/genericOverriddenProperty.kt index d94a1be507d..f3f4ab72d5b 100644 --- a/compiler/testData/codegen/box/reflection/properties/genericOverriddenProperty.kt +++ b/compiler/testData/codegen/box/reflection/properties/genericOverriddenProperty.kt @@ -6,6 +6,8 @@ // WITH_REFLECT // KT-13700 Exception obtaining descriptor for property reference +package test + import kotlin.test.assertEquals interface H { @@ -15,7 +17,7 @@ interface H { interface A : H fun box(): String { - assertEquals("A?", A::parent.returnType.toString()) + assertEquals("test.A?", A::parent.returnType.toString()) assertEquals("T?", H::parent.returnType.toString()) return "OK" diff --git a/compiler/testData/codegen/box/reflection/properties/genericProperty.kt b/compiler/testData/codegen/box/reflection/properties/genericProperty.kt index c601bb4fe25..cf9ff1c1f28 100644 --- a/compiler/testData/codegen/box/reflection/properties/genericProperty.kt +++ b/compiler/testData/codegen/box/reflection/properties/genericProperty.kt @@ -4,6 +4,7 @@ // IGNORE_BACKEND: JS, NATIVE // WITH_REFLECT +package test import kotlin.test.assertEquals @@ -11,6 +12,6 @@ data class Box(val element: T) fun box(): String { val p = Box::element - assertEquals("val Box.element: T", p.toString()) + assertEquals("val test.Box.element: T", p.toString()) return p.call(Box("OK")) } diff --git a/compiler/testData/codegen/box/reflection/types/createType/innerGeneric.kt b/compiler/testData/codegen/box/reflection/types/createType/innerGeneric.kt index b5b30bc0b3f..b664e36db88 100644 --- a/compiler/testData/codegen/box/reflection/types/createType/innerGeneric.kt +++ b/compiler/testData/codegen/box/reflection/types/createType/innerGeneric.kt @@ -3,6 +3,7 @@ // IGNORE_BACKEND: JS, NATIVE // WITH_REFLECT +package test import kotlin.reflect.full.createType import kotlin.reflect.KClass @@ -22,9 +23,9 @@ fun box(): String { fun KClass<*>.inv() = KTypeProjection.invariant(this.createType()) val type = A.B.C::class.createType(listOf(Long::class.inv(), Double::class.inv(), Float::class.inv(), Int::class.inv())) - assertEquals("A.B.C", type.toString()) + assertEquals("test.A.B.C", type.toString()) - assertEquals("A.D", A.D::class.createType().toString()) + assertEquals("test.A.D", A.D::class.createType().toString()) return "OK" } diff --git a/compiler/testData/codegen/box/reflection/types/createType/simpleCreateType.kt b/compiler/testData/codegen/box/reflection/types/createType/simpleCreateType.kt index 60823d3f92e..6f8ea42b0ca 100644 --- a/compiler/testData/codegen/box/reflection/types/createType/simpleCreateType.kt +++ b/compiler/testData/codegen/box/reflection/types/createType/simpleCreateType.kt @@ -3,6 +3,7 @@ // IGNORE_BACKEND: JS, NATIVE // WITH_REFLECT +package test import kotlin.reflect.full.createType import kotlin.reflect.KTypeProjection @@ -12,11 +13,11 @@ class Foo class Bar fun box(): String { - assertEquals("Foo", Foo::class.createType().toString()) - assertEquals("Foo?", Foo::class.createType(nullable = true).toString()) + assertEquals("test.Foo", Foo::class.createType().toString()) + assertEquals("test.Foo?", Foo::class.createType(nullable = true).toString()) - assertEquals("Bar", Bar::class.createType(listOf(KTypeProjection.invariant(String::class.createType()))).toString()) - assertEquals("Bar?", Bar::class.createType(listOf(KTypeProjection.invariant(Int::class.createType())), nullable = true).toString()) + assertEquals("test.Bar", Bar::class.createType(listOf(KTypeProjection.invariant(String::class.createType()))).toString()) + assertEquals("test.Bar?", Bar::class.createType(listOf(KTypeProjection.invariant(Int::class.createType())), nullable = true).toString()) return "OK" } diff --git a/compiler/testData/codegen/box/reified/anonymousObjectReifiedSupertype.kt b/compiler/testData/codegen/box/reified/anonymousObjectReifiedSupertype.kt index d9a5bcd1de8..feea4399dde 100644 --- a/compiler/testData/codegen/box/reified/anonymousObjectReifiedSupertype.kt +++ b/compiler/testData/codegen/box/reified/anonymousObjectReifiedSupertype.kt @@ -3,6 +3,8 @@ // WITH_RUNTIME +package test + import kotlin.test.assertEquals abstract class A { @@ -20,6 +22,6 @@ inline fun foo(): A { fun box(): String { val y = foo(); assertEquals("OK", y.f()) - assertEquals("A", y.javaClass.getGenericSuperclass()?.toString()) + assertEquals("test.A", y.javaClass.getGenericSuperclass()?.toString()) return "OK" } diff --git a/compiler/testData/codegen/box/reified/approximateCapturedTypes.kt b/compiler/testData/codegen/box/reified/approximateCapturedTypes.kt index 23e4c1f5afd..3d55f342772 100644 --- a/compiler/testData/codegen/box/reified/approximateCapturedTypes.kt +++ b/compiler/testData/codegen/box/reified/approximateCapturedTypes.kt @@ -3,12 +3,14 @@ // WITH_RUNTIME // Basically this test checks that no captured type used as argument for signature mapping + +package test + class SwOperator: Operator, T> interface Operator open class Inv - class Obs { inline fun lift(lift: Operator) = object : Inv() {} } @@ -19,7 +21,7 @@ fun box(): String { val inv = o.lift(SwOperator()) val signature = inv.javaClass.genericSuperclass.toString() - if (signature != "Inv>") return "fail 1: $signature" + if (signature != "test.Inv>") return "fail 1: $signature" return "OK" } diff --git a/compiler/testData/codegen/box/reified/innerAnonymousObject.kt b/compiler/testData/codegen/box/reified/innerAnonymousObject.kt index a82180939ef..2b4ece65fcf 100644 --- a/compiler/testData/codegen/box/reified/innerAnonymousObject.kt +++ b/compiler/testData/codegen/box/reified/innerAnonymousObject.kt @@ -2,6 +2,7 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME +package test import kotlin.test.assertEquals @@ -27,6 +28,6 @@ inline fun foo(): G { fun box(): String { val y = foo().bar(); assertEquals("OK", y.toString()) - assertEquals("A", y.javaClass.getGenericSuperclass()?.toString()) + assertEquals("test.A", y.javaClass.getGenericSuperclass()?.toString()) return "OK" } diff --git a/compiler/testData/codegen/box/reified/nestedReifiedSignature.kt b/compiler/testData/codegen/box/reified/nestedReifiedSignature.kt index b512e42b66c..a7f6455301c 100644 --- a/compiler/testData/codegen/box/reified/nestedReifiedSignature.kt +++ b/compiler/testData/codegen/box/reified/nestedReifiedSignature.kt @@ -3,6 +3,8 @@ // WITH_RUNTIME +package test + import kotlin.test.assertEquals open class A @@ -27,7 +29,7 @@ fun box(): String { Triple("java.lang.Integer", "java.lang.Double", "java.lang.Integer"), Triple("java.lang.Boolean", "java.lang.Double", "java.lang.Integer"), Triple("java.lang.Double", "java.lang.Boolean", "java.lang.Integer") - ).map { "A<${it.first}, ${it.second}, ${it.third}>" } + ).map { "test.A<${it.first}, ${it.second}, ${it.third}>" } for (i in expected.indices) { assertEquals(expected[i], result[i].javaClass.getGenericSuperclass()?.toString(), "$i-th element") diff --git a/compiler/testData/codegen/box/reified/recursiveInnerAnonymousObject.kt b/compiler/testData/codegen/box/reified/recursiveInnerAnonymousObject.kt index 1092aaa3360..cf6d2375724 100644 --- a/compiler/testData/codegen/box/reified/recursiveInnerAnonymousObject.kt +++ b/compiler/testData/codegen/box/reified/recursiveInnerAnonymousObject.kt @@ -2,6 +2,7 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME +package test import kotlin.test.assertEquals @@ -34,7 +35,7 @@ fun box(): String { val x2 = res.second.bar() assertEquals("OK", x1.toString()) assertEquals("OK", x2.toString()) - assertEquals("A", x1.javaClass.getGenericSuperclass()?.toString()) - assertEquals("A", x2.javaClass.getGenericSuperclass()?.toString()) + assertEquals("test.A", x1.javaClass.getGenericSuperclass()?.toString()) + assertEquals("test.A", x2.javaClass.getGenericSuperclass()?.toString()) return "OK" } diff --git a/compiler/testData/codegen/box/sam/kt17091.kt b/compiler/testData/codegen/box/sam/kt17091.kt index 6cda5f6bc5f..e33ca19fa3b 100644 --- a/compiler/testData/codegen/box/sam/kt17091.kt +++ b/compiler/testData/codegen/box/sam/kt17091.kt @@ -2,6 +2,7 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME // FILE: Foo.kt +package foo class A2 { fun doWork(job: () -> Unit) { @@ -10,6 +11,7 @@ class A2 { } // FILE: kt17091.kt +import foo.A2 typealias Z = String @@ -25,7 +27,7 @@ fun box(): String { if (java.lang.Class.forName("Kt17091Kt\$sam\$java_lang_Runnable$0") == null) return "fail: can't find sam wrapper" - if (java.lang.Class.forName("A2\$sam\$java_lang_Runnable$0") == null) return "fail 2: can't find sam wrapper" + if (java.lang.Class.forName("foo.A2\$sam\$java_lang_Runnable$0") == null) return "fail 2: can't find sam wrapper" return result } \ No newline at end of file diff --git a/compiler/testData/codegen/box/traits/noPrivateDelegation.kt b/compiler/testData/codegen/box/traits/noPrivateDelegation.kt index c0e16842c6b..42a64385eb8 100644 --- a/compiler/testData/codegen/box/traits/noPrivateDelegation.kt +++ b/compiler/testData/codegen/box/traits/noPrivateDelegation.kt @@ -2,6 +2,8 @@ // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE +package test + interface Z{ private fun extension(): String { @@ -14,7 +16,7 @@ object Z2 : Z { } fun box() : String { - val size = Class.forName("Z2").declaredMethods.size + val size = Class.forName("test.Z2").declaredMethods.size if (size != 0) return "fail: $size" return "OK" } \ No newline at end of file