Add ANDROID target

This commit is contained in:
Mikhail Bogdanov
2020-04-13 20:06:50 +02:00
parent 9d68db1668
commit dec93c8b49
32 changed files with 115 additions and 123 deletions
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.android.tests package org.jetbrains.kotlin.android.tests
import com.intellij.openapi.util.Ref import com.intellij.openapi.util.Ref
import org.jetbrains.kotlin.codegen.CodegenTestCase
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
@@ -47,18 +46,21 @@ internal fun patchFilesAndAddTest(
val newPackagePrefix = testFile.path.replace("\\\\|-|\\.|/".toRegex(), "_") val newPackagePrefix = testFile.path.replace("\\\\|-|\\.|/".toRegex(), "_")
val oldPackage = Ref<FqName>() val oldPackage = Ref<FqName>()
val isJvmName = Ref<Boolean>(false)
val isSingle = testFiles.size == 1 val isSingle = testFiles.size == 1
val resultFiles = testFiles.map { val resultFiles = testFiles.map {
val fileName = if (isSingle) it.name else testFile.name.substringBeforeLast(".kt") + "/" + it.name val fileName = if (isSingle) it.name else testFile.name.substringBeforeLast(".kt") + "/" + it.name
TestClassInfo( TestClassInfo(
fileName, fileName,
changePackage(newPackagePrefix, it.content, oldPackage), changePackage(newPackagePrefix, it.content, oldPackage, isJvmName),
oldPackage.get(), oldPackage.get(),
isJvmName.get(),
getGeneratedClassName(File(fileName), it.content, newPackagePrefix, oldPackage.get()) getGeneratedClassName(File(fileName), it.content, newPackagePrefix, oldPackage.get())
) )
} }
val packages = val packages =
resultFiles.map { OldPackageAndNew(it.oldPackage, it.newClassId.parent()) }.sortedByDescending { it.oldFqName.asString().length } resultFiles.map { OldPackageAndNew(it.oldPackage, it.newPackagePartClassId.parent()) }
.sortedByDescending { it.oldFqName.asString().length }
//If files contain any val or var declaration with same name as any package name //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 // then use old conservative renaming scheme, otherwise use aggressive one
@@ -95,7 +97,7 @@ internal fun patchFilesAndAddTest(
/*replace all Class.forName*/ /*replace all Class.forName*/
resultFiles.forEach { file -> resultFiles.forEach { file ->
file.content = resultFiles.fold(file.content) { r, param -> file.content = resultFiles.fold(file.content) { r, param ->
patchClassForName(param.newClassId, param.oldPackage, r, conservativeRenameScheme) patchClassForName(param.newPackagePartClassId, param.oldPackage, r, conservativeRenameScheme)
} }
} }
@@ -104,6 +106,13 @@ internal fun patchFilesAndAddTest(
file.content = file.content.patchSelfImports(file.newPackage) file.content = file.content.patchSelfImports(file.newPackage)
} }
//patch root package parts usages in strings
resultFiles.forEach { file ->
file.content = resultFiles.fold(file.content) { r, param ->
patchRootPartNamesInStrings(param.newPackagePartClassId, param.oldPackage, param.isJvmName, r)
}
}
val boxFiles = resultFiles.filter { hasBoxMethod(it.content) } val boxFiles = resultFiles.filter { hasBoxMethod(it.content) }
if (boxFiles.size != 1) { if (boxFiles.size != 1) {
println("Several box methods in $testFile") println("Several box methods in $testFile")
@@ -111,22 +120,22 @@ internal fun patchFilesAndAddTest(
filesHolder.addTest( filesHolder.addTest(
resultFiles.filter { resultFile -> resultFile.name.endsWith(".kt") || resultFile.name.endsWith(".kts") }, resultFiles.filter { resultFile -> resultFile.name.endsWith(".kt") || resultFile.name.endsWith(".kts") },
TestInfo("", boxFiles.last().newClassId, testFile) TestInfo("", boxFiles.last().newPackagePartClassId, testFile)
) )
return boxFiles.last().newClassId return boxFiles.last().newPackagePartClassId
} }
private fun hasBoxMethod(text: String): Boolean { private fun hasBoxMethod(text: String): Boolean {
return text.contains("fun box()") return text.contains("fun box()")
} }
class TestClassInfo(val name: String, var content: String, val oldPackage: FqName, val newClassId: FqName) { class TestClassInfo(val name: String, var content: String, val oldPackage: FqName, val isJvmName: Boolean, val newPackagePartClassId: FqName) {
val newPackage = newClassId.parent() val newPackage = newPackagePartClassId.parent()
} }
private fun changePackage(newPackagePrefix: String, text: String, oldPackage: Ref<FqName>): String { private fun changePackage(newPackagePrefix: String, text: String, oldPackage: Ref<FqName>, isJvmName: Ref<Boolean>): String {
val matcher = packagePattern.matcher(text) val matcher = packagePattern.matcher(text)
if (matcher.find()) { if (matcher.find()) {
val oldPackageName = matcher.toMatchResult().group(1) val oldPackageName = matcher.toMatchResult().group(1)
@@ -138,6 +147,7 @@ private fun changePackage(newPackagePrefix: String, text: String, oldPackage: Re
if (text.contains("@file:")) { if (text.contains("@file:")) {
val index = text.lastIndexOf("@file:") val index = text.lastIndexOf("@file:")
val packageDirectiveIndex = text.indexOf("\n", index) val packageDirectiveIndex = text.indexOf("\n", index)
isJvmName.set(true)
return text.substring(0, packageDirectiveIndex + 1) + packageDirective + text.substring(packageDirectiveIndex + 1) return text.substring(0, packageDirectiveIndex + 1) + packageDirective + text.substring(packageDirectiveIndex + 1)
} else { } else {
return packageDirective + text return packageDirective + text
@@ -170,6 +180,19 @@ private fun patchClassForName(className: FqName, oldPackage: FqName, text: Strin
) )
} }
private fun patchRootPartNamesInStrings(
className: FqName,
oldPackage: FqName,
isJvmName: Boolean,
text: String
): String {
if (!oldPackage.isRoot || isJvmName) return text
return text.replace(
("\"" + oldPackage.child(className.shortName()).asString()).toRegex(),
"\"" + className.asString()
)
}
private fun patchPackages(newPackage: FqName, oldPackage: FqName, text: String): String { private fun patchPackages(newPackage: FqName, oldPackage: FqName, text: String): String {
if (oldPackage.isRoot) return text if (oldPackage.isRoot) return text
@@ -246,9 +246,6 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
} }
for (file in files) { for (file in files) {
if (SpecialFiles.getExcludedFiles().contains(file.name)) {
continue
}
if (file.isDirectory) { if (file.isDirectory) {
val listFiles = file.listFiles() val listFiles = file.listFiles()
if (listFiles != null) { if (listFiles != null) {
@@ -261,7 +258,9 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
continue continue
} }
if (!InTextDirectivesUtils.isPassingTarget(TargetBackend.JVM, file)) { if (!InTextDirectivesUtils.isPassingTarget(TargetBackend.JVM, file) ||
InTextDirectivesUtils.isIgnoredTarget(TargetBackend.ANDROID, file)
) {
continue continue
} }
@@ -313,16 +312,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
} }
private fun createTestFiles(file: File, expectedText: String): List<KotlinBaseTest.TestFile> = private fun createTestFiles(file: File, expectedText: String): List<KotlinBaseTest.TestFile> =
TestFiles.createTestFiles( CodegenTestCase.createTestFilesFromFile(file, expectedText, "kotlin.coroutines", false, TargetBackend.JVM)
file.name,
expectedText,
object : TestFiles.TestFileFactoryNoModules<KotlinBaseTest.TestFile>() {
override fun create(fileName: String, text: String, directives: Directives): KotlinBaseTest.TestFile {
return KotlinBaseTest.TestFile(fileName, text, directives)
}
}, false,
"kotlin.coroutines"
)
companion object { companion object {
const val GRADLE_VERSION = "5.6.4" const val GRADLE_VERSION = "5.6.4"
@@ -359,6 +349,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
val rootFolder = File("") val rootFolder = File("")
val pathManager = PathManager(rootFolder.absolutePath, tmpFolder.absolutePath) val pathManager = PathManager(rootFolder.absolutePath, tmpFolder.absolutePath)
generate(pathManager, true) generate(pathManager, true)
println("Android test project is generated into " + tmpFolder.absolutePath + " folder")
} }
} }
} }
@@ -1,87 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.android.tests;
import java.util.HashSet;
import java.util.Set;
public class SpecialFiles {
private static final Set<String> excludedFiles = new HashSet<>();
static {
fillExcludedFiles();
}
public static Set<String> getExcludedFiles() {
return excludedFiles;
}
private static void fillExcludedFiles() {
// Reflection
excludedFiles.add("enclosing");
excludedFiles.add("kt10259.kt");
excludedFiles.add("simpleClassLiteral.kt");
//UnsatisfiedLinkError
excludedFiles.add("nativePropertyAccessors.kt");
excludedFiles.add("topLevel.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("kt6990.kt");
excludedFiles.add("typeParameters.kt");
excludedFiles.add("kt13133.kt");
// StackOverflow with StringBuilder (escape())
excludedFiles.add("kt684.kt");
// Wrong enclosing info or signature after package renaming
excludedFiles.add("enclosingInfo");
excludedFiles.add("signature");
// Some classes are not visible on android
excludedFiles.add("classpath.kt");
// Out of memory
excludedFiles.add("manyNumbers.kt");
// Native methods
excludedFiles.add("external");
// Additional nested class in 'Thread' class on Android
excludedFiles.add("nestedClasses.kt");
// KT-8120
excludedFiles.add("closureOfInnerLocalClass.kt");
excludedFiles.add("closureWithSelfInstantiation.kt");
excludedFiles.add("quotedClassName.kt");
//wrong function resolution after package renaming
excludedFiles.add("apiVersionAtLeast1.kt");
//special symbols in names
excludedFiles.add("nameWithWhitespace.kt");
//some classes are moved from stdlib to compatibility package
excludedFiles.add("suspendFunction_1_2.kt");
}
private SpecialFiles() {
}
}
@@ -5,6 +5,7 @@
// Therefore, do not attemp to dex this file as it will fail. // Therefore, do not attemp to dex this file as it will fail.
// See: https://source.android.com/devices/tech/dalvik/dex-format#simplename // See: https://source.android.com/devices/tech/dalvik/dex-format#simplename
// IGNORE_DEXING // IGNORE_DEXING
// IGNORE_BACKEND: ANDROID
class `A!u00A0`() { class `A!u00A0`() {
val ok = "OK" val ok = "OK"
@@ -1,5 +1,6 @@
// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// IGNORE_BACKEND: ANDROID
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,5 +1,6 @@
// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// IGNORE_BACKEND: ANDROID
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,4 +1,5 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// IGNORE_BACKEND: ANDROID
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,5 +1,6 @@
// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// IGNORE_BACKEND: ANDROID
// FULL_JDK // FULL_JDK
@@ -1,4 +1,5 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// IGNORE_BACKEND: ANDROID
// FULL_JDK // FULL_JDK
@@ -1,4 +1,5 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// IGNORE_BACKEND: ANDROID
// FULL_JDK // FULL_JDK
+3
View File
@@ -1,5 +1,8 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// Out of memory on Android 4.4
// IGNORE_BACKEND: ANDROID
// WITH_REFLECT // WITH_REFLECT
import java.util.* import java.util.*
@@ -8,6 +8,7 @@
// //
// See: https://source.android.com/devices/tech/dalvik/dex-format#simplename // See: https://source.android.com/devices/tech/dalvik/dex-format#simplename
// IGNORE_DEXING // IGNORE_DEXING
// IGNORE_BACKEND: ANDROID
fun `method with spaces`(): String { fun `method with spaces`(): String {
data class C(val s: String = "OK") data class C(val s: String = "OK")
@@ -4,6 +4,9 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// some classes are moved from stdlib to compatibility package
// IGNORE_BACKEND: ANDROID
import helpers.* import helpers.*
import kotlin.coroutines.* import kotlin.coroutines.*
@@ -1,5 +1,8 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// l[0] === 1000 is true on Android
// IGNORE_BACKEND: ANDROID
fun box(): String { fun box(): String {
val l = java.util.ArrayList<Int>() val l = java.util.ArrayList<Int>()
l.add(1000) l.add(1000)
+3
View File
@@ -2,6 +2,9 @@
// TODO: muted automatically, investigate should it be ran for JS or not // TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE // IGNORE_BACKEND: JS, NATIVE
// StackOverflow with StringBuilder (escape()) on Android 4.4
// IGNORE_BACKEND: ANDROID
fun escapeChar(c : Char) : String? = when (c) { fun escapeChar(c : Char) : String? = when (c) {
'\\' -> "\\\\" '\\' -> "\\\\"
'\n' -> "\\n" '\n' -> "\\n"
@@ -2,6 +2,9 @@
// WITH_REFLECT // WITH_REFLECT
// IGNORE_BACKEND: JS_IR, JS, NATIVE // IGNORE_BACKEND: JS_IR, JS, NATIVE
// different annotation order
// IGNORE_BACKEND: ANDROID
package test package test
import kotlin.test.assertEquals import kotlin.test.assertEquals
@@ -1,9 +1,10 @@
// IGNORE_BACKEND: NATIVE // IGNORE_BACKEND: NATIVE
// WITH_REFLECT // WITH_REFLECT
package test
class A class A
fun box(): String { fun box(): String {
val klass = A::class val klass = A::class
return if (klass.toString() == "class A") "OK" else "Fail: $klass" return if (klass.toString() == "class test.A") "OK" else "Fail: $klass"
} }
@@ -1,5 +1,8 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// has declaring class on Android 4.4
// IGNORE_BACKEND: ANDROID
// WITH_REFLECT // WITH_REFLECT
val property = fun () {} val property = fun () {}
@@ -1,6 +1,7 @@
// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME // WITH_RUNTIME
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
package test
interface Z { interface Z {
private fun privateFun() = { "OK" } private fun privateFun() = { "OK" }
@@ -58,7 +59,7 @@ fun box(): String {
val nested = Z.Nested::class.java val nested = Z.Nested::class.java
val enclosingClass = nested.enclosingClass!! val enclosingClass = nested.enclosingClass!!
if (enclosingClass.name != "Z") return "fail 9: ${enclosingClass.name}" if (enclosingClass.name != "test.Z") return "fail 9: ${enclosingClass.name}"
return "OK" return "OK"
} }
@@ -2,6 +2,7 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// WITH_REFLECT // WITH_REFLECT
package test
var lambda = {} var lambda = {}
@@ -20,7 +21,7 @@ fun box(): String {
if (enclosingMethod?.getName() != "run") return "method: $enclosingMethod" if (enclosingMethod?.getName() != "run") return "method: $enclosingMethod"
val enclosingClass = javaClass.getEnclosingClass()!!.getName() val enclosingClass = javaClass.getEnclosingClass()!!.getName()
if (enclosingClass != "A\$prop\$1") return "enclosing class: $enclosingClass" if (enclosingClass != "test.A\$prop\$1") return "enclosing class: $enclosingClass"
val declaringClass = javaClass.getDeclaringClass() val declaringClass = javaClass.getDeclaringClass()
if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass" if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass"
@@ -1,7 +1,9 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// WITH_REFLECT // has declaring class on Android 4.4
// IGNORE_BACKEND: ANDROID
// WITH_REFLECT
class O { class O {
companion object { companion object {
// Currently we consider <clinit> in class O as the enclosing method of this lambda, // Currently we consider <clinit> in class O as the enclosing method of this lambda,
@@ -1,6 +1,7 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// WITH_REFLECT // WITH_REFLECT
package test
class C { class C {
val l: Any = {} val l: Any = {}
@@ -9,10 +10,10 @@ class C {
fun box(): String { fun box(): String {
val javaClass = C().l.javaClass val javaClass = C().l.javaClass
val enclosingConstructor = javaClass.getEnclosingConstructor() val enclosingConstructor = javaClass.getEnclosingConstructor()
if (enclosingConstructor?.getDeclaringClass()?.getName() != "C") return "ctor: $enclosingConstructor" if (enclosingConstructor?.getDeclaringClass()?.getName() != "test.C") return "ctor: $enclosingConstructor"
val enclosingClass = javaClass.getEnclosingClass() val enclosingClass = javaClass.getEnclosingClass()
if (enclosingClass?.getName() != "C") return "enclosing class: $enclosingClass" if (enclosingClass?.getName() != "test.C") return "enclosing class: $enclosingClass"
val declaringClass = javaClass.getDeclaringClass() val declaringClass = javaClass.getDeclaringClass()
if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass" if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass"
@@ -1,6 +1,7 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// WITH_REFLECT // WITH_REFLECT
package test
class C { class C {
fun foo(): Any { fun foo(): Any {
@@ -15,7 +16,7 @@ fun box(): String {
if (enclosingMethod?.getName() != "foo") return "method: $enclosingMethod" if (enclosingMethod?.getName() != "foo") return "method: $enclosingMethod"
val enclosingClass = javaClass.getEnclosingClass() val enclosingClass = javaClass.getEnclosingClass()
if (enclosingClass?.getName() != "C") return "enclosing class: $enclosingClass" if (enclosingClass?.getName() != "test.C") return "enclosing class: $enclosingClass"
val declaringClass = javaClass.getDeclaringClass() val declaringClass = javaClass.getDeclaringClass()
if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass" if (declaringClass != null) return "anonymous function has a declaring class: $declaringClass"
@@ -1,5 +1,8 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// has declaring class on Android 4.4
// IGNORE_BACKEND: ANDROID
// WITH_REFLECT // WITH_REFLECT
object O { object O {
@@ -1,5 +1,8 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// has declaring class on Android 4.4
// IGNORE_BACKEND: ANDROID
// WITH_REFLECT // WITH_REFLECT
val l: Any = {} val l: Any = {}
@@ -1,5 +1,6 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// WITH_RUNTIME // WITH_RUNTIME
package test
class C { class C {
val f by foo { val f by foo {
@@ -19,7 +20,7 @@ fun box(): String {
if (emInner?.getName() != "invoke") return "Fail: incorrect enclosing method for inner lambda: $emInner" if (emInner?.getName() != "invoke") return "Fail: incorrect enclosing method for inner lambda: $emInner"
val ecInner = innerLambda.getEnclosingClass() val ecInner = innerLambda.getEnclosingClass()
if (ecInner?.getName() != "C\$f\$2") return "Fail: incorrect enclosing class for inner lambda: $ecInner" if (ecInner?.getName() != "test.C\$f\$2") return "Fail: incorrect enclosing class for inner lambda: $ecInner"
val ectorInner = innerLambda.getEnclosingConstructor() val ectorInner = innerLambda.getEnclosingConstructor()
if (ectorInner != null) return "Fail: inner lambda should not have enclosing constructor: $ectorInner" if (ectorInner != null) return "Fail: inner lambda should not have enclosing constructor: $ectorInner"
@@ -35,7 +36,7 @@ fun box(): String {
if (emOuter != null) return "Fail: outer lambda should not have enclosing method: $emOuter" if (emOuter != null) return "Fail: outer lambda should not have enclosing method: $emOuter"
val ecOuter = outerLambda.getEnclosingClass() val ecOuter = outerLambda.getEnclosingClass()
if (ecOuter?.getName() != "C") return "Fail: incorrect enclosing class for outer lambda: $ecOuter" if (ecOuter?.getName() != "test.C") return "Fail: incorrect enclosing class for outer lambda: $ecOuter"
val ectorOuter = outerLambda.getEnclosingConstructor() val ectorOuter = outerLambda.getEnclosingConstructor()
if (ectorOuter == null) return "Fail: outer lambda _should_ have enclosing constructor" if (ectorOuter == null) return "Fail: outer lambda _should_ have enclosing constructor"
@@ -1,6 +1,9 @@
// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// "IOOBE: Invalid index 4, size is 4" for java.lang.reflect.ParameterizedType on Android
// IGNORE_BACKEND: ANDROID
// WITH_REFLECT // WITH_REFLECT
import kotlin.reflect.jvm.javaType import kotlin.reflect.jvm.javaType
@@ -1,6 +1,10 @@
// !JVM_DEFAULT_MODE: disable // !JVM_DEFAULT_MODE: disable
// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// First item on Android is `java.lang.Thread.getStackTrace`
// IGNORE_BACKEND: ANDROID
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,4 +1,8 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// Wrong function resolution after package renaming
// IGNORE_BACKEND: ANDROID
// FILE: 1.kt // FILE: 1.kt
package kotlin.internal package kotlin.internal
+2
View File
@@ -1,4 +1,6 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// IGNORE_BACKEND: ANDROID
// FILE: 1.kt // FILE: 1.kt
// WITH_REFLECT // WITH_REFLECT
package test package test
@@ -773,16 +773,27 @@ public abstract class CodegenTestCase extends KotlinBaseTest<KotlinBaseTest.Test
@Override @Override
@NotNull @NotNull
protected List<TestFile> createTestFilesFromFile(File file, @NotNull String expectedText) { protected List<TestFile> createTestFilesFromFile(@NotNull File file, @NotNull String expectedText) {
return createTestFilesFromFile(file, expectedText, coroutinesPackage, parseDirectivesPerFiles(), getBackend());
}
@NotNull
public static List<TestFile> createTestFilesFromFile(
@NotNull File file,
@NotNull String expectedText,
@NotNull String coroutinesPackage,
boolean parseDirectivesPerFiles,
@NotNull TargetBackend backend
) {
List testFiles = TestFiles.createTestFiles(file.getName(), expectedText, new TestFiles.TestFileFactoryNoModules<TestFile>() { List testFiles = TestFiles.createTestFiles(file.getName(), expectedText, new TestFiles.TestFileFactoryNoModules<TestFile>() {
@NotNull @NotNull
@Override @Override
public TestFile create(@NotNull String fileName, @NotNull String text, @NotNull Directives directives) { public TestFile create(@NotNull String fileName, @NotNull String text, @NotNull Directives directives) {
return new TestFile(fileName, text, directives); return new TestFile(fileName, text, directives);
} }
}, false, coroutinesPackage, parseDirectivesPerFiles()); }, false, coroutinesPackage, parseDirectivesPerFiles);
if (InTextDirectivesUtils.isDirectiveDefined(expectedText, "WITH_HELPERS")) { if (InTextDirectivesUtils.isDirectiveDefined(expectedText, "WITH_HELPERS")) {
testFiles.add(new TestFile("CodegenTestHelpers.kt", TestHelperGeneratorKt.createTextForCodegenTestHelpers(getBackend()))); testFiles.add(new TestFile("CodegenTestHelpers.kt", TestHelperGeneratorKt.createTextForCodegenTestHelpers(backend)));
} }
return testFiles; return testFiles;
} }
@@ -15,7 +15,8 @@ enum class TargetBackend(
JVM_IR(true, JVM), JVM_IR(true, JVM),
JS(false), JS(false),
JS_IR(true, JS), JS_IR(true, JS),
WASM(true); WASM(true),
ANDROID(false, JVM);
val compatibleWith get() = compatibleWithTargetBackend ?: ANY val compatibleWith get() = compatibleWithTargetBackend ?: ANY
} }