From f737be39bc26c101cf5087bd0df5037021ee3a74 Mon Sep 17 00:00:00 2001 From: worstell Date: Tue, 14 Nov 2023 10:32:39 -0800 Subject: [PATCH] fix(kotlin): allow empty return types (#594) --- .../xyz/block/ftl/schemaextractor/ExtractSchemaRule.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kotlin-runtime/ftl-runtime/src/main/kotlin/xyz/block/ftl/schemaextractor/ExtractSchemaRule.kt b/kotlin-runtime/ftl-runtime/src/main/kotlin/xyz/block/ftl/schemaextractor/ExtractSchemaRule.kt index 2d89ff7654..113c854120 100644 --- a/kotlin-runtime/ftl-runtime/src/main/kotlin/xyz/block/ftl/schemaextractor/ExtractSchemaRule.kt +++ b/kotlin-runtime/ftl-runtime/src/main/kotlin/xyz/block/ftl/schemaextractor/ExtractSchemaRule.kt @@ -142,9 +142,11 @@ class SchemaExtractor( } // Validate return type - val respClass = verb.createTypeBindingForReturnType(bindingContext)?.type?.toClassDescriptor() + val respClass = verb.createTypeBindingForReturnType(bindingContext)?.type ?: throw IllegalStateException("Could not resolve ${verb.name} return type") - require(respClass.isData) { "Return type of ${verb.name} must be a data class" } + require(respClass.toClassDescriptor().isData || respClass.isEmptyClassTypeAlias()) { + "Return type of ${verb.name} must be a data class or typealias of Unit" + } } }