diff --git a/translator/src/main/kotlin/org/kotlinnative/translator/ProjectTranslator.kt b/translator/src/main/kotlin/org/kotlinnative/translator/ProjectTranslator.kt index e4f66fbaa8a..55603bac816 100644 --- a/translator/src/main/kotlin/org/kotlinnative/translator/ProjectTranslator.kt +++ b/translator/src/main/kotlin/org/kotlinnative/translator/ProjectTranslator.kt @@ -13,10 +13,11 @@ class ProjectTranslator(val files: List, val state: TranslationState) { } fun addDeclarations(file: KtFile) { + val variableManager = VariableManager(state.globalVariableCollection) for (declaration in file.declarations) { when (declaration) { is KtNamedFunction -> { - val function = FunctionCodegen(state, VariableManager(state.globalVariableCollection), declaration, codeBuilder) + val function = FunctionCodegen(state, variableManager, declaration, codeBuilder) if (function.external) { state.externalFunctions.put(function.fullName, function) } else { @@ -24,15 +25,15 @@ class ProjectTranslator(val files: List, val state: TranslationState) { } } is KtClass -> { - val codegen = ClassCodegen(state, VariableManager(state.globalVariableCollection), declaration, codeBuilder) + val codegen = ClassCodegen(state, variableManager, declaration, codeBuilder) state.classes.put(declaration.name!!, codegen) } is KtProperty -> { - val property = PropertyCodegen(state, VariableManager(state.globalVariableCollection), declaration, codeBuilder) + val property = PropertyCodegen(state, variableManager, declaration, codeBuilder) state.properties.put(declaration.name!!, property) } is KtObjectDeclaration -> { - val property = ObjectCodegen(state, VariableManager(state.globalVariableCollection), declaration, codeBuilder) + val property = ObjectCodegen(state, variableManager, declaration, codeBuilder) state.objects.put(declaration.name!!, property) } } diff --git a/translator/src/test/kotlin/tests/input/string_print_test_1.txt b/translator/src/test/kotlin/tests/input/string_print_test_1.txt new file mode 100644 index 00000000000..11a3bfdf37d --- /dev/null +++ b/translator/src/test/kotlin/tests/input/string_print_test_1.txt @@ -0,0 +1,2 @@ +string_print_test_1_inline() == 23 +string_print_test_1_variable() == 1 diff --git a/translator/src/test/kotlin/tests/kotlin/string_print_test_1.kt b/translator/src/test/kotlin/tests/kotlin/string_print_test_1.kt new file mode 100644 index 00000000000..e553c80f108 --- /dev/null +++ b/translator/src/test/kotlin/tests/kotlin/string_print_test_1.kt @@ -0,0 +1,11 @@ +fun string_print_test_1_inline(): Int { + println("STRING INLINE PRINT WORKS") + return 23 +} + +fun string_print_test_1_variable(): Int { + val x = "STRING VARIABLE WORKS" + val y = x + println(y) + return 1 +} \ No newline at end of file