Stabilize unsigned types KT-45653

Deprecate specialized unsigned iterators for removal.

Fix compiler tests:
- drop unsignedLiteralsOn1_2 because apiVersion 1.2 is no longer supported
- drop experimental unsigned literals diagnostic test
This commit is contained in:
Ilya Gorbunov
2021-03-19 20:38:02 +03:00
parent 768c165a72
commit 94240f7b21
63 changed files with 1305 additions and 1461 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -268,8 +268,10 @@ object Aggregates : TemplateGroupBase() {
annotation("""@Suppress("INAPPLICABLE_JVM_NAME")""")
}
annotation("""@kotlin.jvm.JvmName("sumOf$typeShortName")""") // should not be needed if inline return type is mangled
if (selectorType.startsWith("U"))
annotation("@ExperimentalUnsignedTypes")
if (selectorType.startsWith("U")) {
since("1.5")
wasExperimental("ExperimentalUnsignedTypes")
}
doc { "Returns the sum of all values produced by [selector] function applied to each ${f.element} in the ${f.collection}." }
returns(selectorType)
@@ -1142,7 +1144,7 @@ object Aggregates : TemplateGroupBase() {
include(ArraysOfPrimitives, ArraysOfUnsigned, CharSequences)
} builder {
since("1.4")
annotation("@WasExperimental(ExperimentalStdlibApi::class)")
wasExperimental("ExperimentalStdlibApi")
inline()
specialFor(ArraysOfUnsigned) { inlineOnly() }
@@ -1167,7 +1169,7 @@ object Aggregates : TemplateGroupBase() {
include(ArraysOfObjects, Iterables, Sequences)
} builder {
since("1.4")
annotation("@WasExperimental(ExperimentalStdlibApi::class)")
wasExperimental("ExperimentalStdlibApi")
inline()
doc { reduceDoc("reduceOrNull") }
@@ -1267,7 +1269,7 @@ object Aggregates : TemplateGroupBase() {
include(CharSequences, ArraysOfPrimitives, ArraysOfUnsigned)
} builder {
since("1.4")
annotation("@WasExperimental(ExperimentalStdlibApi::class)")
wasExperimental("ExperimentalStdlibApi")
inline()
specialFor(ArraysOfUnsigned) { inlineOnly() }
@@ -1293,7 +1295,7 @@ object Aggregates : TemplateGroupBase() {
include(Lists, ArraysOfObjects)
} builder {
since("1.4")
annotation("@WasExperimental(ExperimentalStdlibApi::class)")
wasExperimental("ExperimentalStdlibApi")
inline()
doc { reduceDoc("reduceRightOrNull") }
sample("samples.collections.Collections.Aggregates.reduceRightOrNull")
@@ -1414,7 +1416,7 @@ object Aggregates : TemplateGroupBase() {
include(CharSequences, ArraysOfUnsigned)
} builder {
since("1.4")
annotation("@WasExperimental(ExperimentalStdlibApi::class)")
wasExperimental("ExperimentalStdlibApi")
specialFor(Iterables, ArraysOfObjects, CharSequences) { inline() }
specialFor(ArraysOfPrimitives, ArraysOfUnsigned) { inlineOnly() }
@@ -1512,7 +1514,7 @@ object Aggregates : TemplateGroupBase() {
include(CharSequences, ArraysOfUnsigned)
} builder {
since("1.4")
annotation("@WasExperimental(ExperimentalStdlibApi::class)")
wasExperimental("ExperimentalStdlibApi")
specialFor(Iterables, ArraysOfObjects, CharSequences) { inline() }
specialFor(ArraysOfPrimitives, ArraysOfUnsigned) { inlineOnly() }
@@ -1612,7 +1614,7 @@ object Aggregates : TemplateGroupBase() {
include(ArraysOfObjects, Iterables, Sequences)
} builder {
since("1.4")
annotation("@WasExperimental(ExperimentalStdlibApi::class)")
wasExperimental("ExperimentalStdlibApi")
specialFor(ArraysOfObjects, Iterables) { inline() }
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -12,8 +12,13 @@ object ComparableOps : TemplateGroupBase() {
init {
defaultBuilder {
specialFor(Unsigned) {
sinceAtLeast("1.3")
annotation("@ExperimentalUnsignedTypes")
if ("vararg" in signature) {
sinceAtLeast("1.3")
annotation("@ExperimentalUnsignedTypes")
} else {
sinceAtLeast("1.5")
wasExperimental("ExperimentalUnsignedTypes")
}
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -21,8 +21,8 @@ object Elements : TemplateGroupBase() {
}
specialFor(RangesOfPrimitives) {
if (primitive in PrimitiveType.unsignedPrimitives) {
sinceAtLeast("1.3")
annotation("@ExperimentalUnsignedTypes")
sinceAtLeast("1.5")
wasExperimental("ExperimentalUnsignedTypes")
sourceFile(SourceFile.URanges)
}
}
@@ -944,7 +944,7 @@ object Elements : TemplateGroupBase() {
include(Collections, ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned, CharSequences, RangesOfPrimitives)
} builder {
since("1.4")
annotation("@WasExperimental(ExperimentalStdlibApi::class)")
wasExperimental("ExperimentalStdlibApi")
inlineOnly()
returns("T?")
doc {
@@ -1006,7 +1006,7 @@ object Elements : TemplateGroupBase() {
include(Collections, ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned, CharSequences, RangesOfPrimitives)
} builder {
since("1.4")
annotation("@WasExperimental(ExperimentalStdlibApi::class)")
wasExperimental("ExperimentalStdlibApi")
returns("T?")
doc {
"""
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -51,8 +51,8 @@ object Numeric : TemplateGroupBase() {
specialFor(Sequences) { sourceFile(SourceFile.USequences) }
specialFor(ArraysOfObjects) { sourceFile(SourceFile.UArrays) }
since("1.3")
annotation("@ExperimentalUnsignedTypes")
since("1.5")
wasExperimental("ExperimentalUnsignedTypes")
}
body {
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -44,8 +44,8 @@ object RangeOps : TemplateGroupBase() {
defaultBuilder {
sourceFile(SourceFile.Ranges)
if (primitive in PrimitiveType.unsignedPrimitives) {
since("1.3")
annotation("@ExperimentalUnsignedTypes")
sinceAtLeast("1.5")
wasExperimental("ExperimentalUnsignedTypes")
sourceFile(SourceFile.URanges)
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -68,6 +68,7 @@ class MemberBuilder(
var body: String? = null; private set
val annotations: MutableSet<String> = mutableSetOf()
val suppressions: MutableList<String> = mutableListOf()
val wasExperimentalAnnotations: MutableSet<String> = mutableSetOf()
fun sourceFile(file: SourceFile) { sourceFile = file }
@@ -123,6 +124,10 @@ class MemberBuilder(
suppressions += diagnostic
}
fun wasExperimental(annotation: String) {
wasExperimentalAnnotations += annotation
}
fun sequenceClassification(vararg sequenceClass: SequenceClass) {
sequenceClassification += sequenceClass
}
@@ -348,6 +353,9 @@ class MemberBuilder(
builder.append("@SinceKotlin(\"$since\")\n")
}
if (wasExperimentalAnnotations.isNotEmpty()) {
annotation("@WasExperimental(${wasExperimentalAnnotations.joinToString(", ") { "$it::class" }})")
}
annotations.forEach { builder.append(it.trimIndent()).append('\n') }
when (inline) {