Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/topics/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Additional attributes of the annotation can be specified by annotating the annot

```kotlin
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION,
AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.VALUE_PARAMETER,
AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.VALUE_PARAMETER,
AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
@MustBeDocumented
Expand Down Expand Up @@ -105,7 +105,7 @@ annotation class Ann(val arg1: KClass<*>, val arg2: KClass<out Any>)
## Instantiation

In Java, an annotation type is a form of an interface, so you can implement it and use an instance.
As an alternative to this mechanism, Kotlin lets you call a constructor of an annotation class in arbitrary code
As an alternative to this mechanism, Kotlin lets you call a constructor of an annotation class in arbitrary code
and similarly use the resulting instance.

```kotlin
Expand Down Expand Up @@ -181,7 +181,7 @@ The full list of supported use-site targets is:
```kotlin
fun @receiver:Fancy String.myExtension() { ... }
```

* `param` (constructor parameter)
* `setparam` (property setter parameter)
* `delegate` (the field storing the delegate instance for a delegated property)
Expand Down Expand Up @@ -399,7 +399,7 @@ public @interface AnnWithArrayValue {
@AnnWithArrayValue("abc", "foo", "bar") class C
```

For other arguments that have an array type, you need to use the array literal syntax or
For other arguments that have an array type, you need to use the array literal syntax or
`arrayOf(...)`:

``` java
Expand All @@ -410,7 +410,7 @@ public @interface AnnWithArrayMethod {
```

```kotlin
@AnnWithArrayMethod(names = ["abc", "foo", "bar"])
@AnnWithArrayMethod(names = ["abc", "foo", "bar"])
class C
```

Expand Down Expand Up @@ -474,4 +474,4 @@ annotation class Tags(val value: Array<Tag>)
To extract Kotlin or Java repeatable annotations via reflection, use the [`KAnnotatedElement.findAnnotations()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect.full/find-annotations.html)
function.

Learn more about Kotlin repeatable annotations in [this KEEP](https://github.com/Kotlin/KEEP/blob/master/proposals/repeatable-annotations.md).
Learn more about Kotlin repeatable annotations in [this KEEP](https://github.com/Kotlin/KEEP/blob/master/proposals/repeatable-annotations.md).
12 changes: 6 additions & 6 deletions docs/topics/build-tools-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ import org.jetbrains.kotlin.buildtools.api.ExperimentalBuildToolsApi
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

plugins {
kotlin("jvm") version "2.2.0"
kotlin("jvm") version "2.2.0"
}

group = "org.jetbrains.example"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
mavenCentral()
}

kotlin {
jvmToolchain(8)
@OptIn(ExperimentalBuildToolsApi::class, ExperimentalKotlinGradlePluginApi::class)
compilerVersion.set("2.1.21") // <-- different version than 2.2.0
jvmToolchain(8)
@OptIn(ExperimentalBuildToolsApi::class, ExperimentalKotlinGradlePluginApi::class)
compilerVersion.set("2.1.21") // <-- different version than 2.2.0
}
```

Expand Down Expand Up @@ -105,4 +105,4 @@ From Kotlin 2.2.0, the BTA is enabled by default in the [`kotlin-maven-plugin`](
Although the BTA doesn't give direct benefits for Maven users yet, it provides a solid foundation for developing features like:

* [Kotlin daemon support](https://youtrack.jetbrains.com/issue/KT-77587)
* [Incremental compilation stabilization](https://youtrack.jetbrains.com/issue/KT-77086)
* [Incremental compilation stabilization](https://youtrack.jetbrains.com/issue/KT-77086)
78 changes: 39 additions & 39 deletions docs/topics/coding-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ in method names are also allowed in test code.

```kotlin
class MyTestCase {
@Test fun `ensure everything works`() { /*...*/ }
@Test fun ensureEverythingWorks_onAndroid() { /*...*/ }
@Test fun `ensure everything works`() { /*...*/ }

@Test fun ensureEverythingWorks_onAndroid() { /*...*/ }
}
```

Expand Down Expand Up @@ -214,7 +214,7 @@ class C {
private val _elementList = mutableListOf<Element>()

val elementList: List<Element>
get() = _elementList
get() = _elementList
}
```

Expand Down Expand Up @@ -302,9 +302,9 @@ abstract class Foo<out T : Any> : IFoo {

class FooImpl : Foo() {
constructor(x: String) : this(x) { /*...*/ }

val x = object : IFoo { /*...*/ }
}
}
```

### Class headers
Expand Down Expand Up @@ -606,10 +606,10 @@ If the parameter list is too long to fit on a line, put the arrow on a separate

```kotlin
foo {
context: Context,
environment: Env
->
context.configureEnv(environment)
context: Context,
environment: Env
->
context.configureEnv(environment)
}
```

Expand Down Expand Up @@ -876,15 +876,15 @@ to treat the dollar sign chars `$` as string literals:

```kotlin
val KClass<*>.jsonSchema : String
get() = $$"""
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/product.schema.json",
"$dynamicAnchor": "meta",
"title": "$${simpleName ?: qualifiedName ?: "unknown"}",
"type": "object"
}
"""
get() = $$"""
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/product.schema.json",
"$dynamicAnchor": "meta",
"title": "$${simpleName ?: qualifiedName ?: "unknown"}",
"type": "object"
}
"""
```

## Idiomatic use of language features
Expand Down Expand Up @@ -986,7 +986,7 @@ else
when(x) {
0 -> return "zero"
else -> return "nonzero"
}
}
```

### if versus when
Expand Down Expand Up @@ -1060,25 +1060,25 @@ indentation, or `trimMargin` when internal indentation is required:
```kotlin
fun main() {
//sampleStart
println("""
Not
trimmed
text
"""
)

println("""
Trimmed
text
""".trimIndent()
)

println()

val a = """Trimmed to margin text:
|if(a > 1) {
| return a
|}""".trimMargin()
println("""
Not
trimmed
text
"""
)

println("""
Trimmed
text
""".trimIndent()
)

println()

val a = """Trimmed to margin text:
|if(a > 1) {
| return a
|}""".trimMargin()

println(a)
//sampleEnd
Expand Down
4 changes: 2 additions & 2 deletions docs/topics/compatibility-guides/compatibility-guide-22.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,9 @@ perspective (for example, from Java) is out of the scope of this document.
>
> **Short summary**: The experimental `kotlinArtifacts` API is deprecated. Use the current DSL available in the Kotlin Gradle
> plugin to [build final native binaries](https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-build-native-binaries.html).
> If it's not sufficient for migration, leave a comment in [this YT issue](https://youtrack.jetbrains.com/issue/KT-74953).
> If it's not sufficient for migration, leave a comment in [this YouTrack issue](https://youtrack.jetbrains.com/issue/KT-74953).
>
> **Deprecation cycle**:
>
> - 2.2.0: report a warning when the `kotlinArtifacts` API is used
> - 2.3.0: raise this warning to an error
> - 2.3.0: raise this warning to an error
2 changes: 1 addition & 1 deletion docs/topics/coroutines-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The `suspend` keyword marks functions that can perform long-running operations a

To launch new coroutines, use coroutine builders like [`.launch()`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/launch.html) and [`.async()`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html).
These builders are extension functions on [`CoroutineScope`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/),
which defines the coroutines lifecycle and provides the coroutine context.
which defines the coroutine's lifecycle and provides the coroutine context.

You can learn more about these builders in [Coroutine basics](coroutines-basics.md) and [Composing suspend functions](coroutines-and-channels.md).

Expand Down
10 changes: 4 additions & 6 deletions docs/topics/data-analysis/data-analysis-work-with-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,25 @@ This ensures you gather data across multiple pages:

```kotlin
fun load(path: String, maxPages: Int): AnyFrame {

// Initializes a mutable list to store rows of data.
val rows = mutableListOf<AnyRow>()

// Sets the initial page path for data loading.
var pagePath = path
do {

// Loads data from the current page path.
val row = load(pagePath)
// Adds the loaded data as a row to the list.
rows.add(row)

// Retrieves the token for the next page, if available.
val next = row.getValueOrNull<String>("nextPageToken")
// Updates the page path for the next iteration, including the new token.
pagePath = path + "&pageToken=" + next

// Continues loading pages until there's no next page.
} while (next != null && rows.size < maxPages)

// Concatenates and returns all loaded rows as a DataFrame.
return rows.concat()
}
Expand Down
12 changes: 6 additions & 6 deletions docs/topics/gradle/gradle-binary-compatibility-validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ kotlin {
</tab>
<tab title="Groovy" group-key="groovy">

```kotlin
```groovy
kotlin {
abiValidation {
enabled = true
Expand All @@ -56,7 +56,7 @@ If your project has multiple modules where you want to check for binary compatib
To check for potentially binary incompatible issues after making changes to your code, run the `checkLegacyAbi` Gradle task
in IntelliJ IDEA or use the following command in your project directory:

```kotlin
```bash
./gradlew checkLegacyAbi
```

Expand All @@ -68,7 +68,7 @@ make changes to your code to preserve binary compatibility.
To update the reference ABI dump that Gradle uses to check your latest changes, run the `updateLegacyAbi` task in IntelliJ
IDEA or use the following command in your project directory:

```kotlin
```bash
./gradlew updateLegacyAbi
```

Expand Down Expand Up @@ -121,7 +121,7 @@ kotlin {
</tab>
<tab title="Groovy" group-key="groovy">

```kotlin
```groovy
kotlin {
abiValidation {
filters {
Expand Down Expand Up @@ -177,7 +177,7 @@ kotlin {
</tab>
<tab title="Groovy" group-key="groovy">

```kotlin
```groovy
kotlin {
abiValidation {
klib {
Expand All @@ -191,4 +191,4 @@ kotlin {
</tabs>

If a target is unsupported and inference is disabled, the `checkLegacyAbi` task fails because it can't generate a complete
ABI dump. This behavior may be useful if you'd prefer the task to fail rather than risk missing a binary-incompatible change.
ABI dump. This behavior may be useful if you'd prefer the task to fail rather than risk missing a binary-incompatible change.
14 changes: 7 additions & 7 deletions docs/topics/gradle/gradle-compiler-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ configuration of compiler options. It is available for [Kotlin Multiplatform](ht
With the Gradle DSL, you can configure compiler options within the build script at three levels:
* **[Extension level](#extension-level)**, in the `kotlin {}` block for all targets and shared source sets.
* **[Target level](#target-level)**, in the block for a specific target.
* **[Compilation unit level](#compilation-unit-level),** usually in a specific compilation task.
* **[Compilation unit level](#compilation-unit-level)**, usually in a specific compilation task.

![Kotlin compiler options levels](compiler-options-levels.svg){width=700}

Expand Down Expand Up @@ -57,7 +57,7 @@ kotlin {
compilerOptions {
optIn.add("kotlin.RequiresOptIn")
}
}
}
```

### Target level
Expand All @@ -67,7 +67,7 @@ in the `compilerOptions {}` block inside the `target {}` block:

```kotlin
kotlin {
target {
target {
compilerOptions {
optIn.add("kotlin.RequiresOptIn")
}
Expand All @@ -83,7 +83,7 @@ specific target. For example, `jvm { compilerOptions {}}`. For more information,
You can configure compiler options for a specific compilation unit or task in a `compilerOptions {}`
block inside the task configuration:

```Kotlin
```kotlin
tasks.named<KotlinJvmCompile>("compileKotlin"){
compilerOptions {
optIn.add("kotlin.RequiresOptIn")
Expand All @@ -93,7 +93,7 @@ tasks.named<KotlinJvmCompile>("compileKotlin"){

You can also access and configure compiler options at a compilation unit level via `KotlinCompilation`:

```Kotlin
```kotlin
kotlin {
target {
val main by compilations.getting {
Expand Down Expand Up @@ -293,8 +293,8 @@ Update it to:

```kotlin
plugins {
id("com.android.application")
kotlin("android")
id("com.android.application")
kotlin("android")
}

kotlin {
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/js/js-project-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ You can enable all the supported ES2015 features at once by adding the `es2015`

```kotlin
tasks.withType<KotlinJsCompile>().configureEach {
kotlinOptions {
compilerOptions {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

JFYI
IMO:
kotlinOptions is deprecated, should use compilerOptions instead

target = "es2015"
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/jvm/java-to-kotlin-interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ The Kotlin visibility modifiers map to Java in the following way:
if accessed from within a class.
* `protected` remains `protected`. (Note that Java allows accessing protected members from other classes in the same package
and Kotlin doesn't, so Java classes will have broader access to the code.)
* `internal` declarations become `public` in Java. Members of `internal` classes go through name mangling, to make.
* `internal` declarations become `public` in Java. Members of `internal` classes go through name mangling, to make
it harder to accidentally use them from Java and to allow overloading for members with the same signature that don't see
each other according to Kotlin rules.
* `public` remains `public`.
Expand Down
Loading