diff --git a/js/js.libraries/src/core/annotationsJVM.kt b/js/js.libraries/src/core/annotationsJVM.kt new file mode 100644 index 00000000000..b476d48af59 --- /dev/null +++ b/js/js.libraries/src/core/annotationsJVM.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.jvm + +// is used in common generated code in stdlib +internal annotation class overloads diff --git a/libraries/stdlib/src/generated/_Strings.kt b/libraries/stdlib/src/generated/_Strings.kt index 6b059681ef5..44ba5aaa246 100644 --- a/libraries/stdlib/src/generated/_Strings.kt +++ b/libraries/stdlib/src/generated/_Strings.kt @@ -338,6 +338,7 @@ public fun ShortArray.joinToString(separator: String = ", ", prefix: String = "" * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). */ +kotlin.jvm.overloads public fun Iterable.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((T) -> String)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt index 03e9ccda91d..ad607d0f0ff 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt @@ -84,6 +84,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp override fun onKeySet(key: Family) = include(key) } val customPrimitiveBodies = HashMap, String>() + val annotations = FamilyProperty() fun bodyForTypes(family: Family, vararg primitiveTypes: PrimitiveType, b: () -> String) { include(family) @@ -295,6 +296,8 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp ?.let { platformName -> builder.append("platformName(\"${platformName}\")\n")} } + annotations[f]?.let { builder.append(it).append('\n') } + builder.append("public ") if (inline[f] == true) builder.append("inline ") diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt index dd1fdeb8902..6c89c670e8f 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt @@ -63,6 +63,7 @@ fun strings(): List { exclude(Strings) returns("String") + annotations("kotlin.jvm.overloads", Iterables) body { """ return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()