[K/N][tests] Migrate link tests to new testing infra ^KT-61259
This commit is contained in:
committed by
Space Team
parent
588549d1d0
commit
d6a922bc74
@@ -298,11 +298,6 @@ Task dynamicTest(String name, Closure<KonanDynamicTest> configureClosure) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
linkTest("localDelegatedPropertyLink") {
|
|
||||||
source = "lower/local_delegated_property_link/main.kt"
|
|
||||||
lib = "lower/local_delegated_property_link/lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
// This test checks object layout can't be done in
|
// This test checks object layout can't be done in
|
||||||
// KonanLocalTest paradigm
|
// KonanLocalTest paradigm
|
||||||
//tasks.register("constructor", UnitKonanTest) {
|
//tasks.register("constructor", UnitKonanTest) {
|
||||||
@@ -554,105 +549,11 @@ standaloneTest("leakMemoryWithWorkerTermination") {
|
|||||||
source = "runtime/workers/leak_memory_with_worker_termination.kt"
|
source = "runtime/workers/leak_memory_with_worker_termination.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
linkTest("enum_linkTest") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/enum/linkTest_main.kt"
|
|
||||||
lib = "codegen/enum/linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("enum_openMethodNoOverrides") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/enum/openMethodNoOverrides_main.kt"
|
|
||||||
lib = "codegen/enum/openMethodNoOverrides_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("mangling") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "mangling/mangling.kt"
|
|
||||||
lib = "mangling/manglinglib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("innerClass_linkTest") {
|
|
||||||
source = "codegen/innerClass/linkTest_main.kt"
|
|
||||||
lib = "codegen/innerClass/linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("innerClass_inheritance_linkTest") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/innerClass/inheritance_linkTest_main.kt"
|
|
||||||
lib = "codegen/innerClass/inheritance_linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("innerClass_inheritance2_linkTest") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/innerClass/inheritance2_linkTest_main.kt"
|
|
||||||
lib = "codegen/innerClass/inheritance2_linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("innerClass_inheritance3_linkTest") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/innerClass/inheritance3_linkTest_main.kt"
|
|
||||||
lib = "codegen/innerClass/inheritance3_linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
standaloneTest("initializers_testInfrastructure") {
|
standaloneTest("initializers_testInfrastructure") {
|
||||||
source = "codegen/initializers/testInfrastructure.kt"
|
source = "codegen/initializers/testInfrastructure.kt"
|
||||||
flags = ["-tr"]
|
flags = ["-tr"]
|
||||||
}
|
}
|
||||||
|
|
||||||
linkTest("initializers_linkTest1") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/initializers/linkTest1_main.kt"
|
|
||||||
lib = "codegen/initializers/linkTest1_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("initializers_linkTest2") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/initializers/linkTest2_main.kt"
|
|
||||||
lib = "codegen/initializers/linkTest2_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("initializers_sharedVarInInitBlock") {
|
|
||||||
source = "codegen/initializers/sharedVarInInitBlock_main.kt"
|
|
||||||
lib = "codegen/initializers/sharedVarInInitBlock_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("bridges_linkTest") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/bridges/linkTest_main.kt"
|
|
||||||
lib = "codegen/bridges/linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("bridges_linkTest2") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/bridges/linkTest2_main.kt"
|
|
||||||
lib = "codegen/bridges/linkTest2_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("classDelegation_linkTest") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/classDelegation/linkTest_main.kt"
|
|
||||||
lib = "codegen/classDelegation/linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("delegatedProperty_delegatedOverride") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/delegatedProperty/delegatedOverride_main.kt"
|
|
||||||
lib = "codegen/delegatedProperty/delegatedOverride_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("delegatedProperty_correctFieldsOrder") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/delegatedProperty/correctFieldsOrder_main.kt"
|
|
||||||
lib = "codegen/delegatedProperty/correctFieldsOrder_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("propertyCallableReference_linkTest") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/propertyCallableReference/linkTest_main.kt"
|
|
||||||
lib = "codegen/propertyCallableReference/linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("sanity_assertions_enabled_for_local_tests", KonanLocalTest) {
|
tasks.register("sanity_assertions_enabled_for_local_tests", KonanLocalTest) {
|
||||||
source = "sanity/assertions_enabled_for_local_tests.kt"
|
source = "sanity/assertions_enabled_for_local_tests.kt"
|
||||||
}
|
}
|
||||||
@@ -694,21 +595,6 @@ tasks.register("empty_string", KonanLocalTest) {
|
|||||||
source = "datagen/literals/empty_string.kt"
|
source = "datagen/literals/empty_string.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disabled until we extract the classes that should be
|
|
||||||
// always present from stdlib into a separate binary.
|
|
||||||
//
|
|
||||||
//linkTest("link") {
|
|
||||||
// useGoldenData = true
|
|
||||||
// source = "link/src/bar.kt"
|
|
||||||
// lib = "link/lib"
|
|
||||||
//}(
|
|
||||||
|
|
||||||
linkTest("link_omit_unused") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "link/omit/main.kt"
|
|
||||||
lib = "link/omit/library.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
standaloneTest("link_default_libs") {
|
standaloneTest("link_default_libs") {
|
||||||
useGoldenData = true
|
useGoldenData = true
|
||||||
source = "link/default/default.kt"
|
source = "link/default/default.kt"
|
||||||
@@ -722,12 +608,6 @@ linkTest("no_purge_for_dependencies") {
|
|||||||
UtilsKt.dependsOnPlatformLibs(it)
|
UtilsKt.dependsOnPlatformLibs(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
linkTest("lib@name") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "link/klib_name/prog.kt"
|
|
||||||
lib = "link/klib_name/lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("throw0", KonanLocalTest) {
|
tasks.register("throw0", KonanLocalTest) {
|
||||||
useGoldenData = true
|
useGoldenData = true
|
||||||
source = "runtime/basic/throw0.kt"
|
source = "runtime/basic/throw0.kt"
|
||||||
@@ -1051,53 +931,11 @@ KotlinNativeTestKt.createTest(project, "kt39548", KonanStandaloneTest) { task ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
linkTest("deserialized_members") {
|
|
||||||
source = "serialization/deserialized_members/main.kt"
|
|
||||||
lib = "serialization/deserialized_members/library.kt"
|
|
||||||
useGoldenData = true
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("serialized_catch") {
|
|
||||||
source = "serialization/serialized_catch/main.kt"
|
|
||||||
lib = "serialization/serialized_catch/library.kt"
|
|
||||||
useGoldenData = true
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("serialized_doWhile") {
|
|
||||||
source = "serialization/serialized_doWhile/main.kt"
|
|
||||||
lib = "serialization/serialized_doWhile/library.kt"
|
|
||||||
useGoldenData = true
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("serialized_vararg") {
|
|
||||||
source = "serialization/serialized_vararg/main.kt"
|
|
||||||
lib = "serialization/serialized_vararg/library.kt"
|
|
||||||
useGoldenData = true
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("serialized_default_args") {
|
|
||||||
source = "serialization/serialized_default_args/main.kt"
|
|
||||||
lib = "serialization/serialized_default_args/library.kt"
|
|
||||||
useGoldenData = true
|
|
||||||
}
|
|
||||||
|
|
||||||
standaloneTest("serialized_no_typemap") {
|
standaloneTest("serialized_no_typemap") {
|
||||||
source = "serialization/regression/no_type_map.kt"
|
source = "serialization/regression/no_type_map.kt"
|
||||||
useGoldenData = true
|
useGoldenData = true
|
||||||
}
|
}
|
||||||
|
|
||||||
linkTest("serialized_enum_ordinal") {
|
|
||||||
source = "serialization/enum_ordinal/main.kt"
|
|
||||||
lib = "serialization/enum_ordinal/library.kt"
|
|
||||||
useGoldenData = true
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("serialized_char_constant") {
|
|
||||||
source = "serialization/serialized_char_constant/main.kt"
|
|
||||||
lib = "serialization/serialized_char_constant/library.kt"
|
|
||||||
useGoldenData = true
|
|
||||||
}
|
|
||||||
|
|
||||||
standaloneTest("testing_annotations") {
|
standaloneTest("testing_annotations") {
|
||||||
source = "testing/annotations.kt"
|
source = "testing/annotations.kt"
|
||||||
flags = ['-tr']
|
flags = ['-tr']
|
||||||
@@ -1301,36 +1139,6 @@ tasks.register("driver_opt", KonanDriverTest) {
|
|||||||
flags = ["-opt"]
|
flags = ["-opt"]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable when deserialization for default arguments is fixed.
|
|
||||||
linkTest("inline_defaultArgs_linkTest") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/inline/defaultArgs_linkTest_main.kt"
|
|
||||||
lib = "codegen/inline/defaultArgs_linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("inline_sharedVar_linkTest") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/inline/sharedVar_linkTest_main.kt"
|
|
||||||
lib = "codegen/inline/sharedVar_linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("inline_lateinitProperty_linkTest") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/inline/lateinitProperty_linkTest_main.kt"
|
|
||||||
lib = "codegen/inline/lateinitProperty_linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("inline_inlineCtor_linkTest") {
|
|
||||||
source = "codegen/inline/inlineCtor_linkTest_main.kt"
|
|
||||||
lib = "codegen/inline/inlineCtor_linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("inline_innerInlineFunCapturesOuter_linkTest") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "codegen/inline/innerInlineFunCapturesOuter_linkTest_main.kt"
|
|
||||||
lib = "codegen/inline/innerInlineFunCapturesOuter_linkTest_lib.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
def generateWithSpaceDefFile() {
|
def generateWithSpaceDefFile() {
|
||||||
def buildDirectory = project.layout.buildDirectory.get().asFile
|
def buildDirectory = project.layout.buildDirectory.get().asFile
|
||||||
def mapOption = "--Map \"$buildDirectory/cutom map.map\""
|
def mapOption = "--Map \"$buildDirectory/cutom map.map\""
|
||||||
@@ -2703,18 +2511,6 @@ standaloneTest("split_compilation_pipeline") {
|
|||||||
useGoldenData = true
|
useGoldenData = true
|
||||||
}
|
}
|
||||||
|
|
||||||
linkTest("private_fake_overrides_0") {
|
|
||||||
source = "link/private_fake_overrides/inherit_main.kt"
|
|
||||||
lib = "link/private_fake_overrides/inherit_lib.kt"
|
|
||||||
useGoldenData = true
|
|
||||||
}
|
|
||||||
|
|
||||||
linkTest("private_fake_overrides_1") {
|
|
||||||
source = "link/private_fake_overrides/override_main.kt"
|
|
||||||
lib = "link/private_fake_overrides/override_lib.kt"
|
|
||||||
useGoldenData = true
|
|
||||||
}
|
|
||||||
|
|
||||||
Task frameworkTest(String name, Closure<FrameworkTest> configurator) {
|
Task frameworkTest(String name, Closure<FrameworkTest> configurator) {
|
||||||
return KotlinNativeTestKt.createTest(project, name, FrameworkTest) { task ->
|
return KotlinNativeTestKt.createTest(project, name, FrameworkTest) { task ->
|
||||||
configurator.delegate = task
|
configurator.delegate = task
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
sealed class Tag {
|
|
||||||
abstract fun value(): Any
|
|
||||||
}
|
|
||||||
|
|
||||||
sealed class TagBoolean : Tag() {
|
|
||||||
abstract override fun value(): Boolean
|
|
||||||
|
|
||||||
object True : TagBoolean() {
|
|
||||||
override fun value() = true
|
|
||||||
}
|
|
||||||
|
|
||||||
object False : TagBoolean() {
|
|
||||||
override fun value() = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
val test: TagBoolean = TagBoolean.True
|
|
||||||
println(test.value())
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
true
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 a
|
|
||||||
|
|
||||||
interface A<T> {
|
|
||||||
fun foo(): T
|
|
||||||
}
|
|
||||||
|
|
||||||
open class C: A<Int> {
|
|
||||||
override fun foo(): Int = 42
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 a.*
|
|
||||||
|
|
||||||
class B: C()
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
val b = B()
|
|
||||||
println(b.foo())
|
|
||||||
val c: C = b
|
|
||||||
println(c.foo())
|
|
||||||
val a: A<Int> = b
|
|
||||||
println(a.foo())
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
42
|
|
||||||
42
|
|
||||||
42
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 zzz
|
|
||||||
|
|
||||||
interface I {
|
|
||||||
fun foo(): Int
|
|
||||||
}
|
|
||||||
|
|
||||||
open class A : I {
|
|
||||||
override fun foo() = 42
|
|
||||||
}
|
|
||||||
|
|
||||||
open class B : I by A() {
|
|
||||||
val x = 117
|
|
||||||
val y = "zzz"
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 zzz.*
|
|
||||||
|
|
||||||
class C : B() {
|
|
||||||
val a = "qxx"
|
|
||||||
val b = 123
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
val c = C()
|
|
||||||
println(c.a)
|
|
||||||
println(c.b)
|
|
||||||
println(c.foo())
|
|
||||||
println(c.x)
|
|
||||||
println(c.y)
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
qxx
|
|
||||||
123
|
|
||||||
42
|
|
||||||
117
|
|
||||||
zzz
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 zzz
|
|
||||||
|
|
||||||
open class B {
|
|
||||||
val z by lazy { "qzz" }
|
|
||||||
val x = 117
|
|
||||||
val zzz = "zzz"
|
|
||||||
}
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 zzz.*
|
|
||||||
|
|
||||||
class C : B() {
|
|
||||||
val a = "qxx"
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
val c = C()
|
|
||||||
println(c.a)
|
|
||||||
println(c.x)
|
|
||||||
println(c.zzz)
|
|
||||||
println(c.z)
|
|
||||||
}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
qxx
|
|
||||||
117
|
|
||||||
zzz
|
|
||||||
qzz
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 a
|
|
||||||
|
|
||||||
import kotlin.reflect.KProperty
|
|
||||||
|
|
||||||
open class A {
|
|
||||||
open val x = 42
|
|
||||||
}
|
|
||||||
|
|
||||||
class Delegate {
|
|
||||||
val f = 117
|
|
||||||
operator fun getValue(receiver: Any?, p: KProperty<*>): Int {
|
|
||||||
println(p.name)
|
|
||||||
return f
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open class B: A() {
|
|
||||||
override val x: Int by Delegate()
|
|
||||||
|
|
||||||
fun bar() {
|
|
||||||
println(super<A>.x)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 a.*
|
|
||||||
|
|
||||||
open class C: B() {
|
|
||||||
override val x: Int = 156
|
|
||||||
|
|
||||||
fun foo() {
|
|
||||||
println(x)
|
|
||||||
|
|
||||||
println(super<B>.x)
|
|
||||||
bar()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
val c = C()
|
|
||||||
c.foo()
|
|
||||||
}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
156
|
|
||||||
x
|
|
||||||
117
|
|
||||||
42
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 a
|
|
||||||
|
|
||||||
enum class A(val x: Int) {
|
|
||||||
Z1(42),
|
|
||||||
Z2(117),
|
|
||||||
Z3(-1)
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 a.*
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
println(A.Z1.x)
|
|
||||||
println(A.valueOf("Z2").x)
|
|
||||||
println(A.values()[2].x)
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
42
|
|
||||||
117
|
|
||||||
-1
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2022 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum class Foo {
|
|
||||||
Z;
|
|
||||||
|
|
||||||
open fun bar() = 42
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2022 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun main() = println(Foo.Z.bar())
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
42
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
val a = 10
|
|
||||||
val b = a * 6
|
|
||||||
val c = a * b * 2
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
fun main() = println(c)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
1200
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
val a = mutableListOf<Int>()
|
|
||||||
val b = 1.also { a += 2 }
|
|
||||||
val c = a.single()
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
fun main() = println(c)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
2
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
class A {
|
|
||||||
val x: Int
|
|
||||||
|
|
||||||
init {
|
|
||||||
var y = 10
|
|
||||||
|
|
||||||
fun foo() { y = 42 }
|
|
||||||
|
|
||||||
foo()
|
|
||||||
|
|
||||||
x = y
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import kotlin.test.*
|
|
||||||
|
|
||||||
fun main() = assertEquals(42, (A().x))
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 a
|
|
||||||
|
|
||||||
inline fun foo(x: Int, y: Int = 117) = x + y
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 a.*
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
println(foo(5))
|
|
||||||
println(foo(5, 42))
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
122
|
|
||||||
47
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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 a
|
|
||||||
|
|
||||||
fun foo(n: Int, block: (Int) -> Int): Int {
|
|
||||||
val arr = IntArray(n) { block(it) }
|
|
||||||
var sum = 0
|
|
||||||
for (x in arr) sum += x
|
|
||||||
return sum
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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 a.*
|
|
||||||
import kotlin.test.*
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
assertEquals(42, foo(7) { it * 2 })
|
|
||||||
}
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
package a
|
|
||||||
|
|
||||||
class E(val x: String) {
|
|
||||||
inner class Inner {
|
|
||||||
inline fun foo(y: String) = x + y
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-5
@@ -1,5 +0,0 @@
|
|||||||
import a.*
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
println(E("O").Inner().foo("K"))
|
|
||||||
}
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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 a
|
|
||||||
|
|
||||||
fun IntArray.forEachNoInline(block: (Int) -> Unit) = this.forEach { block(it) }
|
|
||||||
|
|
||||||
inline fun foo(values: IntArray, crossinline block: (Int, Int, Int) -> Int): Int {
|
|
||||||
val o = object {
|
|
||||||
lateinit var s: String
|
|
||||||
var x: Int = 42
|
|
||||||
}
|
|
||||||
values.forEachNoInline {
|
|
||||||
o.x = block(o.x, o.s.length, it)
|
|
||||||
}
|
|
||||||
return o.x
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
|
|
||||||
|
|
||||||
import a.*
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
try {
|
|
||||||
val res = foo(intArrayOf(1, 2, 3)) { x, y, z -> x + y - z }
|
|
||||||
println(res)
|
|
||||||
} catch (t: UninitializedPropertyAccessException) {
|
|
||||||
println("OK")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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 a.*
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
println(fold(0, intArrayOf(1, 2, 3)) { x, y -> x + y })
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
6
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2021 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
open class Outer(val x: Int) {
|
|
||||||
open inner class Inner1
|
|
||||||
inner class Middle(x: Int) : Outer(x) {
|
|
||||||
inner class Inner2 : Inner1() {
|
|
||||||
fun foo() = this@Outer.x + this@Middle.x
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2021 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
val o = Outer(42).Middle(117).Inner2()
|
|
||||||
println(o.foo())
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
159
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2021 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
open class Outer {
|
|
||||||
open inner class Inner1
|
|
||||||
inner class Middle {
|
|
||||||
inner class Inner2 : Inner1() {
|
|
||||||
fun getOuter() = this@Outer
|
|
||||||
fun getMiddle() = this@Middle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2021 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
val o = Outer().Middle().Inner2()
|
|
||||||
println(o.getOuter() != Outer())
|
|
||||||
println(o.getMiddle() != Outer().Middle())
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
true
|
|
||||||
true
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2021 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
open class Foo(val z: Int) {
|
|
||||||
open inner class FooInner {
|
|
||||||
fun foo() = z
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2021 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Bar : Foo(42) {
|
|
||||||
inner class BarInner(val x: Int) : FooInner()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
val o = Bar().BarInner(117)
|
|
||||||
println(o.x)
|
|
||||||
println(o.foo())
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
117
|
|
||||||
42
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
open class A {
|
|
||||||
open inner class Inner {
|
|
||||||
val x = 42
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
open class B : A() {
|
|
||||||
open inner class Inner : A.Inner()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
B().Inner()
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 a
|
|
||||||
|
|
||||||
class A(val x: Int)
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 a.A
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
val p1 = A::x
|
|
||||||
println(p1.get(A(42)))
|
|
||||||
val a = A(117)
|
|
||||||
val p2 = a::x
|
|
||||||
println(p2.get())
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
42
|
|
||||||
117
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2021 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun foo() {
|
|
||||||
println("linked library")
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2021 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
foo()
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
linked library
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 qwerty
|
|
||||||
|
|
||||||
fun foo(a: Int): Int {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 qwerty
|
|
||||||
|
|
||||||
fun foo2(a: Int): Int {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 foo
|
|
||||||
fun foo() {}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
println("Hello")
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Hello
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Private classes
|
|
||||||
private open class A {
|
|
||||||
public fun foo1() = println("PASS")
|
|
||||||
internal fun foo2() = println("PASS")
|
|
||||||
protected fun foo3() = println("PASS")
|
|
||||||
}
|
|
||||||
|
|
||||||
private class B:A() {
|
|
||||||
fun foo4() = foo3()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Private interfaces
|
|
||||||
private interface C {
|
|
||||||
fun foo() = println("PASS")
|
|
||||||
}
|
|
||||||
|
|
||||||
private class D: C
|
|
||||||
|
|
||||||
fun runner() {
|
|
||||||
B().foo1()
|
|
||||||
B().foo2()
|
|
||||||
B().foo4()
|
|
||||||
|
|
||||||
D().foo()
|
|
||||||
|
|
||||||
// Objects
|
|
||||||
object : A(){
|
|
||||||
fun foo4() = foo3()
|
|
||||||
}.apply {
|
|
||||||
foo1()
|
|
||||||
foo2()
|
|
||||||
foo4()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function local classes
|
|
||||||
abstract class E {
|
|
||||||
public open fun foo1() = println("PASS")
|
|
||||||
internal open fun foo2() = println("PASS")
|
|
||||||
protected open fun foo3() = println("PASS")
|
|
||||||
}
|
|
||||||
class F : E() {
|
|
||||||
fun foo4() = foo3()
|
|
||||||
}
|
|
||||||
F().foo1()
|
|
||||||
F().foo2()
|
|
||||||
F().foo4()
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
runner()
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
PASS
|
|
||||||
PASS
|
|
||||||
PASS
|
|
||||||
PASS
|
|
||||||
PASS
|
|
||||||
PASS
|
|
||||||
PASS
|
|
||||||
PASS
|
|
||||||
PASS
|
|
||||||
PASS
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* that can be found in the LICENSE file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* that can be found in the LICENSE file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 qwerty.*
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
val size = foo(foo2(args.size))
|
|
||||||
println(size.toString())
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
0
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fun foo(): String{
|
|
||||||
val bar: String by lazy {
|
|
||||||
"OK"
|
|
||||||
}
|
|
||||||
|
|
||||||
return bar
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import kotlin.test.*
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
assertEquals("OK", foo())
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun test_direct() {
|
|
||||||
val mutListInt = mutableListOf<Int>(1, 2, 3, 4)
|
|
||||||
val mutListNum = mutableListOf<Number>(9, 10, 11, 12)
|
|
||||||
val mutListAny = mutableListOf<Any>(5, 6, 7, 8)
|
|
||||||
|
|
||||||
mangle1(mutListInt)
|
|
||||||
mangle1(mutListNum)
|
|
||||||
mangle1(mutListAny)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test_param() {
|
|
||||||
val mutListInt = mutableListOf<Int>(1, 2, 3, 4)
|
|
||||||
val mutListNum = mutableListOf<Number>(9, 10, 11, 12)
|
|
||||||
val mutListAny = mutableListOf<Any>(5, 6, 7, 8)
|
|
||||||
|
|
||||||
mangle2(mutListInt)
|
|
||||||
mangle2(mutListNum)
|
|
||||||
mangle2(mutListAny)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test_multiple_constructors() {
|
|
||||||
val any = mapOf<Float, Float>()
|
|
||||||
val comparable = "some string"
|
|
||||||
val number = 17
|
|
||||||
|
|
||||||
mangle3(any)
|
|
||||||
mangle3(comparable)
|
|
||||||
mangle3(number)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
test_direct()
|
|
||||||
test_param()
|
|
||||||
test_multiple_constructors()
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
Int direct [1, 2, 3, 4]
|
|
||||||
out Number direct [9, 10, 11, 12]
|
|
||||||
star direct [5, 6, 7, 8]
|
|
||||||
Int param [1, 2, 3, 4]
|
|
||||||
out Number param [9, 10, 11, 12]
|
|
||||||
star param [5, 6, 7, 8]
|
|
||||||
no constructors {}
|
|
||||||
single constructor some string
|
|
||||||
two constructors 17
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public fun mangle1(l: List<Int>) {
|
|
||||||
println("Int direct $l")
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun mangle1(l: List<out Number>) {
|
|
||||||
println("out Number direct $l")
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun mangle1(l: List<*>) {
|
|
||||||
println("star direct $l")
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun <T> mangle2(l: T) where T: List<Int>
|
|
||||||
{
|
|
||||||
println("Int param $l")
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun <T> mangle2(l: T) where T: List<out Number>
|
|
||||||
{
|
|
||||||
println("out Number param $l")
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun <T> mangle2(l: T) where T: List<*>
|
|
||||||
{
|
|
||||||
println("star param $l")
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun <T> mangle3(l: T)
|
|
||||||
{
|
|
||||||
println("no constructors $l")
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun <T> mangle3(l: T)
|
|
||||||
where
|
|
||||||
T: Comparable<T>
|
|
||||||
{
|
|
||||||
println("single constructor $l")
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun <T> mangle3(l: T)
|
|
||||||
where
|
|
||||||
T: Comparable<T>,
|
|
||||||
T: Number
|
|
||||||
{
|
|
||||||
println("two constructors $l")
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 foo.bar
|
|
||||||
|
|
||||||
class R<T> {
|
|
||||||
inline fun bar(t: T) {
|
|
||||||
println("just a single class: $t")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class C {
|
|
||||||
inline fun foo() {
|
|
||||||
println("first level")
|
|
||||||
}
|
|
||||||
|
|
||||||
class D {
|
|
||||||
inline fun foo() {
|
|
||||||
println("second level")
|
|
||||||
}
|
|
||||||
|
|
||||||
class E {
|
|
||||||
inline fun foo() {
|
|
||||||
println("third levelxz")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class C2 {
|
|
||||||
inline fun foo() {
|
|
||||||
println("inner first level")
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class D2 {
|
|
||||||
inline fun foo() {
|
|
||||||
println("inner second level")
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class E2 {
|
|
||||||
inline fun foo() {
|
|
||||||
println("inner third level")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class C3<X> {
|
|
||||||
inline fun foo(x: X) {
|
|
||||||
println("types first level: $x")
|
|
||||||
}
|
|
||||||
|
|
||||||
class D3<X> {
|
|
||||||
inline fun foo(x: X) {
|
|
||||||
println("types second level $x")
|
|
||||||
}
|
|
||||||
|
|
||||||
class E3<X> {
|
|
||||||
inline fun foo(x: X) {
|
|
||||||
println("types third level $x")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class C4<X> {
|
|
||||||
inline fun foo(x: X) {
|
|
||||||
println("inner types first level: $x")
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class D4<Y> {
|
|
||||||
inline fun foo(x: X, y: Y) {
|
|
||||||
println("inner types second level $x, $y")
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class E4<Z> {
|
|
||||||
inline fun foo(x: X, y: Y, z: Z) {
|
|
||||||
println("inner types third level $x, $y, $z")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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 foo.bar.*
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
val c = C()
|
|
||||||
val d = C.D()
|
|
||||||
val e = C.D.E()
|
|
||||||
c.foo()
|
|
||||||
d.foo()
|
|
||||||
e.foo()
|
|
||||||
|
|
||||||
val c2 = C2()
|
|
||||||
val d2 = C2().D2()
|
|
||||||
val e2 = C2().D2().E2()
|
|
||||||
c2.foo()
|
|
||||||
d2.foo()
|
|
||||||
e2.foo()
|
|
||||||
|
|
||||||
val c3 = C3<Int>()
|
|
||||||
val d3 = C3.D3<String>()
|
|
||||||
val e3 = C3.D3.E3<Float>()
|
|
||||||
c3.foo(13)
|
|
||||||
d3.foo("cha-cha-cha")
|
|
||||||
e3.foo(1.0f)
|
|
||||||
|
|
||||||
// This part doesn't work with file local inline functions.
|
|
||||||
// So disabled for now.
|
|
||||||
// val c4 = C4<Int>()
|
|
||||||
// val d4 = C4<String>().D4<Int>()
|
|
||||||
// val e4 = C4<Int>().D4<String>().E4<Int>()
|
|
||||||
// c4.foo(13)
|
|
||||||
// d4.foo("cawabunga", 17)
|
|
||||||
// e4.foo(19, "raqa-taqa", 23)
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
first level
|
|
||||||
second level
|
|
||||||
third levelxz
|
|
||||||
inner first level
|
|
||||||
inner second level
|
|
||||||
inner third level
|
|
||||||
types first level: 13
|
|
||||||
types second level cha-cha-cha
|
|
||||||
types third level 1.0
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum class Color {
|
|
||||||
RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW
|
|
||||||
}
|
|
||||||
|
|
||||||
fun determineColor(code: Int): Color = when (code) {
|
|
||||||
0 -> Color.BLUE
|
|
||||||
1 -> Color.MAGENTA
|
|
||||||
else -> Color.CYAN
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
println(Color.RED.ordinal)
|
|
||||||
println(Color.GREEN.ordinal)
|
|
||||||
println(Color.BLUE.ordinal)
|
|
||||||
val color = when (determineColor(args.size)) {
|
|
||||||
Color.RED -> println("r")
|
|
||||||
Color.GREEN -> println("g")
|
|
||||||
Color.BLUE -> println("b")
|
|
||||||
Color.CYAN -> println("c")
|
|
||||||
Color.MAGENTA -> println("m")
|
|
||||||
Color.YELLOW -> println("y")
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
0
|
|
||||||
1
|
|
||||||
2
|
|
||||||
b
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
inline fun foo() {
|
|
||||||
try {
|
|
||||||
try {
|
|
||||||
throw Exception("XXX")
|
|
||||||
} catch (e: Throwable) {
|
|
||||||
println("Gotcha1: ${e.message}")
|
|
||||||
throw Exception("YYY")
|
|
||||||
}
|
|
||||||
} catch (e: Throwable) {
|
|
||||||
println("Gotcha2: ${e.message}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
foo()
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Gotcha1: XXX
|
|
||||||
Gotcha2: YYY
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
inline fun foo(x: Char = '\u042b') = x
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
println(foo())
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Ы
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
inline val Int.prop get() = SomeDataClass(second = this)
|
|
||||||
|
|
||||||
data class SomeDataClass(val first: Int = 17, val second: Int = 19, val third: Int = 23)
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
println(666.prop)
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
SomeDataClass(first=17, second=666, third=23)
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
inline fun foo() {
|
|
||||||
do {
|
|
||||||
var x: Int = 999
|
|
||||||
println(x)
|
|
||||||
} while (x != 999)
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
foo()
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
999
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun bar(vararg x: Int) {
|
|
||||||
x.forEach {
|
|
||||||
println(it)
|
|
||||||
}
|
|
||||||
println("size: ${x.size}")
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun foo() = bar(17, 19, 23, *intArrayOf(29, 31))
|
|
||||||
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
foo()
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
17
|
|
||||||
19
|
|
||||||
23
|
|
||||||
29
|
|
||||||
31
|
|
||||||
size: 5
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// MODULE: lib
|
||||||
|
// FILE: lib.kt
|
||||||
|
|
||||||
|
package a
|
||||||
|
|
||||||
|
interface A<T> {
|
||||||
|
fun foo(): T
|
||||||
|
}
|
||||||
|
|
||||||
|
open class C: A<Int> {
|
||||||
|
override fun foo(): Int = 42
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: main(lib)
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
import a.*
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
class B: C()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val b = B()
|
||||||
|
assertEquals(42, b.foo())
|
||||||
|
val c: C = b
|
||||||
|
assertEquals(42, c.foo())
|
||||||
|
val a: A<Int> = b
|
||||||
|
assertEquals(42, a.foo())
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// MODULE: lib
|
||||||
|
// FILE: lib.kt
|
||||||
|
|
||||||
|
sealed class Tag {
|
||||||
|
abstract fun value(): Any
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class TagBoolean : Tag() {
|
||||||
|
abstract override fun value(): String
|
||||||
|
|
||||||
|
object True : TagBoolean() {
|
||||||
|
override fun value() = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
object False : TagBoolean() {
|
||||||
|
override fun value() = "FAIL"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: main(lib)
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
fun box() = TagBoolean.True.value()
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user