Skip to content

Commit 0daaf5d

Browse files
authored
Merge pull request #79 from Kotlin/develop
In preparation for kotlin-spec 1.5 release
2 parents 5617b8c + e79140a commit 0daaf5d

File tree

3,954 files changed

+525546
-634313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,954 files changed

+525546
-634313
lines changed

CONTRIBUTING.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ You have several options on how to contribute.
1111
1. Make a [pull request](https://github.com/Kotlin/kotlin-spec/pulls)
1212
1. Drop an email to [Marat Akhin](mailto:marat.akhin@jetbrains.com) or [Mikhail Belyaev](mailto:mikhail.belyaev@jetbrains.com)
1313

14+
> Note: if doing a pull request, it should be based on the `develop` branch.
15+
1416
In any of these cases, if we are talking about semantic changes to the specification, please try to include not only the improvements themselves, but also the reasoning on why you believe such a change is needed.
1517

1618
> If we are talking about simple, but still very much appreciated improvements, e.g., fixing grammar, spelling or punctuation mistakes, no justification is required for those.

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
This repository contains the specification of the [Kotlin programming language](https://kotlinlang.org), which describes how parts of the language should function *in more detail*, as compared to a more traditional user documentation on the [Kotlin Website](https://kotlinlang.org/docs/reference/).
88

9-
It would be most useful to those who are interested in how Kotlin works on a finer lever and how its features interoperate, e.g., language enthusiasts, compiler writers and Kotlin power-users.
9+
It would be most useful to those who are interested in how Kotlin works on a finer level and how its features interoperate, e.g., language enthusiasts, compiler writers and Kotlin power-users.
1010
However, if you are simply wondering, why some code you wrote works the way it does, this specification might help you get an answer to that.
1111

1212
Currently, the specification covers only what we call *Kotlin/Core*: fundamental parts of Kotlin which should function the same way irregardless of the underlying platform.
@@ -67,6 +67,8 @@ You can help us make the Kotlin specification better by one of the following way
6767
1. Discuss the specification on the Kotlin [forums](https://discuss.kotlinlang.org/)
6868
1. Drop an email to [Marat Akhin](mailto:marat.akhin@jetbrains.com) or [Mikhail Belyaev](mailto:mikhail.belyaev@jetbrains.com) with your suggestions
6969

70+
> Note: if doing a pull request, it should be based on the `develop` branch.
71+
7072
We welcome any and all feedback to the specification, but may tweak, change or iterate with you on the contribution before including it in the specification.
7173

7274
Further details on how to contribute to the specification are available in [CONTRIBUTING.md](CONTRIBUTING.md).

build.gradle.kts

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import at.phatbl.shellexec.ShellExec
2+
13
plugins {
24
id("at.phatbl.shellexec") version "1.1.3"
35
}
@@ -108,3 +110,8 @@ tasks.create<Delete>("clean") {
108110

109111
delete("$projectDir/build")
110112
}
113+
114+
tasks.create<ShellExec>("syncGrammarWithKotlinGrammarApache2Repo") {
115+
group = "internal"
116+
command = """echo -e Run the following command: git checkout release \&\& git subtree push --prefix grammar/src/main/antlr git@github.com:Kotlin/kotlin-grammar-apache2 release"""
117+
}

docs/build.gradle.kts

+24-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import at.phatbl.shellexec.ShellExec
22
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
33
import java.nio.file.Paths
4+
import java.net.URI
45

56
plugins {
67
application
7-
id("kotlin") version "1.3.41"
8+
id("kotlin") version "1.4.31"
89
id("at.phatbl.shellexec")
910
}
1011

@@ -26,10 +27,10 @@ fun getScriptText(scriptName: String): String {
2627

2728
val res = with(StringBuilder()) {
2829
append("PROJECT_DIR=$projectDir$ls")
29-
if(disableTODOS) append("TODO_OPTION=--disable-todos$ls")
30+
if (disableTODOS) append("TODO_OPTION=--disable-todos$ls")
3031
else append("TODO_OPTION=--enable-todos$ls")
3132

32-
if(enableStaticMath) append("STATIC_MATH_OPTION=--enable-static-math$ls")
33+
if (enableStaticMath) append("STATIC_MATH_OPTION=--enable-static-math$ls")
3334
else append("STATIC_MATH_OPTION=--disable-static-math$ls")
3435

3536
append(buildTemplate)
@@ -39,23 +40,32 @@ fun getScriptText(scriptName: String): String {
3940
}
4041

4142
repositories {
42-
maven { setUrl("https://dl.bintray.com/vorpal-research/kotlin-maven") }
43+
maven {
44+
url = URI("https://maven.pkg.github.com/vorpal-research/kotlin-maven")
45+
credentials {
46+
username = "vorpal-reseacher"
47+
password = "\u0031\u0030\u0062\u0037\u0064\u0066\u0031\u0032\u0063\u0064" +
48+
"\u0035\u0034\u0038\u0037\u0034\u0065\u0030\u0034\u0035\u0035" +
49+
"\u0038\u0031\u0063\u0039\u0039\u0062\u0031\u0066\u0032\u0030" +
50+
"\u0038\u0065\u0031\u0061\u0035\u0033\u0065\u0036\u0032\u0038"
51+
}
52+
}
4353
mavenCentral()
4454
}
4555

46-
java.sourceSets {
47-
"main" {
56+
sourceSets {
57+
main {
4858
java.srcDir("src/main/kotlin")
4959
}
5060
}
5161

5262
dependencies {
53-
compile("ru.spbstu:g4toEBNF:0.0.0.3")
54-
compile("ru.spbstu:kotlin-pandoc:0.0.10")
55-
compile("ru.spbstu:simple-diagrammer:0.0.0.6")
56-
compile("com.github.ajalt:clikt:1.7.0")
57-
compile("com.zaxxer:nuprocess:2.0.1")
58-
compile("org.antlr:antlr4:4.+")
63+
implementation("ru.spbstu:g4-to-ebnf:0.0.0.4")
64+
implementation("ru.spbstu:kotlin-pandoc:0.0.13")
65+
implementation("ru.spbstu:simple-diagrammer:0.0.0.7")
66+
implementation("com.github.ajalt:clikt:1.7.0")
67+
implementation("com.zaxxer:nuprocess:2.0.1")
68+
implementation("org.antlr:antlr4:4.+")
5969
}
6070

6171
tasks.withType<KotlinCompile> {
@@ -96,7 +106,7 @@ tasks.create<JavaExec>("convertGrammar") {
96106

97107
outputs.file(outputFile)
98108

99-
classpath = java.sourceSets["main"].runtimeClasspath
109+
classpath = sourceSets["main"].runtimeClasspath
100110
main = "org.jetbrains.kotlin.spec.ConvertGrammarKt"
101111
args = listOf("-d", grammarsDir, "-l", lexerGrammar, "-p", parserGrammar, "-o", outputFile)
102112
}
@@ -130,7 +140,7 @@ tasks.create<ShellExec>("buildHtmlBySections") {
130140
tasks.create<JavaExec>("execute") {
131141
group = "internal"
132142

133-
classpath = java.sourceSets["main"].runtimeClasspath
143+
classpath = sourceSets["main"].runtimeClasspath
134144

135145
main = project.findProperty("mainClass") as? String ?: ""
136146
args = (project.findProperty("args") as? String)?.split(" ") ?: emptyList()

docs/scripts/build/buildHtml.sh

100644100755
File mode changed.

docs/scripts/build/buildHtmlBySections.sh

100644100755
File mode changed.

docs/scripts/build/directories.sh

100755100644
File mode changed.

docs/src/md/commands.md

+2
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,5 @@
112112

113113
\opMathIT{\Assigned}{Assigned}
114114
\opMathIT{\Unassigned}{Unassigned}
115+
116+
\newcommand{\coroutineSuspended}{\texttt{CO\-RO\-U\-TINE\-\_SUS\-PEN\-DED}}

docs/src/md/kotlin.core/annotations.md

+28-4
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,15 @@ Annotations may be declared *repeatable* (meaning that the same annotation may b
112112
`kotlin.annotation.Repeatable` is an annotation which is only used on annotation classes to specify whether this particular annotation is repeatable.
113113
Annotations are non-repeatable by default.
114114

115-
* `kotlin.Experimental` / `kotlin.UseExperimental`
115+
* `kotlin.RequiresOptIn` / `kotlin.OptIn`
116116

117-
`kotlin.Experimental` is an annotation class with a single field:
117+
`kotlin.RequiresOptIn` is an annotation class with two fields:
118+
119+
* ```kotlin
120+
val message: String = ""
121+
```
122+
123+
The message describing the particular opt-in requirements.
118124

119125
* ```kotlin
120126
val level: Level = Level.ERROR
@@ -124,17 +130,19 @@ Annotations may be declared *repeatable* (meaning that the same annotation may b
124130

125131
This annotation is used to introduce implementation-defined experimental language or standard library features.
126132

127-
`kotlin.UseExperimental` is an annotation class with a single field:
133+
`kotlin.OptIn` is an annotation class with a single field:
128134

129135
* ```kotlin
130136
vararg val markerClass: KClass<out Annotation>
131137
```
132138

133139
The classes which this annotation allows to use.
134140

135-
This annotation is used to explicitly mark declarations which use experimental features marked by `kotlin.Experimental`.
141+
This annotation is used to explicitly mark declarations which use experimental features marked by `kotlin.RequiresOptIn`.
136142

137143
It is implementation-defined how this annotation is processed.
144+
145+
> Note: before Kotlin 1.4.0, there were two other built-in annotations: `@Experimental` (now replaced by `@RequiresOptIn`) and `@UseExperimental` (now replaced by `@OptIn`) serving the same purpose which are now deprecated.
138146

139147
TODO(Experimental status is still experimental itself)
140148

@@ -226,3 +234,19 @@ Annotations may be declared *repeatable* (meaning that the same annotation may b
226234
`kotlin.PublishedApi` is an annotation class with no fields which is applicable to any declaration.
227235
It may be applied to any declaration with `internal` visibility to make it available to `public` `inline` declarations.
228236
See [Declaration visibility section][Declaration visibility] for details.
237+
238+
* `kotlin.BuilderInference`
239+
240+
Marks the annotated function of function argument as eligible for [builder-style type inference][Builder-style type inference].
241+
See corresponding section for details.
242+
243+
> Note: as of Kotlin 1.4.0, this annotation is experimental and, in order to use it in one's code, one must explicitly enable it using opt-in annotations given above.
244+
> The particular marker class used to perform this is implementation-defined.
245+
246+
* `kotlin.RestrictSuspension`
247+
248+
In some cases we may want to limit which [suspending functions] can be called in another suspending function with an extension receiver of a specific type; i.e., if we want to provide a coroutine-enabled DSL, but disallow the use of arbitrary suspending functions.
249+
To do so, the type `T` of that extension receiver needs to be annotated with `kotlin.RestrictSuspension`, which enables the following limitations.
250+
251+
* Suspending functions with an extention receiver of type `T` are restricted from calling other suspending functions besides those accessible on this receiver.
252+
* Suspending functions of type `T` can be called only on an extention receiver.

docs/src/md/kotlin.core/builtins.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,14 @@ It is the type of the result of [string interpolation][String interpolation expr
183183
184184
Contains the ordinal of this enumeration constant, i.e., its position in the declaration, starting from zero.
185185
186-
`kotlin.Enum<T>` provides the following methods.
186+
`kotlin.Enum<T>` provides the following member functions.
187187
188188
* ```kotlin
189189
public override final fun compareTo(other: T): Int
190190
```
191+
192+
The implementation of `kotlin.Comparable`.
193+
The result of `a.compareTo(b)` for enum class instances `a` and `b` is equivalent to `a.ordinal.compareTo(b.ordinal)`.
191194
192195
* ```kotlin
193196
public override final fun equals(other: Any?): Boolean
@@ -197,13 +200,18 @@ It is the type of the result of [string interpolation][String interpolation expr
197200
public override final fun hashCode(): Int
198201
```
199202
200-
> Note: the presence of these final methods ensures the semantics of equality and comparison for the enumeration objects, as they cannot be overridden by the user.
203+
These member functions are defined to their default behaviour: only the same entry of an enum class is equal to itself and no other object.
204+
Hash implementation is required to be consistent, but unspecified.
205+
206+
> Note: the presence of these final member functions ensures the semantics of equality and comparison for the enumeration objects, as they cannot be overridden by the user.
201207
202208
* ```kotlin
203209
protected final fun clone(): Any
204210
```
205211
206-
> Note: the `clone()` implementation throws an exception, as enumeration objects cannot be copied.
212+
Throws an unspecified exception.
213+
214+
> Note: the `clone()` implementation throws an exception, as enumeration objects cannot be copied and on some platforms `clone` function serves for copying.
207215
208216
### Built-in array types
209217
@@ -217,6 +225,8 @@ It is final (i.e., cannot be inherited from) and has the following public constr
217225
218226
Creates a new array with the specified size, where each element is calculated by calling the specified `init` function with the corresponding element's index.
219227
The function `init` is called for each array element sequentially starting from the first one.
228+
This constructor is special in two ways: first, it is `inline` and inline constructors are not generally allowed in Kotlin.
229+
Second, it is required for the parameter `T` to be instantiated with a [runtime-available type][Runtime-available types].
220230
221231
`kotlin.Array<T>` provides the following methods and properties.
222232

0 commit comments

Comments
 (0)