Skip to content

feat: Kotlin 2.1.20-Beta2 release #4680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 29, 2025
Merged

Conversation

danil-pavlov
Copy link
Contributor

No description provided.

@AlexanderPrendota
Copy link
Collaborator

Bad samples
Snippets:
File: docs/topics/whatsnew-eap.md

// Imports the necessary libraries
import kotlin.concurrent.atomics.*
import kotlinx.coroutines.*

//sampleStart
@OptIn(ExperimentalAtomicApi::class)
suspend fun main() {
    // Initializes the atomic counter for processed items
    var processedItems = AtomicInt(0)
    val totalItems = 100
    val items = List(totalItems) { "item$it" }
    // Splits the items into chunks for processing by multiple coroutines
    val chunkSize = 20
    val itemChunks = items.chunked(chunkSize)
    coroutineScope {
        for (chunk in itemChunks) {
            launch {
                for (item in chunk) {
                    println("Processing $item in thread ${Thread.currentThread()}")
                    processedItems += 1 // Increment counter atomically
                }
            }
         }
    }
//sampleEnd
    // Prints the total number of processed items
    println("Total processed items: ${processedItems.load()}")
}

(1:25, 1:32) ERROR Unresolved reference 'atomics'.
(5:7, 5:28) ERROR Unresolved reference 'ExperimentalAtomicApi'.
(5:7, 5:35) ERROR Annotation argument must be a compile-time constant.
(8:25, 8:34) ERROR Unresolved reference 'AtomicInt'.


File: docs/topics/whatsnew-eap.md

// Imports the necessary libraries
import kotlin.concurrent.atomics.*
import java.util.concurrent.atomic.*

//sampleStart
@OptIn(ExperimentalAtomicApi::class)
fun main() {
    // Converts Kotlin AtomicInt to Java's AtomicInteger
    val kotlinAtomic = AtomicInt(42)
    val javaAtomic: AtomicInteger = kotlinAtomic.asJavaAtomic()
    println("Java atomic value: ${javaAtomic.get()}")
    // Java atomic value: 42

    // Converts Java's AtomicInteger back to Kotlin's AtomicInt
    val kotlinAgain: AtomicInt = javaAtomic.asKotlinAtomic()
    println("Kotlin atomic value: ${kotlinAgain.load()}")
    // Kotlin atomic value: 42
}
//sampleEnd

(1:25, 1:32) ERROR Unresolved reference 'atomics'.
(5:7, 5:28) ERROR Unresolved reference 'ExperimentalAtomicApi'.
(5:7, 5:35) ERROR Annotation argument must be a compile-time constant.
(8:23, 8:32) ERROR Unresolved reference 'AtomicInt'.
(14:21, 14:30) ERROR Unresolved reference 'AtomicInt'.
(14:44, 14:58) ERROR Unresolved reference 'asKotlinAtomic'.
(15:48, 15:52) ERROR Unresolved reference 'load'.


File: docs/topics/whatsnew-eap.md

import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid

//sampleStart
@OptIn(ExperimentalUuidApi::class)
fun main() {
    // Use parse() to accept a UUID in a plain hexadecimal format
    val uuid = Uuid.parse("550e8400e29b41d4a716446655440000")

    // Convert it to the hex-and-dash format
    val hexDashFormat = uuid.toHexDashString()
    println(hexDashFormat)
    // Output: 550e8400-e29b-41d4-a716-446655440000
}
//sampleEnd

(0:14, 0:18) ERROR Unresolved reference 'uuid'.
(1:14, 1:18) ERROR Unresolved reference 'uuid'.
(4:7, 4:26) ERROR Unresolved reference 'ExperimentalUuidApi'.
(4:7, 4:33) ERROR Annotation argument must be a compile-time constant.
(7:15, 7:19) ERROR Unresolved reference 'Uuid'.
(11:4, 11:11) ERROR Overload resolution ambiguity between candidates:
@InlineOnly() fun println(message: Any?): Unit
@InlineOnly() fun println(message: Boolean): Unit
@InlineOnly() fun println(message: Byte): Unit
@InlineOnly() fun println(message: Char): Unit
@InlineOnly() fun println(message: CharArray): Unit
@InlineOnly() fun println(message: Double): Unit
@InlineOnly() fun println(message: Float): Unit
@InlineOnly() fun println(message: Int): Unit
@InlineOnly() fun println(message: Long): Unit
@InlineOnly() fun println(message: Short): Unit


@danil-pavlov
Copy link
Contributor Author

No, that's all right, the Playground just doesn't support this version yet

@danil-pavlov danil-pavlov marked this pull request as ready for review January 29, 2025 10:23
@danil-pavlov danil-pavlov requested a review from a team as a code owner January 29, 2025 10:23
Copy link
Contributor

@daniCsorbaJB daniCsorbaJB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left one minor comment - otherwise LGTM, thank you! 👍

@danil-pavlov danil-pavlov merged commit b02cc91 into master Jan 29, 2025
4 checks passed
@danil-pavlov danil-pavlov deleted the 2-1-20-beta2-eap-release branch January 29, 2025 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants