From 95a47e56f7bda3ad4f54c765b8fc98fd59cec169 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Wed, 30 Nov 2016 14:26:41 +0100 Subject: [PATCH] InlineExposed usages are changed to PublishedApi --- .../builtin-classes/default/kotlin.txt | 4 +++ .../testData/builtin-classes/java6/kotlin.txt | 4 +++ .../testData/builtin-classes/java8/kotlin.txt | 4 +++ .../builtin-classes/newMethods/kotlin.txt | 4 +++ core/builtins/src/kotlin/Annotations.kt | 10 ++++++ libraries/stdlib/jre7/src/kotlin/Standard.kt | 4 +-- libraries/stdlib/src/generated/_Arrays.kt | 36 ------------------- .../stdlib/src/generated/_Collections.kt | 5 --- libraries/stdlib/src/generated/_Strings.kt | 3 -- .../src/kotlin/collections/Iterables.kt | 4 +-- .../src/kotlin/collections/MapWithDefault.kt | 2 +- .../stdlib/src/kotlin/collections/Maps.kt | 4 +-- .../stdlib/src/kotlin/concurrent/Timer.kt | 6 +--- .../stdlib/src/kotlin/internal/Annotations.kt | 9 +---- .../internal/PlatformImplementations.kt | 2 +- libraries/stdlib/src/kotlin/io/ReadWrite.kt | 1 - .../stdlib/src/kotlin/text/regex/Regex.kt | 2 +- .../stdlib/src/kotlin/util/AssertionsJVM.kt | 5 ++- .../org.jetbrains.kotlin.tools/asmUtils.kt | 2 +- .../test/kotlin/cases/inline/inlineExposed.kt | 13 ++++--- .../src/templates/Generators.kt | 3 -- .../src/templates/Snapshots.kt | 9 ----- 22 files changed, 45 insertions(+), 91 deletions(-) diff --git a/compiler/testData/builtin-classes/default/kotlin.txt b/compiler/testData/builtin-classes/default/kotlin.txt index fb5cd46aaaf..83fef9ceb67 100644 --- a/compiler/testData/builtin-classes/default/kotlin.txt +++ b/compiler/testData/builtin-classes/default/kotlin.txt @@ -569,6 +569,10 @@ public abstract class Number { public final fun (): kotlin.String } +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.MustBeDocumented @kotlin.SinceKotlin(version = "1.1") public final annotation class PublishedApi : kotlin.Annotation { + /*primary*/ public constructor PublishedApi() +} + @kotlin.annotation.Target(allowedTargets = {}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.MustBeDocumented public final annotation class ReplaceWith : kotlin.Annotation { /*primary*/ public constructor ReplaceWith(/*0*/ expression: kotlin.String, /*1*/ vararg imports: kotlin.String /*kotlin.Array*/) public final val expression: kotlin.String diff --git a/compiler/testData/builtin-classes/java6/kotlin.txt b/compiler/testData/builtin-classes/java6/kotlin.txt index fc35a96689a..3177782ef40 100644 --- a/compiler/testData/builtin-classes/java6/kotlin.txt +++ b/compiler/testData/builtin-classes/java6/kotlin.txt @@ -585,6 +585,10 @@ public abstract class Number : kotlin.Any, java.io.Serializable { public final fun (): kotlin.String } +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.MustBeDocumented @kotlin.SinceKotlin(version = "1.1") public final annotation class PublishedApi : kotlin.Annotation { + /*primary*/ public constructor PublishedApi() +} + @kotlin.annotation.Target(allowedTargets = {}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.MustBeDocumented public final annotation class ReplaceWith : kotlin.Annotation { /*primary*/ public constructor ReplaceWith(/*0*/ expression: kotlin.String, /*1*/ vararg imports: kotlin.String /*kotlin.Array*/) public final val expression: kotlin.String diff --git a/compiler/testData/builtin-classes/java8/kotlin.txt b/compiler/testData/builtin-classes/java8/kotlin.txt index e87d96f4450..5062b72a13a 100644 --- a/compiler/testData/builtin-classes/java8/kotlin.txt +++ b/compiler/testData/builtin-classes/java8/kotlin.txt @@ -587,6 +587,10 @@ public abstract class Number : kotlin.Any, java.io.Serializable { public final fun (): kotlin.String } +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.MustBeDocumented @kotlin.SinceKotlin(version = "1.1") public final annotation class PublishedApi : kotlin.Annotation { + /*primary*/ public constructor PublishedApi() +} + @kotlin.annotation.Target(allowedTargets = {}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.MustBeDocumented public final annotation class ReplaceWith : kotlin.Annotation { /*primary*/ public constructor ReplaceWith(/*0*/ expression: kotlin.String, /*1*/ vararg imports: kotlin.String /*kotlin.Array*/) public final val expression: kotlin.String diff --git a/compiler/testData/builtin-classes/newMethods/kotlin.txt b/compiler/testData/builtin-classes/newMethods/kotlin.txt index f33fc042f80..fd27306bde8 100644 --- a/compiler/testData/builtin-classes/newMethods/kotlin.txt +++ b/compiler/testData/builtin-classes/newMethods/kotlin.txt @@ -585,6 +585,10 @@ public abstract class Number : kotlin.Any, java.io.Serializable { public final fun (): kotlin.String } +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.MustBeDocumented @kotlin.SinceKotlin(version = "1.1") public final annotation class PublishedApi : kotlin.Annotation { + /*primary*/ public constructor PublishedApi() +} + @kotlin.annotation.Target(allowedTargets = {}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.MustBeDocumented public final annotation class ReplaceWith : kotlin.Annotation { /*primary*/ public constructor ReplaceWith(/*0*/ expression: kotlin.String, /*1*/ vararg imports: kotlin.String /*kotlin.Array*/) public final val expression: kotlin.String diff --git a/core/builtins/src/kotlin/Annotations.kt b/core/builtins/src/kotlin/Annotations.kt index 09db92c5c65..ea2dab18cc7 100644 --- a/core/builtins/src/kotlin/Annotations.kt +++ b/core/builtins/src/kotlin/Annotations.kt @@ -127,3 +127,13 @@ public annotation class SinceKotlin(val version: String) @MustBeDocumented @SinceKotlin("1.1") public annotation class DslMarker + + +/** + * Specifies that this part of internal API is effectively public exposed by using in public inline function + */ +@Target(AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY) +@Retention(AnnotationRetention.BINARY) +@MustBeDocumented +@SinceKotlin("1.1") +public annotation class PublishedApi \ No newline at end of file diff --git a/libraries/stdlib/jre7/src/kotlin/Standard.kt b/libraries/stdlib/jre7/src/kotlin/Standard.kt index 7a31dd0a5d7..332b65f746a 100644 --- a/libraries/stdlib/jre7/src/kotlin/Standard.kt +++ b/libraries/stdlib/jre7/src/kotlin/Standard.kt @@ -20,7 +20,6 @@ public inline fun T.use(block: (T) -> R): R { return block(this) } catch (e: Throwable) { closed = true - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") this?.closeSuppressed(e) throw e } finally { @@ -35,8 +34,7 @@ public inline fun T.use(block: (T) -> R): R { * The suppressed exception is added to the list of suppressed exceptions of [cause] exception. */ @SinceKotlin("1.1") -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") -@kotlin.internal.InlineExposed +@PublishedApi internal fun AutoCloseable.closeSuppressed(cause: Throwable) { try { close() diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 2f67282e918..14a46f721db 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -5808,7 +5808,6 @@ public fun Array.toShortArray(): ShortArray { * The returned map preserves the entry iteration order of the original array. */ public inline fun Array.associate(transform: (T) -> Pair): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) } @@ -5822,7 +5821,6 @@ public inline fun Array.associate(transform: (T) -> Pair) * The returned map preserves the entry iteration order of the original array. */ public inline fun ByteArray.associate(transform: (Byte) -> Pair): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) } @@ -5836,7 +5834,6 @@ public inline fun ByteArray.associate(transform: (Byte) -> Pair): M * The returned map preserves the entry iteration order of the original array. */ public inline fun ShortArray.associate(transform: (Short) -> Pair): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) } @@ -5850,7 +5847,6 @@ public inline fun ShortArray.associate(transform: (Short) -> Pair): * The returned map preserves the entry iteration order of the original array. */ public inline fun IntArray.associate(transform: (Int) -> Pair): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) } @@ -5864,7 +5860,6 @@ public inline fun IntArray.associate(transform: (Int) -> Pair): Map * The returned map preserves the entry iteration order of the original array. */ public inline fun LongArray.associate(transform: (Long) -> Pair): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) } @@ -5878,7 +5873,6 @@ public inline fun LongArray.associate(transform: (Long) -> Pair): M * The returned map preserves the entry iteration order of the original array. */ public inline fun FloatArray.associate(transform: (Float) -> Pair): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) } @@ -5892,7 +5886,6 @@ public inline fun FloatArray.associate(transform: (Float) -> Pair): * The returned map preserves the entry iteration order of the original array. */ public inline fun DoubleArray.associate(transform: (Double) -> Pair): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) } @@ -5906,7 +5899,6 @@ public inline fun DoubleArray.associate(transform: (Double) -> Pair * The returned map preserves the entry iteration order of the original array. */ public inline fun BooleanArray.associate(transform: (Boolean) -> Pair): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) } @@ -5920,7 +5912,6 @@ public inline fun BooleanArray.associate(transform: (Boolean) -> Pair CharArray.associate(transform: (Char) -> Pair): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) } @@ -5934,7 +5925,6 @@ public inline fun CharArray.associate(transform: (Char) -> Pair): M * The returned map preserves the entry iteration order of the original array. */ public inline fun Array.associateBy(keySelector: (T) -> K): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) } @@ -5948,7 +5938,6 @@ public inline fun Array.associateBy(keySelector: (T) -> K): Map ByteArray.associateBy(keySelector: (Byte) -> K): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) } @@ -5962,7 +5951,6 @@ public inline fun ByteArray.associateBy(keySelector: (Byte) -> K): Map ShortArray.associateBy(keySelector: (Short) -> K): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) } @@ -5976,7 +5964,6 @@ public inline fun ShortArray.associateBy(keySelector: (Short) -> K): Map IntArray.associateBy(keySelector: (Int) -> K): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) } @@ -5990,7 +5977,6 @@ public inline fun IntArray.associateBy(keySelector: (Int) -> K): Map * The returned map preserves the entry iteration order of the original array. */ public inline fun LongArray.associateBy(keySelector: (Long) -> K): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) } @@ -6004,7 +5990,6 @@ public inline fun LongArray.associateBy(keySelector: (Long) -> K): Map FloatArray.associateBy(keySelector: (Float) -> K): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) } @@ -6018,7 +6003,6 @@ public inline fun FloatArray.associateBy(keySelector: (Float) -> K): Map DoubleArray.associateBy(keySelector: (Double) -> K): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) } @@ -6032,7 +6016,6 @@ public inline fun DoubleArray.associateBy(keySelector: (Double) -> K): Map BooleanArray.associateBy(keySelector: (Boolean) -> K): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) } @@ -6046,7 +6029,6 @@ public inline fun BooleanArray.associateBy(keySelector: (Boolean) -> K): Map * The returned map preserves the entry iteration order of the original array. */ public inline fun CharArray.associateBy(keySelector: (Char) -> K): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) } @@ -6059,7 +6041,6 @@ public inline fun CharArray.associateBy(keySelector: (Char) -> K): Map Array.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) } @@ -6072,7 +6053,6 @@ public inline fun Array.associateBy(keySelector: (T) -> K, valu * The returned map preserves the entry iteration order of the original array. */ public inline fun ByteArray.associateBy(keySelector: (Byte) -> K, valueTransform: (Byte) -> V): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) } @@ -6085,7 +6065,6 @@ public inline fun ByteArray.associateBy(keySelector: (Byte) -> K, valueTr * The returned map preserves the entry iteration order of the original array. */ public inline fun ShortArray.associateBy(keySelector: (Short) -> K, valueTransform: (Short) -> V): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) } @@ -6098,7 +6077,6 @@ public inline fun ShortArray.associateBy(keySelector: (Short) -> K, value * The returned map preserves the entry iteration order of the original array. */ public inline fun IntArray.associateBy(keySelector: (Int) -> K, valueTransform: (Int) -> V): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) } @@ -6111,7 +6089,6 @@ public inline fun IntArray.associateBy(keySelector: (Int) -> K, valueTran * The returned map preserves the entry iteration order of the original array. */ public inline fun LongArray.associateBy(keySelector: (Long) -> K, valueTransform: (Long) -> V): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) } @@ -6124,7 +6101,6 @@ public inline fun LongArray.associateBy(keySelector: (Long) -> K, valueTr * The returned map preserves the entry iteration order of the original array. */ public inline fun FloatArray.associateBy(keySelector: (Float) -> K, valueTransform: (Float) -> V): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) } @@ -6137,7 +6113,6 @@ public inline fun FloatArray.associateBy(keySelector: (Float) -> K, value * The returned map preserves the entry iteration order of the original array. */ public inline fun DoubleArray.associateBy(keySelector: (Double) -> K, valueTransform: (Double) -> V): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) } @@ -6150,7 +6125,6 @@ public inline fun DoubleArray.associateBy(keySelector: (Double) -> K, val * The returned map preserves the entry iteration order of the original array. */ public inline fun BooleanArray.associateBy(keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) } @@ -6163,7 +6137,6 @@ public inline fun BooleanArray.associateBy(keySelector: (Boolean) -> K, v * The returned map preserves the entry iteration order of the original array. */ public inline fun CharArray.associateBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) } @@ -11912,7 +11885,6 @@ public infix fun CharArray.zip(other: Iterable): List> { */ public inline fun Array.zip(other: Iterable, transform: (T, R) -> V): List { val arraySize = size - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { @@ -11927,7 +11899,6 @@ public inline fun Array.zip(other: Iterable, transform: (T, */ public inline fun ByteArray.zip(other: Iterable, transform: (Byte, R) -> V): List { val arraySize = size - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { @@ -11942,7 +11913,6 @@ public inline fun ByteArray.zip(other: Iterable, transform: (Byte, R) */ public inline fun ShortArray.zip(other: Iterable, transform: (Short, R) -> V): List { val arraySize = size - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { @@ -11957,7 +11927,6 @@ public inline fun ShortArray.zip(other: Iterable, transform: (Short, R */ public inline fun IntArray.zip(other: Iterable, transform: (Int, R) -> V): List { val arraySize = size - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { @@ -11972,7 +11941,6 @@ public inline fun IntArray.zip(other: Iterable, transform: (Int, R) -> */ public inline fun LongArray.zip(other: Iterable, transform: (Long, R) -> V): List { val arraySize = size - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { @@ -11987,7 +11955,6 @@ public inline fun LongArray.zip(other: Iterable, transform: (Long, R) */ public inline fun FloatArray.zip(other: Iterable, transform: (Float, R) -> V): List { val arraySize = size - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { @@ -12002,7 +11969,6 @@ public inline fun FloatArray.zip(other: Iterable, transform: (Float, R */ public inline fun DoubleArray.zip(other: Iterable, transform: (Double, R) -> V): List { val arraySize = size - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { @@ -12017,7 +11983,6 @@ public inline fun DoubleArray.zip(other: Iterable, transform: (Double, */ public inline fun BooleanArray.zip(other: Iterable, transform: (Boolean, R) -> V): List { val arraySize = size - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { @@ -12032,7 +11997,6 @@ public inline fun BooleanArray.zip(other: Iterable, transform: (Boolea */ public inline fun CharArray.zip(other: Iterable, transform: (Char, R) -> V): List { val arraySize = size - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index 1fd388965ba..3155ed64567 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -961,7 +961,6 @@ public fun Collection.toShortArray(): ShortArray { * The returned map preserves the entry iteration order of the original collection. */ public inline fun Iterable.associate(transform: (T) -> Pair): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) } @@ -975,7 +974,6 @@ public inline fun Iterable.associate(transform: (T) -> Pair): * The returned map preserves the entry iteration order of the original collection. */ public inline fun Iterable.associateBy(keySelector: (T) -> K): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) } @@ -988,7 +986,6 @@ public inline fun Iterable.associateBy(keySelector: (T) -> K): Map Iterable.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) } @@ -1885,7 +1882,6 @@ public infix fun Iterable.zip(other: Array): List> { */ public inline fun Iterable.zip(other: Array, transform: (T, R) -> V): List { val arraySize = other.size - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in this) { @@ -1908,7 +1904,6 @@ public infix fun Iterable.zip(other: Iterable): List> { public inline fun Iterable.zip(other: Iterable, transform: (T, R) -> V): List { val first = iterator() val second = other.iterator() - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10))) while (first.hasNext() && second.hasNext()) { list.add(transform(first.next(), second.next())) diff --git a/libraries/stdlib/src/generated/_Strings.kt b/libraries/stdlib/src/generated/_Strings.kt index df9de48de4f..c6f9a03ef89 100644 --- a/libraries/stdlib/src/generated/_Strings.kt +++ b/libraries/stdlib/src/generated/_Strings.kt @@ -505,7 +505,6 @@ public inline fun String.reversed(): String { * The returned map preserves the entry iteration order of the original char sequence. */ public inline fun CharSequence.associate(transform: (Char) -> Pair): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(length).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) } @@ -519,7 +518,6 @@ public inline fun CharSequence.associate(transform: (Char) -> Pair) * The returned map preserves the entry iteration order of the original char sequence. */ public inline fun CharSequence.associateBy(keySelector: (Char) -> K): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(length).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) } @@ -532,7 +530,6 @@ public inline fun CharSequence.associateBy(keySelector: (Char) -> K): Map CharSequence.associateBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(length).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) } diff --git a/libraries/stdlib/src/kotlin/collections/Iterables.kt b/libraries/stdlib/src/kotlin/collections/Iterables.kt index b46421658f3..1d6106baa54 100644 --- a/libraries/stdlib/src/kotlin/collections/Iterables.kt +++ b/libraries/stdlib/src/kotlin/collections/Iterables.kt @@ -38,13 +38,13 @@ internal class IndexingIterable(private val iteratorFactory: () -> Iterat /** * Returns the size of this iterable if it is known, or `null` otherwise. */ -@kotlin.internal.InlineExposed +@PublishedApi internal fun Iterable.collectionSizeOrNull(): Int? = if (this is Collection<*>) this.size else null /** * Returns the size of this iterable if it is known, or the specified [default] value otherwise. */ -@kotlin.internal.InlineExposed +@PublishedApi internal fun Iterable.collectionSizeOrDefault(default: Int): Int = if (this is Collection<*>) this.size else default /** Returns true when it's safe to convert this collection to a set without changing contains method behavior. */ diff --git a/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt b/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt index 6ad08cc3fe2..9b408a1d361 100644 --- a/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt +++ b/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt @@ -11,7 +11,7 @@ package kotlin.collections * @throws NoSuchElementException when the map doesn't contain a value for the specified key and no implicit default was provided for that map. */ @kotlin.jvm.JvmName("getOrImplicitDefaultNullable") -@kotlin.internal.InlineExposed +@PublishedApi internal fun Map.getOrImplicitDefault(key: K): V { if (this is MapWithDefault) return this.getOrImplicitDefault(key) diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index dd7e3fb92e6..fba51344181 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -93,7 +93,7 @@ public fun linkedMapOf(vararg pairs: Pair): LinkedHashMap * to the Collection constructor for HashSet, (c.size()/.75f) + 1, but provides further optimisations for very small or * very large sizes, allows support non-collection classes, and provides consistency for all map based class construction. */ -@kotlin.internal.InlineExposed +@PublishedApi internal fun mapCapacity(expectedSize: Int): Int { if (expectedSize < 3) { return expectedSize + 1 @@ -562,7 +562,7 @@ public inline operator fun MutableMap.plusAssign(map: Map Map.optimizeReadOnlyMap() = when (size) { 0 -> emptyMap() 1 -> toSingletonMapOrSelf() diff --git a/libraries/stdlib/src/kotlin/concurrent/Timer.kt b/libraries/stdlib/src/kotlin/concurrent/Timer.kt index 6dc737cc274..32b3b808244 100644 --- a/libraries/stdlib/src/kotlin/concurrent/Timer.kt +++ b/libraries/stdlib/src/kotlin/concurrent/Timer.kt @@ -74,7 +74,7 @@ public inline fun Timer.scheduleAtFixedRate(time: Date, period: Long, crossinlin // exposed as public -@kotlin.internal.InlineExposed +@PublishedApi internal fun timer(name: String?, daemon: Boolean) = if (name == null) Timer(daemon) else Timer(name, daemon) /** @@ -87,7 +87,6 @@ internal fun timer(name: String?, daemon: Boolean) = if (name == null) Timer(dae */ @kotlin.internal.InlineOnly public inline fun timer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.toLong(), period: Long, crossinline action: TimerTask.() -> Unit): Timer { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val timer = timer(name, daemon) timer.schedule(initialDelay, period, action) return timer @@ -102,7 +101,6 @@ public inline fun timer(name: String? = null, daemon: Boolean = false, initialDe */ @kotlin.internal.InlineOnly public inline fun timer(name: String? = null, daemon: Boolean = false, startAt: Date, period: Long, crossinline action: TimerTask.() -> Unit): Timer { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val timer = timer(name, daemon) timer.schedule(startAt, period, action) return timer @@ -118,7 +116,6 @@ public inline fun timer(name: String? = null, daemon: Boolean = false, startAt: */ @kotlin.internal.InlineOnly public inline fun fixedRateTimer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.toLong(), period: Long, crossinline action: TimerTask.() -> Unit): Timer { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val timer = timer(name, daemon) timer.scheduleAtFixedRate(initialDelay, period, action) return timer @@ -133,7 +130,6 @@ public inline fun fixedRateTimer(name: String? = null, daemon: Boolean = false, */ @kotlin.internal.InlineOnly public inline fun fixedRateTimer(name: String? = null, daemon: Boolean = false, startAt: Date, period: Long, crossinline action: TimerTask.() -> Unit): Timer { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val timer = timer(name, daemon) timer.scheduleAtFixedRate(startAt, period, action) return timer diff --git a/libraries/stdlib/src/kotlin/internal/Annotations.kt b/libraries/stdlib/src/kotlin/internal/Annotations.kt index fe99cf71c42..1c2a8d3f30b 100644 --- a/libraries/stdlib/src/kotlin/internal/Annotations.kt +++ b/libraries/stdlib/src/kotlin/internal/Annotations.kt @@ -57,11 +57,4 @@ internal annotation class OnlyInputTypes */ @Target(AnnotationTarget.FUNCTION) @Retention(AnnotationRetention.BINARY) -internal annotation class InlineOnly - -/** - * Specifies that this part of internal API is effectively public exposed by using in public inline function - */ -@Target(AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY) -@Retention(AnnotationRetention.BINARY) -internal annotation class InlineExposed \ No newline at end of file +internal annotation class InlineOnly \ No newline at end of file diff --git a/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt b/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt index 8b72940396e..6d0de8a18a8 100644 --- a/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt +++ b/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt @@ -23,7 +23,7 @@ internal open class PlatformImplementations { } @SinceKotlin("1.1") -@kotlin.internal.InlineExposed +@PublishedApi internal fun platformCloseSuppressed(instance: Closeable, cause: Throwable) = IMPLEMENTATIONS.closeSuppressed(instance, cause) diff --git a/libraries/stdlib/src/kotlin/io/ReadWrite.kt b/libraries/stdlib/src/kotlin/io/ReadWrite.kt index 88f43f37a53..86210b6eeea 100644 --- a/libraries/stdlib/src/kotlin/io/ReadWrite.kt +++ b/libraries/stdlib/src/kotlin/io/ReadWrite.kt @@ -157,7 +157,6 @@ public inline fun T.use(block: (T) -> R): R { return block(this) } catch (e: Throwable) { closed = true - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") if (this != null) platformCloseSuppressed(this, e) throw e } finally { diff --git a/libraries/stdlib/src/kotlin/text/regex/Regex.kt b/libraries/stdlib/src/kotlin/text/regex/Regex.kt index b122d4aeb21..38b864f24a0 100644 --- a/libraries/stdlib/src/kotlin/text/regex/Regex.kt +++ b/libraries/stdlib/src/kotlin/text/regex/Regex.kt @@ -94,7 +94,7 @@ public data class MatchGroup(public val value: String, public val range: IntRang * For pattern syntax reference see [Pattern] */ public class Regex -@kotlin.internal.InlineExposed +@PublishedApi internal constructor(private val nativePattern: Pattern) { diff --git a/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt b/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt index f33d1859bdb..44a7be5e38d 100644 --- a/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt +++ b/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt @@ -3,9 +3,9 @@ @file:kotlin.jvm.JvmName("PreconditionsKt") package kotlin -@kotlin.internal.InlineExposed +@PublishedApi internal object _Assertions { - @JvmField + @JvmField @PublishedApi internal val ENABLED: Boolean = javaClass.desiredAssertionStatus() } @@ -24,7 +24,6 @@ public inline fun assert(value: Boolean) { */ @kotlin.internal.InlineOnly public inline fun assert(value: Boolean, lazyMessage: () -> Any) { - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") if (_Assertions.ENABLED) { if (!value) { val message = lazyMessage() diff --git a/libraries/tools/binary-compatibility-validator/src/main/kotlin/org.jetbrains.kotlin.tools/asmUtils.kt b/libraries/tools/binary-compatibility-validator/src/main/kotlin/org.jetbrains.kotlin.tools/asmUtils.kt index 63626615b59..d10c3b39c48 100644 --- a/libraries/tools/binary-compatibility-validator/src/main/kotlin/org.jetbrains.kotlin.tools/asmUtils.kt +++ b/libraries/tools/binary-compatibility-validator/src/main/kotlin/org.jetbrains.kotlin.tools/asmUtils.kt @@ -128,7 +128,7 @@ val ClassNode.effectiveAccess: Int get() = innerClassNode?.access ?: access val ClassNode.outerClassName: String? get() = innerClassNode?.outerName -const val inlineExposedAnnotationName = "kotlin/internal/InlineExposed" +const val inlineExposedAnnotationName = "kotlin/PublishedApi" fun ClassNode.isInlineExposed() = findAnnotation(inlineExposedAnnotationName, includeInvisible = true) != null fun MethodNode.isInlineExposed() = findAnnotation(inlineExposedAnnotationName, includeInvisible = true) != null fun FieldNode.isInlineExposed() = findAnnotation(inlineExposedAnnotationName, includeInvisible = true) != null diff --git a/libraries/tools/binary-compatibility-validator/src/test/kotlin/cases/inline/inlineExposed.kt b/libraries/tools/binary-compatibility-validator/src/test/kotlin/cases/inline/inlineExposed.kt index 08f4f2b1e8c..5aee74a8739 100644 --- a/libraries/tools/binary-compatibility-validator/src/test/kotlin/cases/inline/inlineExposed.kt +++ b/libraries/tools/binary-compatibility-validator/src/test/kotlin/cases/inline/inlineExposed.kt @@ -1,24 +1,23 @@ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package cases.inline -@kotlin.internal.InlineExposed +@PublishedApi internal fun exposedForInline() {} -@kotlin.internal.InlineExposed +@PublishedApi internal class InternalClassExposed - @kotlin.internal.InlineExposed + @PublishedApi internal constructor() { - @kotlin.internal.InlineExposed + @PublishedApi internal fun funExposed() {} // TODO: Cover unsupported cases: requires correctly reflecting annotations from properties /* - @kotlin.internal.InlineExposed + @PublishedApi internal var propertyExposed: String? = null @JvmField - @kotlin.internal.InlineExposed + @PublishedApi internal var fieldExposed: String? = null */ diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index 3490a86099c..bae6c6e6bcf 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -545,7 +545,6 @@ fun generators(): List { """ val first = iterator() val second = other.iterator() - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10))) while (first.hasNext() && second.hasNext()) { list.add(transform(first.next(), second.next())) @@ -556,7 +555,6 @@ fun generators(): List { body(ArraysOfObjects, ArraysOfPrimitives) { """ val arraySize = size - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in other) { @@ -582,7 +580,6 @@ fun generators(): List { body { """ val arraySize = other.size - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val list = ArrayList(Math.min(collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in this) { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt index 6377877b218..d4565484d4d 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt @@ -181,7 +181,6 @@ fun snapshots(): List { } body { """ - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) """ @@ -193,14 +192,12 @@ fun snapshots(): List { } body(CharSequences) { """ - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(length).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) """ } body(ArraysOfObjects, ArraysOfPrimitives) { """ - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) """ @@ -255,7 +252,6 @@ fun snapshots(): List { body { """ - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) """ @@ -267,14 +263,12 @@ fun snapshots(): List { } body(CharSequences) { """ - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(length).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) """ } body(ArraysOfObjects, ArraysOfPrimitives) { """ - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector) """ @@ -329,7 +323,6 @@ fun snapshots(): List { body { """ - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) """ @@ -341,14 +334,12 @@ fun snapshots(): List { } body(CharSequences) { """ - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(length).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) """ } body(ArraysOfObjects, ArraysOfPrimitives) { """ - @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) """