From 31e00efa8f1b505ae7c5400dac2863492dad99d1 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 2 Nov 2017 21:54:41 +0300 Subject: [PATCH] Legacy mode for non-multiplatform stdlib sources --- .../src/templates/dsl/MemberBuilder.kt | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/MemberBuilder.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/MemberBuilder.kt index 419dcdb237e..ceda5fcd1f5 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/MemberBuilder.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/MemberBuilder.kt @@ -45,7 +45,8 @@ class MemberBuilder( val f get() = family - var hasPlatformSpecializations: Boolean = false + private val legacyMode = true + var hasPlatformSpecializations: Boolean = legacyMode private set var doc: String? = null; private set @@ -143,10 +144,19 @@ class MemberBuilder( fun build(builder: Appendable) { - // TODO: legacy mode when all is headerOnly + no_impl - // except functions with optional parameters - they are common + no_impl - val headerOnly: Boolean = platform == Platform.Common && hasPlatformSpecializations - val isImpl: Boolean = platform != Platform.Common && Platform.Common in allowedPlatforms + val headerOnly: Boolean + val isImpl: Boolean + if (!legacyMode) { + headerOnly = platform == Platform.Common && hasPlatformSpecializations + isImpl = platform != Platform.Common && Platform.Common in allowedPlatforms + } + else { + // legacy mode when all is headerOnly + no_impl + // except functions with optional parameters - they are common + no_impl + val hasOptionalParams = signature.contains("=") + headerOnly = platform == Platform.Common && !hasOptionalParams + isImpl = false + } val returnType = returns ?: throw RuntimeException("No return type specified for $signature")