[K/N][Tests] Move codegen test sources interfaceCallsNCasts..vector

^KT-61259
This commit is contained in:
Vladimir Sukharev
2023-12-15 00:13:04 +01:00
committed by Space Team
parent 56e1c5cbc6
commit 93642020ff
182 changed files with 2023 additions and 686 deletions
@@ -303,42 +303,12 @@ linkTest("localDelegatedPropertyLink") {
lib = "lower/local_delegated_property_link/lib.kt"
}
tasks.register("method_call", KonanLocalTest) {
source = "codegen/object/method_call.kt"
}
tasks.register("fields", KonanLocalTest) {
source = "codegen/object/fields.kt"
}
tasks.register("fields1", KonanLocalTest) {
source = "codegen/object/fields1.kt"
}
tasks.register("fields2", KonanLocalTest) {
useGoldenData = true
source = "codegen/object/fields2.kt"
}
// This test checks object layout can't be done in
// KonanLocalTest paradigm
//tasks.register("constructor", UnitKonanTest) {
// source = "codegen/object/constructor.kt"
//}
tasks.register("objectInitialization", KonanLocalTest) {
source = "codegen/object/initialization.kt"
}
tasks.register("objectInitialization1", KonanLocalTest) {
useGoldenData = true
source = "codegen/object/initialization1.kt"
}
standaloneTest("object_globalInitializer") {
source = "codegen/object/globalInitializer.kt"
}
standaloneTest("runtime_basic_init") {
source = "runtime/basic/init.kt"
expectedExitStatus = 0
@@ -349,14 +319,6 @@ standaloneTest("runtime_basic_exit") {
expectedExitStatus = 42
}
tasks.register("codegen_vector_default_argument", KonanLocalTest) {
source = "codegen/vector/default_argument.kt"
}
tasks.register("stringTrim", KonanLocalTest) {
source = "codegen/stringTrim/stringTrim.kt"
}
standaloneTest('enumEquals') {
useGoldenData = true
source = "runtime/basic/enum_equals.kt"
@@ -638,66 +600,6 @@ linkTest("innerClass_inheritance3_linkTest") {
lib = "codegen/innerClass/inheritance3_linkTest_lib.kt"
}
tasks.register("localClass_localHierarchy", KonanLocalTest) {
useGoldenData = true
source = "codegen/localClass/localHierarchy.kt"
}
standaloneTest("objectDeclaration_globalConstants") {
disabled = (cacheTesting != null) // Cache is not compatible with -opt.
flags = ["-opt", "-opt-in=kotlin.native.internal.InternalForKotlinNative", "-tr"]
source = "codegen/objectDeclaration/globalConstants.kt"
}
tasks.register("object_isFrozen", KonanLocalTest) {
source = "codegen/objectDeclaration/isFrozen.kt"
}
tasks.register("localClass_objectExpressionInProperty", KonanLocalTest) {
useGoldenData = true
source = "codegen/localClass/objectExpressionInProperty.kt"
}
tasks.register("localClass_objectExpressionInInitializer", KonanLocalTest) {
useGoldenData = true
source = "codegen/localClass/objectExpressionInInitializer.kt"
}
tasks.register("localClass_innerWithCapture", KonanLocalTest) {
useGoldenData = true
source = "codegen/localClass/innerWithCapture.kt"
}
tasks.register("localClass_innerTakesCapturedFromOuter", KonanLocalTest) {
useGoldenData = true
source = "codegen/localClass/innerTakesCapturedFromOuter.kt"
}
tasks.register("localClass_virtualCallFromConstructor", KonanLocalTest) {
useGoldenData = true
source = "codegen/localClass/virtualCallFromConstructor.kt"
}
tasks.register("localClass_noPrimaryConstructor", KonanLocalTest) {
useGoldenData = true
source = "codegen/localClass/noPrimaryConstructor.kt"
}
tasks.register("localClass_localFunctionCallFromLocalClass", KonanLocalTest) {
useGoldenData = true
source = "codegen/localClass/localFunctionCallFromLocalClass.kt"
}
tasks.register("localClass_localFunctionInLocalClass", KonanLocalTest) {
useGoldenData = true
source = "codegen/localClass/localFunctionInLocalClass.kt"
}
tasks.register("localClass_tryCatch", KonanLocalTest) {
useGoldenData = true
source = "codegen/localClass/tryCatch.kt"
}
standaloneTest("initializers_testInfrastructure") {
source = "codegen/initializers/testInfrastructure.kt"
flags = ["-tr"]
@@ -750,123 +652,16 @@ linkTest("delegatedProperty_correctFieldsOrder") {
lib = "codegen/delegatedProperty/correctFieldsOrder_lib.kt"
}
tasks.register("propertyCallableReference_valClass", KonanLocalTest) {
useGoldenData = true
source = "codegen/propertyCallableReference/valClass.kt"
}
tasks.register("propertyCallableReference_valModule", KonanLocalTest) {
useGoldenData = true
source = "codegen/propertyCallableReference/valModule.kt"
}
tasks.register("propertyCallableReference_varClass", KonanLocalTest) {
useGoldenData = true
source = "codegen/propertyCallableReference/varClass.kt"
}
tasks.register("propertyCallableReference_varModule", KonanLocalTest) {
useGoldenData = true
source = "codegen/propertyCallableReference/varModule.kt"
}
tasks.register("propertyCallableReference_valExtension", KonanLocalTest) {
useGoldenData = true
source = "codegen/propertyCallableReference/valExtension.kt"
}
tasks.register("propertyCallableReference_varExtension", KonanLocalTest) {
useGoldenData = true
source = "codegen/propertyCallableReference/varExtension.kt"
}
linkTest("propertyCallableReference_linkTest") {
useGoldenData = true
source = "codegen/propertyCallableReference/linkTest_main.kt"
lib = "codegen/propertyCallableReference/linkTest_lib.kt"
}
tasks.register("propertyCallableReference_dynamicReceiver", KonanLocalTest) {
useGoldenData = true
source = "codegen/propertyCallableReference/dynamicReceiver.kt"
}
tasks.register("lateinit_initialized", KonanLocalTest) {
useGoldenData = true
source = "codegen/lateinit/initialized.kt"
}
tasks.register("lateinit_notInitialized", KonanLocalTest) {
useGoldenData = true
source = "codegen/lateinit/notInitialized.kt"
}
tasks.register("lateinit_inBaseClass", KonanLocalTest) {
useGoldenData = true
source = "codegen/lateinit/inBaseClass.kt"
}
tasks.register("lateinit_localInitialized", KonanLocalTest) {
useGoldenData = true
source = "codegen/lateinit/localInitialized.kt"
}
tasks.register("lateinit_localNotInitialized", KonanLocalTest) {
useGoldenData = true
source = "codegen/lateinit/localNotInitialized.kt"
}
tasks.register("lateinit_localCapturedInitialized", KonanLocalTest) {
useGoldenData = true
source = "codegen/lateinit/localCapturedInitialized.kt"
}
tasks.register("lateinit_localCapturedNotInitialized", KonanLocalTest) {
useGoldenData = true
source = "codegen/lateinit/localCapturedNotInitialized.kt"
}
tasks.register("lateinit_isInitialized", KonanLocalTest) {
useGoldenData = true
source = "codegen/lateinit/isInitialized.kt"
}
tasks.register("lateinit_globalIsInitialized", KonanLocalTest) {
useGoldenData = true
source = "codegen/lateinit/globalIsInitialized.kt"
}
tasks.register("lateinit_innerIsInitialized", KonanLocalTest) {
useGoldenData = true
source = "codegen/lateinit/innerIsInitialized.kt"
}
tasks.register("sanity_assertions_enabled_for_local_tests", KonanLocalTest) {
source = "sanity/assertions_enabled_for_local_tests.kt"
}
tasks.register("kclass0", KonanLocalTest) {
source = "codegen/kclass/kclass0.kt"
}
tasks.register("kclass1", KonanLocalTest) {
useGoldenData = true
source = "codegen/kclass/kclass1.kt"
}
tasks.register("kclassEnumArgument", KonanLocalTest) {
useGoldenData = true
source = "codegen/kclass/kClassEnumArgument.kt"
}
tasks.register("ktype1", KonanLocalTest) {
source = "codegen/ktype/ktype1.kt"
}
tasks.register("ktype_nonReified", KonanLocalTest) {
source = "codegen/ktype/nonReified.kt"
}
tasks.register("immutable_binary_blob_in_lambda", KonanLocalTest) {
source = "lower/immutable_blob_in_lambda.kt"
useGoldenData = true
@@ -1123,127 +918,6 @@ standaloneTest("unhandled_exception") {
source = "runtime/exceptions/unhandled_exception.kt"
}
tasks.register("catch3", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/catch3.kt"
}
tasks.register("catch4", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/catch4.kt"
}
tasks.register("catch5", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/catch5.kt"
}
tasks.register("catch6", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/catch6.kt"
}
tasks.register("catch8", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/catch8.kt"
}
tasks.register("finally1", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/finally1.kt"
}
tasks.register("finally2", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/finally2.kt"
}
tasks.register("finally3", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/finally3.kt"
}
tasks.register("finally4", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/finally4.kt"
}
tasks.register("finally5", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/finally5.kt"
}
tasks.register("finally6", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/finally6.kt"
}
tasks.register("finally7", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/finally7.kt"
}
tasks.register("finally8", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/finally8.kt"
}
tasks.register("finally9", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/finally9.kt"
}
tasks.register("finally10", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/finally10.kt"
}
tasks.register("finally11", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/finally11.kt"
}
tasks.register("finally_returnsDifferentTypes", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/returnsDifferentTypes.kt"
}
tasks.register("try1", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/try1.kt"
}
tasks.register("try2", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/try2.kt"
}
tasks.register("try3", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/try3.kt"
}
tasks.register("try4", KonanLocalTest) {
useGoldenData = true
source = "codegen/try/try4.kt"
}
tasks.register("interfaceCallsNCasts_conservativeItable", KonanLocalTest) {
useGoldenData = true
source = "codegen/interfaceCallsNCasts/conservativeItable.kt"
}
tasks.register("interfaceCallsNCasts_functionNameClash", KonanLocalTest) {
source = "codegen/interfaceCallsNCasts/functionNameClash.kt"
}
tasks.register("interfaceCallsNCasts_finalMethod", KonanLocalTest) {
source = "codegen/interfaceCallsNCasts/finalMethod.kt"
}
tasks.register("interfaceCallsNCasts_diamond", KonanLocalTest) {
source = "codegen/interfaceCallsNCasts/diamond.kt"
}
tasks.register("main_exception", KonanLocalTest) {
outputChecker = { s -> s.contains("kotlin.Error: Hello!") }
@@ -1280,96 +954,6 @@ tasks.register("initializers1", KonanLocalTest) {
}
tasks.register("lambda1", KonanLocalTest) {
useGoldenData = true
source = "codegen/lambda/lambda1.kt"
}
tasks.register("lambda2", KonanLocalTest) {
arguments = ["arg0"]
useGoldenData = true
source = "codegen/lambda/lambda2.kt"
}
tasks.register("lambda3", KonanLocalTest) {
useGoldenData = true
source = "codegen/lambda/lambda3.kt"
}
tasks.register("lambda4", KonanLocalTest) {
useGoldenData = true
source = "codegen/lambda/lambda4.kt"
}
tasks.register("lambda5", KonanLocalTest) {
useGoldenData = true
source = "codegen/lambda/lambda5.kt"
}
tasks.register("lambda6", KonanLocalTest) {
useGoldenData = true
source = "codegen/lambda/lambda6.kt"
}
tasks.register("lambda7", KonanLocalTest) {
useGoldenData = true
source = "codegen/lambda/lambda7.kt"
}
tasks.register("lambda8", KonanLocalTest) {
useGoldenData = true
source = "codegen/lambda/lambda8.kt"
}
tasks.register("lambda9", KonanLocalTest) {
useGoldenData = true
source = "codegen/lambda/lambda9.kt"
}
tasks.register("lambda10", KonanLocalTest) {
useGoldenData = true
source = "codegen/lambda/lambda10.kt"
}
tasks.register("lambda11", KonanLocalTest) {
useGoldenData = true
source = "codegen/lambda/lambda11.kt"
}
tasks.register("lambda12", KonanLocalTest) {
useGoldenData = true
source = "codegen/lambda/lambda12.kt"
}
tasks.register("lambda13", KonanLocalTest) {
useGoldenData = true
source = "codegen/lambda/lambda13.kt"
}
standaloneTest("lambda14") {
source = "codegen/lambda/lambda14.kt"
flags = ['-tr']
}
tasks.register("lambda_kt49360", KonanLocalTest) {
source = "codegen/lambda/lambda_kt49360.kt"
}
tasks.register("objectExpression1", KonanLocalTest) {
useGoldenData = true
source = "codegen/objectExpression/expr1.kt"
}
tasks.register("objectExpression2", KonanLocalTest) {
useGoldenData = true
source = "codegen/objectExpression/expr2.kt"
}
tasks.register("objectExpression3", KonanLocalTest) {
useGoldenData = true
source = "codegen/objectExpression/expr3.kt"
}
standaloneTest("initializers2") {
useGoldenData = true
@@ -2456,19 +2040,6 @@ standaloneTest("interop_pinning") {
flags = [ "-tr" ]
}
tasks.register("interop_convert", KonanLocalTest) {
source = "codegen/intrinsics/interop_convert.kt"
}
tasks.register("interop_sourceCodeStruct", KonanLocalTest) {
source = "codegen/intrinsics/interop_sourceCodeStruct.kt"
}
standaloneTest("isExperimentalMM") {
source = "codegen/intrinsics/isExperimentalMM.kt"
flags = [ "-tr" ]
}
interopTest("interop_cppClass") {
disabled = PlatformInfo.isAppleTarget(project) // KT-58422
source = "interop/cpp/cppClass.kt"
@@ -3635,13 +3206,6 @@ if (PlatformInfo.isAppleTarget(project)) {
}
}
standaloneTest("local_ea_arraysfieldwrite") {
disabled = (cacheTesting != null) // Cache is not compatible with -opt.
useGoldenData = true
flags = ["-opt"]
source = "codegen/localEscapeAnalysis/arraysFieldWrite.kt"
}
tasks.register("override_konan_properties0", KonanDriverTest) {
disabled = isAggressiveGC // No need to test with different GC schedulers
def overrides = PlatformInfo.isWindows()
@@ -1,58 +0,0 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.ktype.ktype1
import kotlin.test.*
import kotlin.reflect.*
@OptIn(ExperimentalStdlibApi::class)
inline fun <reified R> kType() = typeOf<R>()
inline fun <reified R> kType(obj: R) = kType<R>()
class C<T>
class D
fun <T> kTypeForCWithTypeParameter() = kType<C<T>>()
class Outer<T> {
companion object Friend
inner class Inner<S>
}
object Object
private val pkg = "codegen.ktype.ktype1"
@Test
fun testBasics1() {
assertEquals("$pkg.C<kotlin.Int?>", kType<C<Int?>>().toString())
assertEquals("$pkg.C<$pkg.C<kotlin.Any>>", kType<C<C<Any>>>().toString())
assertEquals("$pkg.C<T>", kTypeForCWithTypeParameter<D>().toString())
assertEquals("$pkg.Object", kType<Object>().toString())
assertEquals("$pkg.Outer.Friend", kType<Outer.Friend>().toString())
}
@Test
fun testInner() {
val innerKType = kType<Outer<D>.Inner<String>>()
assertEquals(Outer.Inner::class, innerKType.classifier)
assertEquals(String::class, innerKType.arguments.first().type!!.classifier)
assertEquals(D::class, innerKType.arguments.last().type!!.classifier)
}
@Test
fun testAnonymousObject() {
val obj = object {}
val objType = kType(obj)
assertEquals("(non-denotable type)", objType.toString())
assertEquals(obj::class, objType.classifier)
assertTrue(objType.arguments.isEmpty())
assertFalse(objType.isMarkedNullable)
}
@@ -1,88 +0,0 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.ktype.nonReified
import kotlin.test.*
import kotlin.reflect.*
@OptIn(kotlin.ExperimentalStdlibApi::class)
fun <T> foo() = typeOf<List<T>>()
@Test
fun test_fun() {
val l = foo<Int>()
assertEquals(List::class, l.classifier)
val t = l.arguments.single().type!!.classifier
assertTrue(t is KTypeParameter)
assertFalse((t as KTypeParameter).isReified)
assertEquals("T", (t as KTypeParameter).name)
}
class C<T> {
@OptIn(kotlin.ExperimentalStdlibApi::class)
fun foo() = typeOf<List<T>>()
}
@Test
fun test_class() {
val l = C<Int>().foo()
assertEquals(List::class, l.classifier)
val t = l.arguments.single().type!!.classifier
assertTrue(t is KTypeParameter)
assertFalse((t as KTypeParameter).isReified)
assertEquals("T", (t as KTypeParameter).name)
}
@OptIn(kotlin.ExperimentalStdlibApi::class)
fun <T> bar1() = typeOf<List<T>>()
@OptIn(kotlin.ExperimentalStdlibApi::class)
fun <T> bar2() = typeOf<List<T>>()
class D {
@OptIn(kotlin.ExperimentalStdlibApi::class)
fun <T> bar1() = typeOf<List<T>>()
}
@Test
fun test_equality() {
val t1 = bar1<Int>().arguments.single().type!!.classifier
val t2 = bar2<Int>().arguments.single().type!!.classifier
val t3 = D().bar1<Int>().arguments.single().type!!.classifier
assertNotEquals(t1, t2)
assertNotEquals(t1, t3)
assertNotEquals(t2, t3)
assertEquals(t1, bar1<Int>().arguments.single().type!!.classifier)
assertEquals(t2, bar2<Int>().arguments.single().type!!.classifier)
assertEquals(t3, D().bar1<Int>().arguments.single().type!!.classifier)
}
@OptIn(kotlin.ExperimentalStdlibApi::class)
inline fun <reified T, R : T> reifiedUpperBound() = typeOf<List<R>>()
@Test
fun test_reifiedUpperBound() {
val l = reifiedUpperBound<Any, Any>()
assertEquals(List::class, l.classifier)
val r = l.arguments.single().type!!.classifier
assertTrue(r is KTypeParameter)
assertFalse((r as KTypeParameter).isReified)
assertEquals("R", (r as KTypeParameter).name)
val t = (r as KTypeParameter).upperBounds.single().classifier
assertTrue(t is KTypeParameter)
assertTrue((t as KTypeParameter).isReified)
assertEquals("T", (t as KTypeParameter).name)
}
@OptIn(kotlin.ExperimentalStdlibApi::class)
inline fun <reified T : Comparable<T>> recursionInReified() = typeOf<List<T>>()
@Test
fun test_recursionInReified() {
val l = recursionInReified<Int>()
assertEquals(List::class, l.classifier)
assertEquals(Int::class, l.arguments.single().type!!.classifier)
}
@@ -1,36 +1,9 @@
@file:OptIn(ExperimentalForeignApi::class)
package codegen.intrinsics.interop_convert
import kotlin.test.*
import kotlinx.cinterop.*
fun convertIntToShortOrNull(i: Int, b: Boolean): Short? = if (b) i.convert() else null
fun narrowIntToShortOrNull(i: Int, b: Boolean): Short? = if (b) i.narrow() else null
fun signExtendShortToIntOrNull(i: Short, b: Boolean): Int? = if (b) i.signExtend() else null
@Test
fun testNI() {
assertNull(convertIntToShortOrNull(0, false))
assertEquals(1, convertIntToShortOrNull(1, true))
assertNull(narrowIntToShortOrNull(2, false))
assertEquals(3, narrowIntToShortOrNull(3, true))
assertNull(signExtendShortToIntOrNull(4, false))
assertEquals(5, signExtendShortToIntOrNull(5, true))
}
@Test
fun testConvertSimple() {
assertEquals(1, 257.convert<Byte>())
assertEquals(255u, (-1).convert<UByte>())
assertEquals(0, Long.MIN_VALUE.narrow<Int>())
assertEquals(-1, Long.MAX_VALUE.narrow<Short>())
assertEquals(-1L, (-1).signExtend<Long>())
}
@Test
fun convertAll() {
fun box(): String {
val values = mutableListOf<Long>()
for (value in listOf(
0L,
@@ -54,6 +27,7 @@ fun convertAll() {
testConvertAll(value.toLong())
testConvertAll(value.toULong())
}
return "OK"
}
fun testConvertAll(value: Byte) {
@@ -0,0 +1,21 @@
@file:OptIn(ExperimentalForeignApi::class)
import kotlin.test.*
import kotlinx.cinterop.*
fun convertIntToShortOrNull(i: Int, b: Boolean): Short? = if (b) i.convert() else null
fun narrowIntToShortOrNull(i: Int, b: Boolean): Short? = if (b) i.narrow() else null
fun signExtendShortToIntOrNull(i: Short, b: Boolean): Int? = if (b) i.signExtend() else null
fun box(): String {
assertNull(convertIntToShortOrNull(0, false))
assertEquals(1, convertIntToShortOrNull(1, true))
assertNull(narrowIntToShortOrNull(2, false))
assertEquals(3, narrowIntToShortOrNull(3, true))
assertNull(signExtendShortToIntOrNull(4, false))
assertEquals(5, signExtendShortToIntOrNull(5, true))
return "OK"
}
@@ -0,0 +1,14 @@
@file:OptIn(ExperimentalForeignApi::class)
import kotlin.test.*
import kotlinx.cinterop.*
fun box(): String {
assertEquals(1, 257.convert<Byte>())
assertEquals(255u, (-1).convert<UByte>())
assertEquals(0, Long.MIN_VALUE.narrow<Int>())
assertEquals(-1, Long.MAX_VALUE.narrow<Short>())
assertEquals(-1L, (-1).signExtend<Long>())
return "OK"
}
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
import kotlin.reflect.*
@OptIn(ExperimentalStdlibApi::class)
inline fun <reified R> kType() = typeOf<R>()
inline fun <reified R> kType(obj: R) = kType<R>()
fun box(): String {
val obj = object {}
val objType = kType(obj)
assertEquals("(non-denotable type)", objType.toString())
assertEquals(obj::class, objType.classifier)
assertTrue(objType.arguments.isEmpty())
assertFalse(objType.isMarkedNullable)
return "OK"
}
@@ -0,0 +1,35 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
import kotlin.reflect.*
@OptIn(ExperimentalStdlibApi::class)
inline fun <reified R> kType() = typeOf<R>()
inline fun <reified R> kType(obj: R) = kType<R>()
class C<T>
class D
fun <T> kTypeForCWithTypeParameter() = kType<C<T>>()
class Outer<T> {
companion object Friend
inner class Inner<S>
}
object Object
fun box(): String {
assertEquals("C<kotlin.Int?>", kType<C<Int?>>().toString())
assertEquals("C<C<kotlin.Any>>", kType<C<C<Any>>>().toString())
assertEquals("C<T>", kTypeForCWithTypeParameter<D>().toString())
assertEquals("Object", kType<Object>().toString())
assertEquals("Outer.Friend", kType<Outer.Friend>().toString())
return "OK"
}
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
import kotlin.reflect.*
@OptIn(ExperimentalStdlibApi::class)
inline fun <reified R> kType() = typeOf<R>()
class D
class Outer<T> {
companion object Friend
inner class Inner<S>
}
fun box(): String {
val innerKType = kType<Outer<D>.Inner<String>>()
assertEquals(Outer.Inner::class, innerKType.classifier)
assertEquals(String::class, innerKType.arguments.first().type!!.classifier)
assertEquals(D::class, innerKType.arguments.last().type!!.classifier)
return "OK"
}
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
import kotlin.reflect.*
class C<T> {
@OptIn(kotlin.ExperimentalStdlibApi::class)
fun foo() = typeOf<List<T>>()
}
fun box(): String {
val l = C<Int>().foo()
assertEquals(List::class, l.classifier)
val t = l.arguments.single().type!!.classifier
assertTrue(t is KTypeParameter)
assertFalse((t as KTypeParameter).isReified)
assertEquals("T", (t as KTypeParameter).name)
return "OK"
}
@@ -0,0 +1,28 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
import kotlin.reflect.*
fun <T> bar1() = typeOf<List<T>>()
fun <T> bar2() = typeOf<List<T>>()
class D {
fun <T> bar1() = typeOf<List<T>>()
}
fun box(): String {
val t1 = bar1<Int>().arguments.single().type!!.classifier
val t2 = bar2<Int>().arguments.single().type!!.classifier
val t3 = D().bar1<Int>().arguments.single().type!!.classifier
assertNotEquals(t1, t2)
assertNotEquals(t1, t3)
assertNotEquals(t2, t3)
assertEquals(t1, bar1<Int>().arguments.single().type!!.classifier)
assertEquals(t2, bar2<Int>().arguments.single().type!!.classifier)
assertEquals(t3, D().bar1<Int>().arguments.single().type!!.classifier)
return "OK"
}
@@ -0,0 +1,20 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
import kotlin.reflect.*
fun <T> foo() = typeOf<List<T>>()
fun box(): String {
val l = foo<Int>()
assertEquals(List::class, l.classifier)
val t = l.arguments.single().type!!.classifier
assertTrue(t is KTypeParameter)
assertFalse((t as KTypeParameter).isReified)
assertEquals("T", (t as KTypeParameter).name)
return "OK"
}
@@ -0,0 +1,17 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
import kotlin.reflect.*
inline fun <reified T : Comparable<T>> recursionInReified() = typeOf<List<T>>()
fun box(): String {
val l = recursionInReified<Int>()
assertEquals(List::class, l.classifier)
assertEquals(Int::class, l.arguments.single().type!!.classifier)
return "OK"
}
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
import kotlin.reflect.*
inline fun <reified T, R : T> reifiedUpperBound() = typeOf<List<R>>()
fun box(): String {
val l = reifiedUpperBound<Any, Any>()
assertEquals(List::class, l.classifier)
val r = l.arguments.single().type!!.classifier
assertTrue(r is KTypeParameter)
assertFalse((r as KTypeParameter).isReified)
assertEquals("R", (r as KTypeParameter).name)
val t = (r as KTypeParameter).upperBounds.single().classifier
assertTrue(t is KTypeParameter)
assertTrue((t as KTypeParameter).isReified)
assertEquals("T", (t as KTypeParameter).name)
return "OK"
}
@@ -0,0 +1,17 @@
import kotlin.test.*
import kotlin.coroutines.*
// To be tested with -g.
// https://youtrack.jetbrains.com/issue/KT-49360
fun testTrivialCreateBlock(result: Int): () -> Int {
return (if (result == 0) { { 0 } } else null) ?: { result }
}
fun box(): String {
assertEquals(0, testTrivialCreateBlock(0)())
assertEquals(1, testTrivialCreateBlock(1)())
return "OK"
}
@@ -1,5 +1,3 @@
package codegen.lambda.lambda_kt49360
import kotlin.test.*
import kotlin.coroutines.*
@@ -7,28 +5,6 @@ import kotlin.coroutines.*
// https://youtrack.jetbrains.com/issue/KT-49360
fun testTrivialCreateBlock(result: Int): () -> Int {
return (if (result == 0) { { 0 } } else null) ?: { result }
}
@Test
fun testTrivial() {
assertEquals(0, testTrivialCreateBlock(0)())
assertEquals(1, testTrivialCreateBlock(1)())
}
class Block(val block: () -> Int)
fun testWrapBlockCreate(flag: Boolean): Block {
return (if (flag) Block { 11 } else null) ?: Block { 22 }
}
@Test
fun testWrapBlock() {
assertEquals(11, testWrapBlockCreate(true).block())
assertEquals(22, testWrapBlockCreate(false).block())
}
// The Flow code below is taken from kotlinx.coroutines (some unrelated details removed).
interface FlowCollector<in T> {
@@ -84,8 +60,7 @@ fun testWithFlowMapNotNull(flow: Flow<Boolean>): Flow<Block> {
}
}
@Test
fun testWithFlow() {
fun box(): String {
lateinit var list1: List<Block>
lateinit var list2: List<Block>
@@ -98,6 +73,8 @@ fun testWithFlow() {
assertEquals(333, list1.single().block())
assertEquals(0, list2.size)
return "OK"
}
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
@@ -0,0 +1,19 @@
import kotlin.test.*
import kotlin.coroutines.*
// To be tested with -g.
// https://youtrack.jetbrains.com/issue/KT-49360
class Block(val block: () -> Int)
fun testWrapBlockCreate(flag: Boolean): Block {
return (if (flag) Block { 11 } else null) ?: Block { 22 }
}
fun box(): String {
assertEquals(11, testWrapBlockCreate(true).block())
assertEquals(22, testWrapBlockCreate(false).block())
return "OK"
}

Some files were not shown because too many files have changed in this diff Show More