From e9a7d75e0e6c22ed060f2163f5737ec94d307d5e Mon Sep 17 00:00:00 2001 From: Alexey Stepanov Date: Tue, 19 Jul 2016 17:51:46 +0300 Subject: [PATCH] translator: fix methods argument order --- .../org/kotlinnative/translator/FunctionCodegen.kt | 4 ++-- .../src/test/kotlin/tests/input/class_methods_1.txt | 1 + .../src/test/kotlin/tests/kotlin/class_methods_1.kt | 10 ++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 translator/src/test/kotlin/tests/input/class_methods_1.txt create mode 100644 translator/src/test/kotlin/tests/kotlin/class_methods_1.kt diff --git a/translator/src/main/kotlin/org/kotlinnative/translator/FunctionCodegen.kt b/translator/src/main/kotlin/org/kotlinnative/translator/FunctionCodegen.kt index 4a35f659b7a..20f37f38da9 100644 --- a/translator/src/main/kotlin/org/kotlinnative/translator/FunctionCodegen.kt +++ b/translator/src/main/kotlin/org/kotlinnative/translator/FunctionCodegen.kt @@ -15,7 +15,7 @@ class FunctionCodegen(override val state: TranslationState, override val variabl BlockCodegen(state, variableManager, codeBuilder) { var name = function.fqName.toString() - var args = ArrayList() + var args = LinkedList() init { val descriptor = state.bindingContext.get(BindingContext.FUNCTION, function)!! @@ -58,7 +58,7 @@ class FunctionCodegen(override val state: TranslationState, override val variabl var external = false if (this_type != null) { - args.add(this_type) + args.addFirst(this_type) } args.forEach { val type = it.type diff --git a/translator/src/test/kotlin/tests/input/class_methods_1.txt b/translator/src/test/kotlin/tests/input/class_methods_1.txt new file mode 100644 index 00000000000..2a1153ba1de --- /dev/null +++ b/translator/src/test/kotlin/tests/input/class_methods_1.txt @@ -0,0 +1 @@ +class_methods_1(55) == 60 \ No newline at end of file diff --git a/translator/src/test/kotlin/tests/kotlin/class_methods_1.kt b/translator/src/test/kotlin/tests/kotlin/class_methods_1.kt new file mode 100644 index 00000000000..e96a4229bf4 --- /dev/null +++ b/translator/src/test/kotlin/tests/kotlin/class_methods_1.kt @@ -0,0 +1,10 @@ +class class_methods_1_class() { + fun method(t : Int): Int { + return t + 5 + } +} + +fun class_methods_1(zz: Int): Int { + val x = class_methods_1_class() + return x.method(zz) +} \ No newline at end of file