[K/N][Tests] Move codegen test sources cycles..innerClass
^KT-61259
This commit is contained in:
committed by
Space Team
parent
35d2be25b2
commit
71a834b778
@@ -303,10 +303,6 @@ linkTest("localDelegatedPropertyLink") {
|
||||
lib = "lower/local_delegated_property_link/lib.kt"
|
||||
}
|
||||
|
||||
tasks.register("sum", KonanLocalTest) {
|
||||
source = "codegen/function/sum.kt"
|
||||
}
|
||||
|
||||
tasks.register("method_call", KonanLocalTest) {
|
||||
source = "codegen/object/method_call.kt"
|
||||
}
|
||||
@@ -343,115 +339,6 @@ standaloneTest("object_globalInitializer") {
|
||||
source = "codegen/object/globalInitializer.kt"
|
||||
}
|
||||
|
||||
tasks.register("aritmetic", KonanLocalTest) {
|
||||
source = "codegen/function/arithmetic.kt"
|
||||
}
|
||||
|
||||
tasks.register("sum1", KonanLocalTest) {
|
||||
source = "codegen/function/sum_foo_bar.kt"
|
||||
}
|
||||
|
||||
tasks.register("sum2", KonanLocalTest) {
|
||||
source = "codegen/function/sum_imm.kt"
|
||||
}
|
||||
|
||||
tasks.register("sum_func", KonanLocalTest) {
|
||||
source = "codegen/function/sum_func.kt"
|
||||
}
|
||||
|
||||
tasks.register("sum_mixed", KonanLocalTest) {
|
||||
source = "codegen/function/sum_mixed.kt"
|
||||
}
|
||||
|
||||
tasks.register("sum_illy", KonanLocalTest) {
|
||||
source = "codegen/function/sum_silly.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults", KonanLocalTest) {
|
||||
source = "codegen/function/defaults.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults1", KonanLocalTest) {
|
||||
source = "codegen/function/defaults1.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults2", KonanLocalTest) {
|
||||
source = "codegen/function/defaults2.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults3", KonanLocalTest) {
|
||||
source = "codegen/function/defaults3.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults4", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/defaults4.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults5", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/defaults5.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults6", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/defaults6.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults7", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/defaults7.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults8", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/defaults8.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults9", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/defaults9.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults10", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/defaults10.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults_from_fake_override", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/defaultsFromFakeOverride.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults_with_vararg1", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/defaultsWithVarArg1.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults_with_vararg2", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/defaultsWithVarArg2.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_defaults_with_inline_classes", KonanLocalTest) {
|
||||
source = "codegen/function/defaultsWithInlineClasses.kt"
|
||||
}
|
||||
|
||||
tasks.register("sum_3const", KonanLocalTest) {
|
||||
source = "codegen/function/sum_3const.kt"
|
||||
}
|
||||
|
||||
standaloneTest("function_nothingN_returning_safe_call") {
|
||||
flags = ["-g", "-entry", "codegen.function.nothingN_returning_safe_call.main"]
|
||||
source = "codegen/function/nothingNReturningSafeCall.kt"
|
||||
}
|
||||
|
||||
standaloneTest("unreachable_statement_after_return") {
|
||||
flags = ["-g", "-entry", "codegen.function.unreachable_statement_after_return.main"]
|
||||
source = "codegen/function/unreachableStatementAfterReturn.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("runtime_basic_init") {
|
||||
source = "runtime/basic/init.kt"
|
||||
expectedExitStatus = 0
|
||||
@@ -710,51 +597,6 @@ standaloneTest("leakMemoryWithWorkerTermination") {
|
||||
source = "runtime/workers/leak_memory_with_worker_termination.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum0", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/test0.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum1", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/test1.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum_valueOf", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/valueOf.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum_values", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/values.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum_vCallNoEntryClass", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/vCallNoEntryClass.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum_vCallWithEntryClass", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/vCallWithEntryClass.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum_companionObject", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/companionObject.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum_interfaceCallNoEntryClass", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/interfaceCallNoEntryClass.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum_interfaceCallWithEntryClass", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/interfaceCallWithEntryClass.kt"
|
||||
}
|
||||
|
||||
linkTest("enum_linkTest") {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/linkTest_main.kt"
|
||||
@@ -767,86 +609,12 @@ linkTest("enum_openMethodNoOverrides") {
|
||||
lib = "codegen/enum/openMethodNoOverrides_lib.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum_varargParam", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/varargParam.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum_nested", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/nested.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum_isFrozen", KonanLocalTest) {
|
||||
source = "codegen/enum/isFrozen.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum_loop", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/loop.kt"
|
||||
}
|
||||
|
||||
tasks.register("enum_reorderedArguments", KonanLocalTest) {
|
||||
source = "codegen/enum/reorderedArguments.kt"
|
||||
}
|
||||
|
||||
standaloneTest('switchLowering') {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/switchLowering.kt"
|
||||
flags = ['-XXLanguage:-ProhibitComparisonOfIncompatibleEnums', '-e', 'codegen.enum.switchLowering.main']
|
||||
}
|
||||
|
||||
tasks.register("enum_lambdaInDefault", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/enum/lambdaInDefault.kt"
|
||||
}
|
||||
|
||||
linkTest("mangling") {
|
||||
useGoldenData = true
|
||||
source = "mangling/mangling.kt"
|
||||
lib = "mangling/manglinglib.kt"
|
||||
}
|
||||
|
||||
tasks.register("innerClass_simple", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/innerClass/simple.kt"
|
||||
}
|
||||
|
||||
tasks.register("innerClass_getOuterVal", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/innerClass/getOuterVal.kt"
|
||||
}
|
||||
|
||||
tasks.register("innerClass_generic", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/innerClass/generic.kt"
|
||||
}
|
||||
|
||||
tasks.register("innerClass_doubleInner", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/innerClass/doubleInner.kt"
|
||||
}
|
||||
|
||||
tasks.register("innerClass_qualifiedThis", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/innerClass/qualifiedThis.kt"
|
||||
}
|
||||
|
||||
tasks.register("innerClass_superOuter", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/innerClass/superOuter.kt"
|
||||
}
|
||||
|
||||
tasks.register("innerClass_noPrimaryConstructor", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/innerClass/noPrimaryConstructor.kt"
|
||||
}
|
||||
|
||||
tasks.register("innerClass_secondaryConstructor", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/innerClass/secondaryConstructor.kt"
|
||||
}
|
||||
|
||||
linkTest("innerClass_linkTest") {
|
||||
source = "codegen/innerClass/linkTest_main.kt"
|
||||
lib = "codegen/innerClass/linkTest_lib.kt"
|
||||
@@ -930,129 +698,11 @@ tasks.register("localClass_tryCatch", KonanLocalTest) {
|
||||
source = "codegen/localClass/tryCatch.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_localFunction", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/localFunction.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_localFunction2", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/localFunction2.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_localFunction3", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/localFunction3.kt"
|
||||
}
|
||||
|
||||
tasks.register("initializers_correctOrder1", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/initializers/correctOrder1.kt"
|
||||
}
|
||||
|
||||
tasks.register("initializers_correctOrder2", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/initializers/correctOrder2.kt"
|
||||
}
|
||||
|
||||
standaloneTest("initializers_correctOrder3") {
|
||||
source = "codegen/initializers/correctOrder3.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("initializers_globalInitedAfterAccessingFile") {
|
||||
source = "codegen/initializers/globalInitedAfterAccessingFile.kt"
|
||||
}
|
||||
|
||||
standaloneTest("initializers_globalNotInitedAfterAccessingClassInternals") {
|
||||
source = "codegen/initializers/globalNotInitedAfterAccessingClassInternals.kt"
|
||||
}
|
||||
|
||||
standaloneTest("initializers_globalInitedBeforeThreadLocal") {
|
||||
source = "codegen/initializers/globalInitedBeforeThreadLocal.kt"
|
||||
}
|
||||
|
||||
standaloneTest("initializers_eagerInitializationGlobal1") {
|
||||
source = "codegen/initializers/eagerInitializationGlobal1.kt"
|
||||
}
|
||||
|
||||
standaloneTest("initializers_eagerInitializationGlobal2") {
|
||||
source = "codegen/initializers/eagerInitializationGlobal2.kt"
|
||||
}
|
||||
|
||||
standaloneTest("initializers_eagerInitializationThreadLocal1") {
|
||||
source = "codegen/initializers/eagerInitializationThreadLocal1.kt"
|
||||
}
|
||||
|
||||
standaloneTest("initializers_eagerInitializationThreadLocal2") {
|
||||
source = "codegen/initializers/eagerInitializationThreadLocal2.kt"
|
||||
}
|
||||
|
||||
standaloneTest("initializers_testInfrastructure") {
|
||||
source = "codegen/initializers/testInfrastructure.kt"
|
||||
flags = ["-tr"]
|
||||
}
|
||||
|
||||
standaloneTest("initializers_workers1") {
|
||||
source = "codegen/initializers/workers1.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("initializers_workers2") {
|
||||
source = "codegen/initializers/workers2.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("initializers_when1") {
|
||||
source = "codegen/initializers/when1.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("initializers_when2") {
|
||||
source = "codegen/initializers/when2.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("initializers_throw1") {
|
||||
source = "codegen/initializers/throw1.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("initializers_throw2") {
|
||||
source = "codegen/initializers/throw2.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("initializers_while1") {
|
||||
source = "codegen/initializers/while1.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("initializers_while2") {
|
||||
source = "codegen/initializers/while2.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("initializers_while3") {
|
||||
source = "codegen/initializers/while3.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("initializers_return1") {
|
||||
source = "codegen/initializers/return1.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("initializers_return2") {
|
||||
source = "codegen/initializers/return2.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
standaloneTest("initializers_object") {
|
||||
source = "codegen/initializers/object.kt"
|
||||
flags = ['-Xir-property-lazy-initialization=enable']
|
||||
}
|
||||
|
||||
linkTest("initializers_linkTest1") {
|
||||
useGoldenData = true
|
||||
source = "codegen/initializers/linkTest1_main.kt"
|
||||
@@ -1070,11 +720,6 @@ linkTest("initializers_sharedVarInInitBlock") {
|
||||
lib = "codegen/initializers/sharedVarInInitBlock_lib.kt"
|
||||
}
|
||||
|
||||
standaloneTest("initializers_static") {
|
||||
source = "codegen/initializers/static.kt"
|
||||
flags = ['-opt-in=kotlin.native.internal.InternalForKotlinNative', "-tr"]
|
||||
}
|
||||
|
||||
linkTest("bridges_linkTest") {
|
||||
useGoldenData = true
|
||||
source = "codegen/bridges/linkTest_main.kt"
|
||||
@@ -1093,26 +738,6 @@ linkTest("classDelegation_linkTest") {
|
||||
lib = "codegen/classDelegation/linkTest_lib.kt"
|
||||
}
|
||||
|
||||
tasks.register("delegatedProperty_simpleVal", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/delegatedProperty/simpleVal.kt"
|
||||
}
|
||||
|
||||
tasks.register("delegatedProperty_simpleVar", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/delegatedProperty/simpleVar.kt"
|
||||
}
|
||||
|
||||
tasks.register("delegatedProperty_packageLevel", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/delegatedProperty/packageLevel.kt"
|
||||
}
|
||||
|
||||
tasks.register("delegatedProperty_local", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/delegatedProperty/local.kt"
|
||||
}
|
||||
|
||||
linkTest("delegatedProperty_delegatedOverride") {
|
||||
useGoldenData = true
|
||||
source = "codegen/delegatedProperty/delegatedOverride_main.kt"
|
||||
@@ -1125,21 +750,6 @@ linkTest("delegatedProperty_correctFieldsOrder") {
|
||||
lib = "codegen/delegatedProperty/correctFieldsOrder_lib.kt"
|
||||
}
|
||||
|
||||
tasks.register("delegatedProperty_lazy", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/delegatedProperty/lazy.kt"
|
||||
}
|
||||
|
||||
tasks.register("delegatedProperty_observable", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/delegatedProperty/observable.kt"
|
||||
}
|
||||
|
||||
tasks.register("delegatedProperty_map", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/delegatedProperty/map.kt"
|
||||
}
|
||||
|
||||
tasks.register("propertyCallableReference_valClass", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/propertyCallableReference/valClass.kt"
|
||||
@@ -1257,54 +867,11 @@ tasks.register("ktype_nonReified", KonanLocalTest) {
|
||||
source = "codegen/ktype/nonReified.kt"
|
||||
}
|
||||
|
||||
tasks.register("stack_array", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/escapeAnalysis/stack_array.kt"
|
||||
}
|
||||
|
||||
tasks.register("immutable_binary_blob_in_lambda", KonanLocalTest) {
|
||||
source = "lower/immutable_blob_in_lambda.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
tasks.register("bool_yes", KonanLocalTest) {
|
||||
source = "codegen/function/boolean.kt"
|
||||
}
|
||||
|
||||
tasks.register("named", KonanLocalTest) {
|
||||
source = "codegen/function/named.kt"
|
||||
}
|
||||
|
||||
|
||||
tasks.register("plus_eq", KonanLocalTest) {
|
||||
source = "codegen/function/plus_eq.kt"
|
||||
}
|
||||
|
||||
tasks.register("minus_eq", KonanLocalTest) {
|
||||
source = "codegen/function/minus_eq.kt"
|
||||
}
|
||||
|
||||
tasks.register("eqeq", KonanLocalTest) {
|
||||
source = "codegen/function/eqeq.kt"
|
||||
}
|
||||
|
||||
tasks.register("function_referenceBigArity", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/function/referenceBigArity.kt"
|
||||
}
|
||||
|
||||
tasks.register("cycle", KonanLocalTest) {
|
||||
source = "codegen/cycles/cycle.kt"
|
||||
}
|
||||
|
||||
tasks.register("cycle_do", KonanLocalTest) {
|
||||
source = "codegen/cycles/cycle_do.kt"
|
||||
}
|
||||
|
||||
tasks.register("cycle_for", KonanLocalTest) {
|
||||
source = "codegen/cycles/cycle_for.kt"
|
||||
}
|
||||
|
||||
tasks.register("abstract_super", KonanLocalTest) {
|
||||
source = "datagen/rtti/abstract_super.kt"
|
||||
}
|
||||
@@ -1337,10 +904,6 @@ tasks.register("empty_string", KonanLocalTest) {
|
||||
source = "datagen/literals/empty_string.kt"
|
||||
}
|
||||
|
||||
tasks.register("intrinsic", KonanLocalTest) {
|
||||
source = "codegen/function/intrinsic.kt"
|
||||
}
|
||||
|
||||
// Disabled until we extract the classes that should be
|
||||
// always present from stdlib into a separate binary.
|
||||
//
|
||||
@@ -1645,16 +1208,6 @@ tasks.register("finally_returnsDifferentTypes", KonanLocalTest) {
|
||||
source = "codegen/try/returnsDifferentTypes.kt"
|
||||
}
|
||||
|
||||
tasks.register("scope1", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/dataflow/scope1.kt"
|
||||
}
|
||||
|
||||
tasks.register("uninitialized_val", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/dataflow/uninitialized_val.kt"
|
||||
}
|
||||
|
||||
tasks.register("try1", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/try/try1.kt"
|
||||
@@ -1675,35 +1228,6 @@ tasks.register("try4", KonanLocalTest) {
|
||||
source = "codegen/try/try4.kt"
|
||||
}
|
||||
|
||||
standaloneTest("devirtualization_lateinitInterface") {
|
||||
disabled = (cacheTesting != null) // Cache is not compatible with -opt.
|
||||
useGoldenData = true
|
||||
flags = ["-opt"]
|
||||
source = "codegen/devirtualization/lateinitInterface.kt"
|
||||
}
|
||||
|
||||
standaloneTest("devirtualization_getter_looking_as_box_function") {
|
||||
disabled = (cacheTesting != null) // Cache is not compatible with -opt.
|
||||
useGoldenData = true
|
||||
flags = ["-opt"]
|
||||
source = "codegen/devirtualization/getter_looking_as_box_function.kt"
|
||||
}
|
||||
|
||||
standaloneTest("devirtualization_inline_getter") {
|
||||
disabled = (cacheTesting != null) // Cache is not compatible with -opt.
|
||||
useGoldenData = true
|
||||
flags = ["-opt"]
|
||||
source = "codegen/devirtualization/inline_getter.kt"
|
||||
}
|
||||
|
||||
|
||||
standaloneTest("devirtualization_anonymousObject") {
|
||||
disabled = (cacheTesting != null) // Cache is not compatible with -opt.
|
||||
useGoldenData = true
|
||||
flags = ["-opt"]
|
||||
source = "codegen/devirtualization/anonymousObject.kt"
|
||||
}
|
||||
|
||||
tasks.register("interfaceCallsNCasts_conservativeItable", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/interfaceCallsNCasts/conservativeItable.kt"
|
||||
@@ -1831,22 +1355,6 @@ tasks.register("lambda_kt49360", KonanLocalTest) {
|
||||
source = "codegen/lambda/lambda_kt49360.kt"
|
||||
}
|
||||
|
||||
tasks.register("funInterface_implIsNotFunction", KonanLocalTest) {
|
||||
source = "codegen/funInterface/implIsNotFunction.kt"
|
||||
}
|
||||
|
||||
tasks.register("funInterface_nonTrivialProjectionInSuperType", KonanLocalTest) {
|
||||
source = "codegen/funInterface/nonTrivialProjectionInSuperType.kt"
|
||||
}
|
||||
|
||||
tasks.register("funInterface_kt43887", KonanLocalTest) {
|
||||
source = "codegen/funInterface/kt43887.kt"
|
||||
}
|
||||
|
||||
tasks.register("funInterface_kt49384", KonanLocalTest) {
|
||||
source = "codegen/funInterface/kt49384.kt"
|
||||
}
|
||||
|
||||
tasks.register("objectExpression1", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/objectExpression/expr1.kt"
|
||||
@@ -1895,35 +1403,6 @@ tasks.register("initializers8", KonanLocalTest) {
|
||||
source = "runtime/basic/initializers8.kt"
|
||||
}
|
||||
|
||||
tasks.register("codegen_escapeAnalysis_zeroOutObjectOnAlloc", KonanLocalTest) {
|
||||
source = "codegen/escapeAnalysis/zeroOutObjectOnAlloc.kt"
|
||||
}
|
||||
|
||||
tasks.register("codegen_escapeAnalysis_recursion", KonanLocalTest) {
|
||||
source = "codegen/escapeAnalysis/recursion.kt"
|
||||
}
|
||||
|
||||
standaloneTest("codegen_escapeAnalysis_stackAllocated") {
|
||||
disabled = (cacheTesting != null) || // Cache is not compatible with -opt.
|
||||
project.globalTestArgs.contains('-g') // -g and -opt are incompatible
|
||||
flags = ['-opt', '-tr', '-opt-in=kotlin.native.internal.InternalForKotlinNative']
|
||||
source = "codegen/escapeAnalysis/stackAllocated.kt"
|
||||
}
|
||||
|
||||
standaloneTest("codegen_escapeAnalysis_string") {
|
||||
disabled = (cacheTesting != null) || // Cache is not compatible with -opt.
|
||||
project.globalTestArgs.contains('-g') // -g and -opt are incompatible
|
||||
flags = ['-opt', '-tr', '-opt-in=kotlin.native.internal.InternalForKotlinNative']
|
||||
source = "codegen/escapeAnalysis/string.kt"
|
||||
}
|
||||
|
||||
standaloneTest("codegen_escapeAnalysis_negativeArraySize") {
|
||||
disabled = (cacheTesting != null) || // Cache is not compatible with -opt.
|
||||
project.globalTestArgs.contains('-g') // -g and -opt are incompatible
|
||||
flags = ['-opt', '-tr', '-opt-in=kotlin.native.internal.InternalForKotlinNative']
|
||||
source = "codegen/escapeAnalysis/negativeArraySize.kt"
|
||||
}
|
||||
|
||||
tasks.register("memory_var1", KonanLocalTest) {
|
||||
source = "runtime/memory/var1.kt"
|
||||
}
|
||||
@@ -2042,11 +1521,6 @@ standaloneTest("array_out_of_memory") {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("inline0", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline0.kt"
|
||||
}
|
||||
|
||||
tasks.register("vararg0", KonanLocalTest) {
|
||||
source = "lower/vararg.kt"
|
||||
}
|
||||
@@ -2064,236 +1538,6 @@ standaloneTest('tailrec') {
|
||||
flags = ['-XXLanguage:-ProhibitTailrecOnVirtualMember', '-e', 'lower.tailrec.main']
|
||||
}
|
||||
|
||||
tasks.register("inline1", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline1.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline2", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline2.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline3", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline3.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline4", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline4.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline5", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline5.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline6", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline6.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline7", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline7.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline8", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline8.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline9", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline9.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline10", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline10.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline13", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline13.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline14", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline14.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline15", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline15.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline16", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline16.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline17", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline17.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline18", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline18.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline19", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline19.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline20", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline20.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline21", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline21.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline22", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline22.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline23", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline23.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline24", KonanLocalTest) {
|
||||
enabled = false
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline24.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline25", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline25.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline26", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/inline26.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_type_substitution_in_fake_override", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/typeSubstitutionInFakeOverride.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_localFunctionInInitializerBlock", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/localFunctionInInitializerBlock.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_lambdaInDefaultValue", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/lambdaInDefaultValue.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_lambdaAsAny", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/lambdaAsAny.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_getClass", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/getClass.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_statementAsLastExprInBlock", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/statementAsLastExprInBlock.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_returnLocalClassFromBlock", KonanLocalTest) {
|
||||
enabled = false
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/returnLocalClassFromBlock.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_changingCapturedLocal", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/changingCapturedLocal.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_defaultArgs", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/defaultArgs.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_propertyAccessorInline", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/propertyAccessorInline.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_twiceInlinedObject", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/twiceInlinedObject.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_localObjectReturnedFromWhen", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/localObjectReturnedFromWhen.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_genericFunctionReference", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/genericFunctionReference.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_correctOrderFunctionReference", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/correctOrderFunctionReference.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_coercionToUnit", KonanLocalTest) {
|
||||
useGoldenData = true
|
||||
source = "codegen/inline/coercionToUnit.kt"
|
||||
}
|
||||
|
||||
tasks.register("inline_redundantCoercionsCleaner", KonanLocalTest) {
|
||||
source = "codegen/inline/redundantCoercionsCleaner.kt"
|
||||
}
|
||||
|
||||
tasks.register("classDeclarationInsideInline", KonanLocalTest) {
|
||||
source = "codegen/inline/classDeclarationInsideInline.kt"
|
||||
useGoldenData = true
|
||||
}
|
||||
|
||||
tasks.register("inlineClass0", KonanLocalTest) {
|
||||
source = "codegen/inlineClass/inlineClass0.kt"
|
||||
}
|
||||
|
||||
tasks.register("inlineClass_customEquals", KonanLocalTest) {
|
||||
source = "codegen/inlineClass/customEquals.kt"
|
||||
}
|
||||
|
||||
tasks.register("inlineClass_defaultEquals", KonanLocalTest) {
|
||||
source = "codegen/inlineClass/defaultEquals.kt"
|
||||
}
|
||||
|
||||
tasks.register("inlineClass_secondaryConstructorWithGenerics", KonanLocalTest) {
|
||||
source = "codegen/inlineClass/secondaryConstructorWithGenerics.kt"
|
||||
}
|
||||
|
||||
tasks.register("inlineClass_nestedInlineClasses", KonanLocalTest) {
|
||||
source = "codegen/inlineClass/nestedInlineClasses.kt"
|
||||
}
|
||||
|
||||
tasks.register("valueClass0", KonanLocalTest) {
|
||||
source = "codegen/inlineClass/valueClass0.kt"
|
||||
}
|
||||
|
||||
tasks.register("deserialized_inline0", KonanLocalTest) {
|
||||
source = "serialization/deserialized_inline0.kt"
|
||||
}
|
||||
|
||||
@@ -1,21 +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 codegen.cycles.cycle
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun cycle(cnt: Int): Int {
|
||||
var sum = 1
|
||||
while (sum == cnt) {
|
||||
sum = sum + 1
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
if (cycle(1) != 2) throw Error()
|
||||
if (cycle(0) != 1) throw Error()
|
||||
}
|
||||
@@ -1,21 +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 codegen.cycles.cycle_do
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun cycle_do(cnt: Int): Int {
|
||||
var sum = 1
|
||||
do {
|
||||
sum = sum + 2
|
||||
} while (sum == cnt)
|
||||
return sum
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
if (cycle_do(3) != 5) throw Error()
|
||||
if (cycle_do(0) != 3) throw Error()
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.cycles.cycle_for
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun cycle_for(arr: Array<Int>) : Int {
|
||||
var sum = 0
|
||||
for (i in arr) {
|
||||
sum += i
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
if (cycle_for(Array(4, init = { it })) != 6) throw Error()
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.dataflow.scope1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
var b = true
|
||||
|
||||
@Test fun runTest() {
|
||||
var x = 1
|
||||
if (b) {
|
||||
var x = 2
|
||||
}
|
||||
println(x)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,26 +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 codegen.dataflow.uninitialized_val
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo(b: Boolean): Int {
|
||||
val x: Int
|
||||
if (b) {
|
||||
x = 1
|
||||
} else {
|
||||
x = 2
|
||||
}
|
||||
|
||||
return x
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
val uninitializedUnused: Int
|
||||
|
||||
println(foo(true))
|
||||
println(foo(false))
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
1
|
||||
2
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.delegatedProperty.lazy
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val lazyValue: String by lazy {
|
||||
println("computed!")
|
||||
"Hello"
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(lazyValue)
|
||||
println(lazyValue)
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
computed!
|
||||
Hello
|
||||
Hello
|
||||
@@ -1,27 +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 codegen.delegatedProperty.local
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
fun foo(): Int {
|
||||
class Delegate {
|
||||
operator fun getValue(receiver: Any?, p: KProperty<*>): Int {
|
||||
println(p.name)
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
val x: Int by Delegate()
|
||||
|
||||
return x
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(foo())
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
x
|
||||
42
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.delegatedProperty.map
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class User(val map: Map<String, Any?>) {
|
||||
val name: String by map
|
||||
val age: Int by map
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
val user = User(mapOf(
|
||||
"name" to "John Doe",
|
||||
"age" to 25
|
||||
))
|
||||
println(user.name) // Prints "John Doe"
|
||||
println(user.age) // Prints 25
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
John Doe
|
||||
25
|
||||
@@ -1,23 +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 codegen.delegatedProperty.observable
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class User {
|
||||
var name: String by Delegates.observable("<no name>") {
|
||||
prop, old, new ->
|
||||
println("$old -> $new")
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
val user = User()
|
||||
user.name = "first"
|
||||
user.name = "second"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
<no name> -> first
|
||||
first -> second
|
||||
@@ -1,23 +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 codegen.delegatedProperty.packageLevel
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class Delegate {
|
||||
operator fun getValue(receiver: Any?, p: KProperty<*>): Int {
|
||||
println(p.name)
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
val x: Int by Delegate()
|
||||
|
||||
@Test fun runTest() {
|
||||
println(x)
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
x
|
||||
42
|
||||
@@ -1,25 +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 codegen.delegatedProperty.simpleVal
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class Delegate {
|
||||
operator fun getValue(receiver: Any?, p: KProperty<*>): Int {
|
||||
println(p.name)
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
val x: Int by Delegate()
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(C().x)
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
x
|
||||
42
|
||||
@@ -1,35 +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 codegen.delegatedProperty.simpleVar
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class Delegate {
|
||||
var f: Int = 42
|
||||
|
||||
operator fun getValue(receiver: Any?, p: KProperty<*>): Int {
|
||||
println("get ${p.name}")
|
||||
return f
|
||||
}
|
||||
|
||||
operator fun setValue(receiver: Any?, p: KProperty<*>, value: Int) {
|
||||
println("set ${p.name}")
|
||||
f = value
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
var x: Int by Delegate()
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
val c = C()
|
||||
println(c.x)
|
||||
c.x = 117
|
||||
println(c.x)
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
get x
|
||||
42
|
||||
set x
|
||||
get x
|
||||
117
|
||||
@@ -1,22 +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.
|
||||
*/
|
||||
|
||||
interface I {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val impl = object : I {
|
||||
override fun foo() { println("zzz") }
|
||||
}
|
||||
|
||||
val delegating = object: I by impl { }
|
||||
|
||||
delegating.foo()
|
||||
}
|
||||
|
||||
fun main() {
|
||||
test()
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
zzz
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
class Foo(val box: String = "box")
|
||||
|
||||
fun main() {
|
||||
println(Foo().box)
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
box
|
||||
@@ -1,13 +0,0 @@
|
||||
interface Base { val id: Int }
|
||||
|
||||
inline class Child(override val id: Int = 1) : Base
|
||||
|
||||
interface Base2 { val prop: Base }
|
||||
class Child2(override val prop: Child) : Base2
|
||||
|
||||
fun main() {
|
||||
val x : Base = Child(5)
|
||||
println(x.id)
|
||||
val y : Base2 = Child2(Child(5))
|
||||
println(y.prop)
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
5
|
||||
Child(id=5)
|
||||
@@ -1,14 +0,0 @@
|
||||
interface I {
|
||||
fun foo(): Int
|
||||
}
|
||||
|
||||
class A : I {
|
||||
override fun foo() = 42
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
lateinit var a: I
|
||||
if (args.size == 0)
|
||||
a = A()
|
||||
println(a.foo())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
42
|
||||
@@ -1,33 +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 codegen.enum.companionObject
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Game {
|
||||
ROCK,
|
||||
PAPER,
|
||||
SCISSORS;
|
||||
|
||||
companion object {
|
||||
fun foo() = ROCK
|
||||
val bar = PAPER
|
||||
val values2 = values()
|
||||
val scissors = valueOf("SCISSORS")
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (Game.foo() != Game.ROCK) return "Fail 1"
|
||||
if (Game.bar != Game.PAPER) return "Fail 2: ${Game.bar}"
|
||||
if (Game.values().size != 3) return "Fail 3"
|
||||
if (Game.valueOf("SCISSORS") != Game.SCISSORS) return "Fail 4"
|
||||
if (Game.values2.size != 3) return "Fail 5"
|
||||
if (Game.scissors != Game.SCISSORS) return "Fail 6"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@Test fun runTest() = println(box())
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
@@ -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 codegen.enum.interfaceCallNoEntryClass
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
interface A {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
enum class Zzz(val zzz: String, val x: Int) : A {
|
||||
Z1("z1", 1),
|
||||
Z2("z2", 2),
|
||||
Z3("z3", 3);
|
||||
|
||||
override fun foo(): String{
|
||||
return "('$zzz', $x)"
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z3.foo())
|
||||
val a: A = Zzz.Z3
|
||||
println(a.foo())
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
('z3', 3)
|
||||
('z3', 3)
|
||||
@@ -1,31 +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 codegen.enum.interfaceCallWithEntryClass
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
interface A {
|
||||
fun f(): String
|
||||
}
|
||||
|
||||
enum class Zzz: A {
|
||||
Z1 {
|
||||
override fun f() = "z1"
|
||||
},
|
||||
|
||||
Z2 {
|
||||
override fun f() = "z2"
|
||||
};
|
||||
|
||||
override fun f() = ""
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z1.f() + Zzz.Z2.f())
|
||||
val a1: A = Zzz.Z1
|
||||
val a2: A = Zzz.Z2
|
||||
println(a1.f() + a2.f())
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
z1z2
|
||||
z1z2
|
||||
@@ -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.
|
||||
*/
|
||||
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class)
|
||||
package codegen.enum.isFrozen
|
||||
|
||||
import kotlin.test.*
|
||||
import kotlin.native.concurrent.*
|
||||
|
||||
enum class Zzz(val zzz: String, var value: Int = 0) {
|
||||
Z1("z1"),
|
||||
Z2("z2")
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
if (Platform.memoryModel == MemoryModel.STRICT) {
|
||||
assertTrue(Zzz.Z1.isFrozen)
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
Zzz.Z1.value = 42
|
||||
}
|
||||
assertEquals(0, Zzz.Z1.value)
|
||||
} else {
|
||||
assertFalse(Zzz.Z1.isFrozen)
|
||||
Zzz.Z1.value = 42
|
||||
assertEquals(42, Zzz.Z1.value)
|
||||
}
|
||||
}
|
||||
@@ -1,107 +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.
|
||||
*/
|
||||
|
||||
package codegen.enum.kt38540
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
public enum class Node(
|
||||
public val external: Boolean,
|
||||
public val dependsOn: Set<Node>,
|
||||
public val required: Boolean
|
||||
) {
|
||||
A(
|
||||
external = false,
|
||||
dependsOn = emptySet(),
|
||||
required = true
|
||||
),
|
||||
B(
|
||||
external = false,
|
||||
dependsOn = emptySet(),
|
||||
required = true
|
||||
),
|
||||
C(
|
||||
external = true,
|
||||
dependsOn = emptySet(),
|
||||
required = true
|
||||
),
|
||||
D(
|
||||
external = true,
|
||||
dependsOn = emptySet(),
|
||||
required = true
|
||||
),
|
||||
E(
|
||||
external = true,
|
||||
dependsOn = emptySet(),
|
||||
required = true
|
||||
),
|
||||
F(
|
||||
external = true,
|
||||
dependsOn = emptySet(),
|
||||
required = true
|
||||
),
|
||||
G(
|
||||
external = true,
|
||||
dependsOn = emptySet(),
|
||||
required = false
|
||||
),
|
||||
H(
|
||||
external = true,
|
||||
dependsOn = emptySet(),
|
||||
required = true
|
||||
),
|
||||
I(
|
||||
external = true,
|
||||
dependsOn = emptySet(),
|
||||
required = true
|
||||
),
|
||||
J(
|
||||
external = true,
|
||||
dependsOn = emptySet(),
|
||||
required = true
|
||||
),
|
||||
K(
|
||||
external = true,
|
||||
dependsOn = setOf(I),
|
||||
required = true
|
||||
),
|
||||
L(
|
||||
external = true,
|
||||
dependsOn = setOf(I),
|
||||
required = true
|
||||
),
|
||||
M(
|
||||
external = true,
|
||||
dependsOn = setOf(I),
|
||||
required = true
|
||||
),
|
||||
N(
|
||||
external = true,
|
||||
dependsOn = emptySet(),
|
||||
required = true
|
||||
),
|
||||
O(
|
||||
external = true,
|
||||
dependsOn = emptySet(),
|
||||
required = true
|
||||
),
|
||||
AG(
|
||||
external = true,
|
||||
dependsOn = emptySet(),
|
||||
required = true
|
||||
),
|
||||
FIELD_REPORT(
|
||||
external = true,
|
||||
dependsOn = setOf(AG, O, J),
|
||||
required = true
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun runTest() {
|
||||
assertTrue(Node.FIELD_REPORT.dependsOn.contains(Node.AG))
|
||||
assertTrue(Node.FIELD_REPORT.dependsOn.contains(Node.O))
|
||||
assertTrue(Node.FIELD_REPORT.dependsOn.contains(Node.J))
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.enum.lambdaInDefault
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Zzz(val value: String.() -> Int = {
|
||||
length
|
||||
}) {
|
||||
Q()
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Q)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Q
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.enum.loop
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Zzz {
|
||||
Z {
|
||||
init {
|
||||
println(Z.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z)
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
Z
|
||||
Z
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.enum.nested
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Foo {
|
||||
A;
|
||||
enum class Bar { C }
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Foo.A)
|
||||
println(Foo.Bar.C)
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
A
|
||||
C
|
||||
@@ -1,73 +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 codegen.enum.reorderedArguments
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// Regression test for https://github.com/JetBrains/kotlin-native/issues/1779
|
||||
enum class Foo(val a: Int, val b: Int, val c: Int = 0) {
|
||||
A(a = 1, b = 0),
|
||||
B(b = 1, a = 0),
|
||||
C(c = 1, b = 0, a = 0),
|
||||
D(0, 0),
|
||||
E(1, 1, 1)
|
||||
}
|
||||
|
||||
interface Base<T> {
|
||||
val value: T
|
||||
}
|
||||
|
||||
enum class Bar(override val value: Foo) : Base<Foo> {
|
||||
A(Foo.A),
|
||||
B(Foo.B),
|
||||
C(Foo.C),
|
||||
D(Foo.D),
|
||||
E(Foo.E)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
|
||||
assertEquals(Foo.A.a, 1)
|
||||
assertEquals(Foo.A.b, 0)
|
||||
assertEquals(Foo.A.c, 0)
|
||||
|
||||
assertEquals(Foo.B.a, 0)
|
||||
assertEquals(Foo.B.b, 1)
|
||||
assertEquals(Foo.B.c, 0)
|
||||
|
||||
assertEquals(Foo.C.a, 0)
|
||||
assertEquals(Foo.C.b, 0)
|
||||
assertEquals(Foo.C.c, 1)
|
||||
|
||||
assertEquals(Foo.D.a, 0)
|
||||
assertEquals(Foo.D.b, 0)
|
||||
assertEquals(Foo.D.c, 0)
|
||||
|
||||
assertEquals(Foo.E.a, 1)
|
||||
assertEquals(Foo.E.b, 1)
|
||||
assertEquals(Foo.E.c, 1)
|
||||
|
||||
assertEquals(Bar.A.value.a, 1)
|
||||
assertEquals(Bar.A.value.b, 0)
|
||||
assertEquals(Bar.A.value.c, 0)
|
||||
|
||||
assertEquals(Bar.B.value.a, 0)
|
||||
assertEquals(Bar.B.value.b, 1)
|
||||
assertEquals(Bar.B.value.c, 0)
|
||||
|
||||
assertEquals(Bar.C.value.a, 0)
|
||||
assertEquals(Bar.C.value.b, 0)
|
||||
assertEquals(Bar.C.value.c, 1)
|
||||
|
||||
assertEquals(Bar.D.value.a, 0)
|
||||
assertEquals(Bar.D.value.b, 0)
|
||||
assertEquals(Bar.D.value.c, 0)
|
||||
|
||||
assertEquals(Bar.E.value.a, 1)
|
||||
assertEquals(Bar.E.value.b, 1)
|
||||
assertEquals(Bar.E.value.c, 1)
|
||||
|
||||
}
|
||||
@@ -1,91 +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 codegen.enum.switchLowering
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class EnumA {
|
||||
A, B, C
|
||||
}
|
||||
|
||||
enum class EnumB {
|
||||
A, B
|
||||
}
|
||||
|
||||
enum class E {
|
||||
ONE, TWO, THREE
|
||||
}
|
||||
|
||||
fun produceEntry() = EnumA.A
|
||||
|
||||
// Check that we fail on comparison of different enum types.
|
||||
fun differentEnums() {
|
||||
println(when (produceEntry()) {
|
||||
EnumB.A -> "EnumB.A"
|
||||
EnumA.A -> "EnumA.A"
|
||||
EnumA.B -> "EnumA.B"
|
||||
else -> "nah"
|
||||
})
|
||||
}
|
||||
|
||||
// Nullable subject shouldn't be lowered.
|
||||
fun nullable() {
|
||||
val x: EnumA? = null
|
||||
when(x) {
|
||||
EnumA.A -> println("fail")
|
||||
else -> println("ok")
|
||||
}
|
||||
}
|
||||
|
||||
// Operator overloading won't trick us!
|
||||
fun operatorOverloading() {
|
||||
operator fun E.contains(other: E): Boolean = false
|
||||
|
||||
val y = E.ONE
|
||||
when(y) {
|
||||
in E.ONE -> println("Should not reach here")
|
||||
else -> println("ok")
|
||||
}
|
||||
}
|
||||
|
||||
fun smoke1() {
|
||||
when (produceEntry()) {
|
||||
EnumA.B -> println("error")
|
||||
EnumA.A -> println("ok")
|
||||
EnumA.C -> println("error")
|
||||
}
|
||||
}
|
||||
|
||||
fun smoke2() {
|
||||
when (produceEntry()) {
|
||||
EnumA.B -> println("error")
|
||||
else -> println("ok")
|
||||
}
|
||||
}
|
||||
|
||||
fun eA() = EnumA.A
|
||||
|
||||
fun eB() = EnumA.B
|
||||
|
||||
|
||||
fun nestedWhen() {
|
||||
println(when (eA()) {
|
||||
EnumA.A, EnumA.C -> when (eB()) {
|
||||
EnumA.B -> "ok"
|
||||
else -> "nope"
|
||||
}
|
||||
else -> "nope"
|
||||
})
|
||||
}
|
||||
|
||||
fun main() {
|
||||
differentEnums()
|
||||
nullable()
|
||||
operatorOverloading()
|
||||
smoke1()
|
||||
smoke2()
|
||||
nestedWhen()
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
EnumA.A
|
||||
ok
|
||||
ok
|
||||
ok
|
||||
ok
|
||||
ok
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.enum.test0
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val TOP_LEVEL = 5
|
||||
|
||||
enum class MyEnum(value: Int) {
|
||||
VALUE(TOP_LEVEL)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(MyEnum.VALUE.toString())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
VALUE
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.enum.test1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Zzz(val zzz: String, val x: Int) {
|
||||
Z1("z1", 1),
|
||||
Z2("z2", 2)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z1.zzz + Zzz.Z2.x)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
z12
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.enum.vCallNoEntryClass
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Zzz(val zzz: String, val x: Int) {
|
||||
Z1("z1", 1),
|
||||
Z2("z2", 2),
|
||||
Z3("z3", 3);
|
||||
|
||||
override fun toString(): String{
|
||||
return "('$zzz', $x)"
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z3.toString())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
('z3', 3)
|
||||
@@ -1,24 +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 codegen.enum.vCallWithEntryClass
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Zzz {
|
||||
Z1 {
|
||||
override fun f() = "z1"
|
||||
},
|
||||
|
||||
Z2 {
|
||||
override fun f() = "z2"
|
||||
};
|
||||
|
||||
open fun f() = ""
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z1.f() + Zzz.Z2.f())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
z1z2
|
||||
@@ -1,23 +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 codegen.enum.valueOf
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class E {
|
||||
E3,
|
||||
E1,
|
||||
E2
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(E.valueOf("E1").toString())
|
||||
println(E.valueOf("E2").toString())
|
||||
println(E.valueOf("E3").toString())
|
||||
println(enumValueOf<E>("E1").toString())
|
||||
println(enumValueOf<E>("E2").toString())
|
||||
println(enumValueOf<E>("E3").toString())
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
E1
|
||||
E2
|
||||
E3
|
||||
E1
|
||||
E2
|
||||
E3
|
||||
@@ -1,23 +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 codegen.enum.values
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class E {
|
||||
E3,
|
||||
E1,
|
||||
E2
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(E.values()[0].toString())
|
||||
println(E.values()[1].toString())
|
||||
println(E.values()[2].toString())
|
||||
println(enumValues<E>()[0].toString())
|
||||
println(enumValues<E>()[1].toString())
|
||||
println(enumValues<E>()[2].toString())
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
E3
|
||||
E1
|
||||
E2
|
||||
E3
|
||||
E1
|
||||
E2
|
||||
@@ -1,16 +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 codegen.enum.varargParam
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Piece(vararg val states: Int) {
|
||||
I(3, 4, 5)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Piece.I.states[0])
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
3
|
||||
@@ -1,19 +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.
|
||||
*/
|
||||
|
||||
package codegen.escapeAnalysis.negativeArraySize
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
const val size = -42
|
||||
|
||||
fun foo() {
|
||||
val arr = IntArray(size) { it }
|
||||
for (x in arr) println(x)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
assertFailsWith<IllegalArgumentException> { foo() }
|
||||
}
|
||||
@@ -1,24 +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 codegen.escapeAnalysis.recursion
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class A {
|
||||
var f: A? = null
|
||||
}
|
||||
|
||||
fun foo(k: Int, a1: A, a2: A): A {
|
||||
val a3 = A()
|
||||
if (k == 0)
|
||||
return a1
|
||||
a3.f = a1
|
||||
return foo(k - 1, a2, a3)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
foo(3, A(), A()).toString()
|
||||
}
|
||||
@@ -1,23 +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.
|
||||
*/
|
||||
|
||||
package codegen.escapeAnalysis.stackAllocated
|
||||
|
||||
import kotlin.test.*
|
||||
import kotlin.native.internal.*
|
||||
|
||||
class A {
|
||||
fun f(x: Int) = x + 13
|
||||
}
|
||||
|
||||
fun f(x: Int): Int {
|
||||
val a = A()
|
||||
assertTrue(a.isLocal())
|
||||
return a.f(x)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
assertEquals(f(42), 55)
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package codegen.escapeAnalysis.stack_array
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val array = IntArray(2)
|
||||
array[0] = 1
|
||||
array[1] = 2
|
||||
val check = array is IntArray
|
||||
println(check)
|
||||
println(array[0] + array[1])
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
true
|
||||
3
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.escapeAnalysis.string
|
||||
|
||||
import kotlin.test.*
|
||||
import kotlin.native.internal.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val s = String()
|
||||
assertTrue(s.isLocal())
|
||||
}
|
||||
@@ -1,20 +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 codegen.escapeAnalysis.test1
|
||||
|
||||
class A(val s: String)
|
||||
|
||||
// ----- Agressive -----
|
||||
// PointsTo:
|
||||
// RET.v@lue -> P0
|
||||
// Escapes:
|
||||
// ----- Passive -----
|
||||
// PointsTo:
|
||||
// RET.v@lue -> P0
|
||||
// Escapes:
|
||||
fun foo(a: A) = a
|
||||
|
||||
fun main() = println(foo(A("zzz")))
|
||||
@@ -1,41 +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 codegen.escapeAnalysis.test10
|
||||
|
||||
class G(val x: Int)
|
||||
|
||||
class F(val s: String) {
|
||||
var g = G(0)
|
||||
}
|
||||
|
||||
class A {
|
||||
var f = F("")
|
||||
}
|
||||
|
||||
// ----- Agressive -----
|
||||
// PointsTo:
|
||||
// P0.f -> D0
|
||||
// RET.v@lue -> D0
|
||||
// Escapes:
|
||||
// ----- Passive -----
|
||||
// PointsTo:
|
||||
// P0.f -> D0
|
||||
// RET.v@lue -> D0
|
||||
// Escapes: D0
|
||||
fun foo(a: A): F {
|
||||
val v = F("zzz")
|
||||
a.f = v
|
||||
return v
|
||||
}
|
||||
|
||||
fun bar(): F {
|
||||
val w = A()
|
||||
val u = foo(w)
|
||||
w.f.g = G(42)
|
||||
return u
|
||||
}
|
||||
|
||||
fun main() = println(bar().g.x)
|
||||
@@ -1,31 +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 codegen.escapeAnalysis.test11
|
||||
|
||||
class F(val x: Int)
|
||||
|
||||
class A(val s: String) {
|
||||
var f = F(0)
|
||||
}
|
||||
|
||||
var f: F? = null
|
||||
|
||||
// ----- Agressive -----
|
||||
// PointsTo:
|
||||
// RET.v@lue -> P0.f
|
||||
// D0 -> P0.f
|
||||
// Escapes: D0
|
||||
// ----- Passive -----
|
||||
// PointsTo:
|
||||
// RET.v@lue -> P0.f
|
||||
// D0 -> P0.f
|
||||
// Escapes: D0
|
||||
fun foo(a: A): F {
|
||||
f = a.f
|
||||
return a.f
|
||||
}
|
||||
|
||||
fun main() = println(foo(A("zzz")))
|
||||
@@ -1,20 +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 codegen.escapeAnalysis.test12
|
||||
|
||||
class A(val s: String)
|
||||
|
||||
// ----- Agressive -----
|
||||
// PointsTo:
|
||||
// RET.v@lue -> P0.inte$tines
|
||||
// Escapes:
|
||||
// ----- Passive -----
|
||||
// PointsTo:
|
||||
// RET.v@lue -> P0.inte$tines
|
||||
// Escapes:
|
||||
fun foo(arr: Array<A>) = arr[0]
|
||||
|
||||
fun main() = println(foo(arrayOf(A("zzz"))).s)
|
||||
@@ -1,20 +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 codegen.escapeAnalysis.test13
|
||||
|
||||
class A {
|
||||
var f: A? = null
|
||||
}
|
||||
|
||||
fun foo(a: A, k: Int): A {
|
||||
return if (k == 0) a else foo(a.f!!, k - 1)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val a = A()
|
||||
a.f = A()
|
||||
println(foo(a, 1))
|
||||
}
|
||||
@@ -1,20 +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 codegen.escapeAnalysis.test2
|
||||
|
||||
class A(val s: String)
|
||||
|
||||
// ----- Agressive -----
|
||||
// PointsTo:
|
||||
// RET.v@lue -> P0.s
|
||||
// Escapes:
|
||||
// ----- Passive -----
|
||||
// PointsTo:
|
||||
// RET.v@lue -> P0.s
|
||||
// Escapes:
|
||||
fun foo(a: A) = a.s
|
||||
|
||||
fun main() = println(foo(A("zzz")))
|
||||
@@ -1,28 +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 codegen.escapeAnalysis.test3
|
||||
|
||||
class A(val s: String)
|
||||
class B {
|
||||
var s: String? = null
|
||||
}
|
||||
|
||||
// ----- Agressive -----
|
||||
// PointsTo:
|
||||
// P1.s -> P0.s
|
||||
// RET.v@lue -> P0.s
|
||||
// Escapes:
|
||||
// ----- Passive -----
|
||||
// PointsTo:
|
||||
// P1.s -> P0.s
|
||||
// RET.v@lue -> P0.s
|
||||
// Escapes:
|
||||
fun foo(a: A, b: B): String {
|
||||
b.s = a.s
|
||||
return a.s
|
||||
}
|
||||
|
||||
fun main() = println(foo(A("zzz"), B()))
|
||||
@@ -1,30 +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 codegen.escapeAnalysis.test4
|
||||
|
||||
class A(val s: String)
|
||||
class B {
|
||||
var f: A = A("qzz")
|
||||
}
|
||||
class C {
|
||||
var g: B = B()
|
||||
}
|
||||
|
||||
// ----- Agressive -----
|
||||
// PointsTo:
|
||||
// P0.g.f -> P1.g.f
|
||||
// RET.v@lue -> D0
|
||||
// Escapes: D0
|
||||
// ----- Passive -----
|
||||
// PointsTo:
|
||||
// P0.g.f -> P1.g.f
|
||||
// RET.v@lue -> D0
|
||||
// Escapes: D0
|
||||
fun foo(c1: C, c2: C) {
|
||||
c1.g.f = c2.g.f
|
||||
}
|
||||
|
||||
fun main() = println(foo(C(), C()))
|
||||
@@ -1,35 +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 codegen.escapeAnalysis.test5
|
||||
|
||||
class A(val s: String)
|
||||
class B {
|
||||
var f: A = A("qzz")
|
||||
}
|
||||
class C {
|
||||
var g: B = B()
|
||||
}
|
||||
|
||||
// ----- Agressive -----
|
||||
// PointsTo:
|
||||
// RET.v@lue -> D0
|
||||
// D0.f -> P0.g.f
|
||||
// Escapes:
|
||||
// ----- Passive -----
|
||||
// PointsTo:
|
||||
// P0.g.f -> D2
|
||||
// RET.v@lue -> D0
|
||||
// D0.f -> P0.g.f
|
||||
// D0.f -> D1
|
||||
// D1 -> D2
|
||||
// Escapes: D0 D1
|
||||
fun foo(c1: C, c2: C): B {
|
||||
val b = B()
|
||||
b.f = c1.g.f
|
||||
return b
|
||||
}
|
||||
|
||||
fun main() = println(foo(C(), C()))
|
||||
@@ -1,40 +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 codegen.escapeAnalysis.test6
|
||||
|
||||
class A(val s: String)
|
||||
class B {
|
||||
var f: A = A("qzz")
|
||||
}
|
||||
class C {
|
||||
var g: B = B()
|
||||
}
|
||||
|
||||
// ----- Agressive -----
|
||||
// PointsTo:
|
||||
// P1.g -> D0
|
||||
// P2.g -> D0
|
||||
// RET.v@lue -> P1.g
|
||||
// RET.v@lue -> P2.g
|
||||
// RET.v@lue -> D0
|
||||
// D0.f -> P3
|
||||
// Escapes:
|
||||
// ----- Passive -----
|
||||
// PointsTo:
|
||||
// P1.g -> D0
|
||||
// P2.g -> D0
|
||||
// RET.v@lue -> P1.g
|
||||
// RET.v@lue -> P2.g
|
||||
// RET.v@lue -> D0
|
||||
// D0.f -> P3
|
||||
// Escapes:
|
||||
fun foo(z: Boolean, c1: C, c2: C, a: A): B {
|
||||
val v = if(z) c1.g else c2.g
|
||||
v.f = a
|
||||
return v
|
||||
}
|
||||
|
||||
fun main() = println(foo(true, C(), C(), A("zzz")))
|
||||
@@ -1,52 +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 codegen.escapeAnalysis.test7
|
||||
|
||||
class A(val s: String) {
|
||||
var h: String = ""
|
||||
var p: C = C()
|
||||
}
|
||||
class B {
|
||||
var f: A = A("qzz")
|
||||
}
|
||||
class C {
|
||||
var g: A = A("")
|
||||
}
|
||||
class D {
|
||||
var o: A = A("")
|
||||
}
|
||||
|
||||
// ----- Agressive -----
|
||||
// PointsTo:
|
||||
// P1.g -> D0
|
||||
// P2.f -> D0
|
||||
// P4.o -> P1.g
|
||||
// P4.o -> P2.f
|
||||
// P4.o -> D0
|
||||
// RET.v@lue -> D1
|
||||
// D0.p -> P1
|
||||
// D0.h -> P3
|
||||
// Escapes: D1
|
||||
// ----- Passive -----
|
||||
// PointsTo:
|
||||
// P1.g -> D0
|
||||
// P2.f -> D0
|
||||
// P4.o -> P1.g
|
||||
// P4.o -> P2.f
|
||||
// P4.o -> D0
|
||||
// RET.v@lue -> D1
|
||||
// D0.p -> P1
|
||||
// D0.h -> P3
|
||||
// Escapes: D1
|
||||
fun foo(z: Boolean, c: C, b: B, s: String, d: D) {
|
||||
val v = if(z) c.g else b.f
|
||||
v.h = s
|
||||
d.o = v
|
||||
val u = v
|
||||
u.p = c
|
||||
}
|
||||
|
||||
fun main() = println(foo(true, C(), B(), "zzz", D()))
|
||||
@@ -1,43 +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 codegen.escapeAnalysis.test8
|
||||
|
||||
class F(val s: String) {
|
||||
var g = F("")
|
||||
}
|
||||
|
||||
class A {
|
||||
var f = F("qzz")
|
||||
}
|
||||
|
||||
// ----- Agressive -----
|
||||
// PointsTo:
|
||||
// P0.f -> D0
|
||||
// RET.v@lue -> P0.f
|
||||
// RET.v@lue -> D0
|
||||
// RET.v@lue -> D0.g
|
||||
// D0.g -> P0.f
|
||||
// D0.g -> D0
|
||||
// Escapes:
|
||||
// ----- Passive -----
|
||||
// PointsTo:
|
||||
// P0.f -> D0
|
||||
// RET.v@lue -> P0.f
|
||||
// RET.v@lue -> D0
|
||||
// RET.v@lue -> D0.g
|
||||
// D0.g -> P0.f
|
||||
// D0.g -> D0
|
||||
// D0.g -> D2
|
||||
// D1 -> D0
|
||||
// D2 -> D0
|
||||
// Escapes: D1 D2
|
||||
fun foo(a: A): F {
|
||||
a.f = F("zzz")
|
||||
a.f.g = a.f
|
||||
return a.f.g.g
|
||||
}
|
||||
|
||||
fun main() = println(foo(A()).s)
|
||||
@@ -1,36 +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 codegen.escapeAnalysis.test9
|
||||
|
||||
class H(val x: Int)
|
||||
|
||||
class F(val s: String) {
|
||||
var g = F("")
|
||||
var h = H(0)
|
||||
}
|
||||
|
||||
class A {
|
||||
var f = F("qzz")
|
||||
}
|
||||
|
||||
// ----- Agressive -----
|
||||
// PointsTo:
|
||||
// P0.f -> P1.g
|
||||
// RET.v@lue -> P1.g.h
|
||||
// Escapes:
|
||||
// ----- Passive -----
|
||||
// PointsTo:
|
||||
// P0.f -> P1.g
|
||||
// P1.g.h -> D0
|
||||
// RET.v@lue -> P1.g.h
|
||||
// Escapes: D0
|
||||
fun foo(a: A, f: F): H {
|
||||
a.f = f.g
|
||||
a.f.h = H(42)
|
||||
return f.g.h
|
||||
}
|
||||
|
||||
fun main() = println(foo(A(), F("zzz")).x)
|
||||
@@ -1,25 +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 codegen.escapeAnalysis.zeroOutObjectOnAlloc
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class A {
|
||||
var x = 0
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
var sum1 = 0
|
||||
var sum2 = 0
|
||||
for (i in 0 until 10) {
|
||||
val a = A()
|
||||
sum1 += a.x
|
||||
a.x = i
|
||||
sum2 += a.x
|
||||
}
|
||||
assertEquals(0, sum1)
|
||||
assertEquals(45, sum2)
|
||||
}
|
||||
@@ -1,19 +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.
|
||||
*/
|
||||
|
||||
package codegen.funInterface.implIsNotFunction
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun interface Foo {
|
||||
fun invoke(): String
|
||||
}
|
||||
|
||||
fun foo(f: Foo) = f is Function<*>
|
||||
|
||||
@Test
|
||||
fun test() {
|
||||
assertFalse(foo { "zzz" })
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
package codegen.funInterface.kt43887
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
typealias heap_t = IntVar
|
||||
fun heap_create(size: Long): CPointer<heap_t>? = null
|
||||
fun heap_alloc(heap: CPointer<heap_t>?, size: ULong): CPointer<*>? = null
|
||||
fun heap_free(heap: CPointer<heap_t>?, ptr: CPointer<*>?): CPointer<BooleanVar>? = null
|
||||
inline fun Heap(size: Long): CPointer<heap_t>? {
|
||||
return heap_create(size)
|
||||
}
|
||||
inline fun <reified T : CVariable> CPointer<heap_t>?.use(f: (CPointer<T>) -> Unit) {
|
||||
alloc<T>()
|
||||
?.also(f)
|
||||
?.also(::free)
|
||||
}
|
||||
inline fun <reified T : CVariable> CPointer<heap_t>?.alloc(): CPointer<T>? {
|
||||
return heap_alloc(this, sizeOf<T>().toULong())?.reinterpret()
|
||||
}
|
||||
inline fun CPointer<heap_t>?.free(ptr: CPointer<*>?): Boolean {
|
||||
return heap_free(this, ptr)?.pointed?.value ?: false
|
||||
}
|
||||
|
||||
@Test
|
||||
fun runTest(): Unit = memScoped {
|
||||
val heap = Heap(1024)
|
||||
|
||||
heap.use<IntVar> { ptr ->
|
||||
ptr.pointed.value = 40
|
||||
//println("PTR ${ptr.pointed}")
|
||||
}
|
||||
}
|
||||
@@ -1,36 +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.
|
||||
*/
|
||||
|
||||
package codegen.funInterface.kt49384
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
interface A<T>
|
||||
|
||||
// https://youtrack.jetbrains.com/issue/KT-49384
|
||||
class B<T> {
|
||||
init {
|
||||
mutableListOf<A<out T>>()
|
||||
.sortWith { _, _ -> 1 }
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test1() {
|
||||
val b = B<Any>()
|
||||
assertEquals(b, b) // Just to ensure B is not deleted by DCE
|
||||
}
|
||||
|
||||
fun interface Foo<T> {
|
||||
fun same(obj: T): T
|
||||
}
|
||||
|
||||
fun getSame(obj: A<out Any>, foo: Foo<A<out Any>>) = foo.same(obj)
|
||||
|
||||
@Test
|
||||
fun test2() {
|
||||
val obj = object : A<Any> {}
|
||||
assertSame(obj, getSame(obj) { it })
|
||||
}
|
||||
-17
@@ -1,17 +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.
|
||||
*/
|
||||
|
||||
package codegen.funInterface.nonTrivialProjectionInSuperType
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun <T> foo(comparator: kotlin.Comparator<in T>, a: T, b: T) = comparator.compare(a, b)
|
||||
|
||||
fun bar(x: Int, y: Int) = foo<Int> ({ a, b -> a - b}, x, y)
|
||||
|
||||
@Test
|
||||
fun test() {
|
||||
assertTrue(bar(42, 117) < 0)
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.function.arithmetic
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun square(a:Int):Int = a * a
|
||||
fun sumOfSquares(a:Int, b:Int):Int = square(a) + square(b)
|
||||
fun diffOfSquares(a:Int, b:Int):Int = square(a) - square(b)
|
||||
fun mod(a:Int,b:Int):Int = a / b
|
||||
fun remainder(a:Int, b:Int):Int = a % b
|
||||
|
||||
@Test fun runTest() {
|
||||
if (square(2) != 4) throw Error()
|
||||
if (sumOfSquares(2, 4) != 20) throw Error()
|
||||
if (diffOfSquares(2, 4) != -12) throw Error()
|
||||
if (mod(5, 2) != 2) throw Error()
|
||||
if (remainder(5, 2) != 1) throw Error()
|
||||
}
|
||||
@@ -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 codegen.function.boolean
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun bool_yes(): Boolean = true
|
||||
|
||||
@Test fun runTest() {
|
||||
if (!bool_yes()) throw Error()
|
||||
}
|
||||
@@ -1,102 +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 codegen.function.defaults
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
/**
|
||||
* Created by minamoto on 12/26/16.
|
||||
*/
|
||||
//package defaults
|
||||
|
||||
open class A(val a:Int) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other == null || other as? A == null) return false
|
||||
return (other as A).a == a // Where is smart casting?
|
||||
}
|
||||
|
||||
companion object {
|
||||
val zero = A(0)
|
||||
val one = A(1)
|
||||
val magic = A(42)
|
||||
}
|
||||
}
|
||||
|
||||
// FUN public fun foo(a: defaults.A = ...): kotlin.Int
|
||||
// a: EXPRESSION_BODY
|
||||
// CALL '<get-magic>(): A' type=defaults.A origin=GET_PROPERTY
|
||||
// $this: GET_OBJECT 'companion object of A' type=defaults.A.Companion
|
||||
// BLOCK_BODY
|
||||
// RETURN type=kotlin.Nothing from='foo(A = ...): Int'
|
||||
// CALL '<get-a>(): Int' type=kotlin.Int origin=GET_PROPERTY
|
||||
// $this: GET_VAR 'value-parameter a: A = ...' type=defaults.A origin=null
|
||||
fun foo(a: A = A.magic, b:Int = 0xdeadbeef.toInt()) = a.a
|
||||
|
||||
// FUN public fun bar(a: defaults.A, inc: kotlin.Int = ...): defaults.A
|
||||
// inc: EXPRESSION_BODY
|
||||
// CONST Int type=kotlin.Int value='0'
|
||||
// BLOCK_BODY
|
||||
// RETURN type=kotlin.Nothing from='bar(A, Int = ...): A'
|
||||
// CALL 'constructor A(Int)' type=defaults.A origin=null
|
||||
// a: CALL 'plus(Int): Int' type=kotlin.Int origin=PLUS
|
||||
// $this: CALL '<get-a>(): Int' type=kotlin.Int origin=GET_PROPERTY
|
||||
// $this: GET_VAR 'value-parameter a: A' type=defaults.A origin=null
|
||||
// other: GET_VAR 'value-parameter inc: Int = ...' type=kotlin.Int origin=null
|
||||
fun bar(a:A, inc:Int = 0) = A(a.a + inc)
|
||||
|
||||
|
||||
@Test fun runTest() {
|
||||
|
||||
// if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
// arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
// arg0: CALL 'foo(A = ...): Int' type=kotlin.Int origin=null
|
||||
// arg1: CALL '<get-a>(): Int' type=kotlin.Int origin=GET_PROPERTY
|
||||
// $this: CALL '<get-magic>(): A' type=defaults.A origin=GET_PROPERTY
|
||||
// $this: GET_OBJECT 'companion object of A' type=defaults.A.Companion
|
||||
if (foo() != A.magic.a) {
|
||||
println("magic failed")
|
||||
throw Error()
|
||||
}
|
||||
|
||||
// if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
// arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
// arg0: CALL 'foo(A = ...): Int' type=kotlin.Int origin=null
|
||||
// a: CALL 'constructor A(Int)' type=defaults.A origin=null
|
||||
// a: CONST Int type=kotlin.Int value='1'
|
||||
// arg1: CONST Int type=kotlin.Int value='1'
|
||||
if (foo(A(1)) != 1) {
|
||||
println("one failed: foo(A(1))")
|
||||
throw Error()
|
||||
}
|
||||
|
||||
// if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
// arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
// arg0: CALL 'bar(A, Int = ...): A' type=defaults.A origin=null
|
||||
// a: CALL '<get-one>(): A' type=defaults.A origin=GET_PROPERTY <---
|
||||
// $this: GET_OBJECT 'companion object of A' type=defaults.A.Companion
|
||||
// arg1: CALL '<get-one>(): A' type=defaults.A origin=GET_PROPERTY
|
||||
// $this: GET_OBJECT 'companion object of A' type=defaults.A.Companion
|
||||
|
||||
if (bar(A.one) != A.one) {
|
||||
println("A one failed")
|
||||
throw Error()
|
||||
}
|
||||
|
||||
|
||||
// if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
// arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
// arg0: CALL '<get-a>(): Int' type=kotlin.Int origin=GET_PROPERTY
|
||||
// $this: CALL 'bar(A, Int = ...): A' type=defaults.A origin=null
|
||||
// a: CALL '<get-one>(): A' type=defaults.A origin=GET_PROPERTY
|
||||
// $this: GET_OBJECT 'companion object of A' type=defaults.A.Companion
|
||||
// inc: CONST Int type=kotlin.Int value='1'
|
||||
// arg1: CONST Int type=kotlin.Int value='2'
|
||||
if (bar(A.one, 1).a != 2) {
|
||||
println("A one + 1 failed")
|
||||
throw Error()
|
||||
}
|
||||
println("all tests passed")
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo(x:Int = 0, y:Int = x + 1, z:Int = x + y + 1) = x + y + z
|
||||
|
||||
@Test fun runTest() {
|
||||
val v = foo()
|
||||
if (v != 3) {
|
||||
println("test failed $v expected 3")
|
||||
throw Error()
|
||||
}
|
||||
}
|
||||
@@ -1,16 +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 codegen.function.defaults10
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class A(one: Int, val two: Int = one) {
|
||||
FOO(42)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(A.FOO.two)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
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 codegen.function.defaults2
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
|
||||
fun Int.foo(inc0:Int, inc:Int = 0) = this + inc0 + inc
|
||||
|
||||
@Test fun runTest() {
|
||||
val v = 42.foo(0)
|
||||
if (v != 42) {
|
||||
println("test failed v:$v expected:42")
|
||||
throw Error()
|
||||
}
|
||||
}
|
||||
@@ -1,21 +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 codegen.function.defaults3
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo(a:Int = 2, b:String = "Hello", c:Int = 4):String = "$b-$c$a"
|
||||
fun foo(a:Int = 3, b:Int = a + 1, c:Int = a + b) = a + b + c
|
||||
|
||||
@Test fun runTest() {
|
||||
val a = foo(b="Universe")
|
||||
if (a != "Universe-42")
|
||||
throw Error()
|
||||
|
||||
val b = foo(b = 5)
|
||||
if (b != (/* a = */ 3 + /* b = */ 5 + /* c = */ (3 + 5)))
|
||||
throw Error()
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults4
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
open class A {
|
||||
open fun foo(x: Int = 42) = println(x)
|
||||
}
|
||||
|
||||
open class B : A()
|
||||
|
||||
class C : B() {
|
||||
override fun foo(x: Int) = println(x + 1)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
C().foo()
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
43
|
||||
@@ -1,23 +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 codegen.function.defaults5
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class TestClass(val x: Int) {
|
||||
fun foo(y: Int = x) {
|
||||
println(y)
|
||||
}
|
||||
}
|
||||
|
||||
fun TestClass.bar(y: Int = x) {
|
||||
println(y)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
TestClass(5).foo()
|
||||
TestClass(6).bar()
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
5
|
||||
6
|
||||
@@ -1,15 +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 codegen.function.defaults6
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
open class Foo(val x: Int = 42)
|
||||
class Bar : Foo()
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Bar().x)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
42
|
||||
@@ -1,25 +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 codegen.function.defaults7
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
/**
|
||||
* Test fails with code generation:
|
||||
* Call parameter type does not match function signature!
|
||||
* %5 = invoke %struct.ObjHeader* @"kfun:kotlin.native.internal.boxInt(kotlin.Int)"(i32 1, %struct.ObjHeader** %4)
|
||||
* to label %label_ unwind label %cleanup_landingpad
|
||||
* i32 invoke void @"kfun:foo$default(kotlin.Int;kotlin.Int;kotlin.Int)"(%struct.ObjHeader* %5, i32 0, i32 2)
|
||||
* to label %label_1 unwind label %cleanup_landingpad
|
||||
*/
|
||||
|
||||
fun <T> foo(a : T, b : Int = 42){
|
||||
println(b)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
foo(1)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user