From b77b8af09d77281abfb3fb21bf2f8c6674141899 Mon Sep 17 00:00:00 2001 From: Jens Klingenberg Date: Sun, 28 Apr 2024 10:06:53 +0200 Subject: [PATCH] Optimize generated code (#541) --- .../kotlin/de/jensklingenberg/ktorfit/model/FunctionData.kt | 3 +-- .../de/jensklingenberg/ktorfit/StreamingAnnotationTest.kt | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/model/FunctionData.kt b/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/model/FunctionData.kt index 4b2b3125f..e3210d1f6 100644 --- a/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/model/FunctionData.kt +++ b/ktorfit-ksp/src/main/kotlin/de/jensklingenberg/ktorfit/model/FunctionData.kt @@ -23,7 +23,6 @@ data class FunctionData( ) { fun toFunSpec(resolver: Resolver): FunSpec { - val returnTypeName = this.returnType.parameterType?.toTypeName() return FunSpec.builder(this.name) .addModifiers(mutableListOf(KModifier.OVERRIDE).also { @@ -51,7 +50,7 @@ data class FunctionData( this.returnType.parameterType.toTypeName().toString().removeWhiteSpaces() ) .addStatement( - "return %L.%L<${returnTypeName}>(%L,${extDataClass.objectName})%L", + "return %L.%L(%L,${extDataClass.objectName})%L", converterHelper.objectName, if (this.isSuspend) { "suspendRequest" diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/StreamingAnnotationTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/StreamingAnnotationTest.kt index 654be70d0..313ea5e36 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/StreamingAnnotationTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/StreamingAnnotationTest.kt @@ -39,7 +39,7 @@ interface TestService { ) - val expectedFunctionText = """return _converter.suspendRequest(_typeData,_ext)!!""" + val expectedFunctionText = """return _converter.suspendRequest(_typeData,_ext)!!""" val compilation = getCompilation(listOf(httpStatement, source)) val result = compilation.compile()