From ffa7f544a4206054d6992e73c2aa4c5e8f2bb9d1 Mon Sep 17 00:00:00 2001 From: Elizabeth Worstell Date: Tue, 14 Nov 2023 10:21:25 -0800 Subject: [PATCH] fix: allow empty return types in kotlin --- .../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" + } } }