You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/topics/whatsnew14.md
+56-67Lines changed: 56 additions & 67 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,12 @@
2
2
3
3
_[Released: 17 August 2020](releases.md#release-details)_
4
4
5
-
In Kotlin 1.4.0, we ship a number of improvements in all of its components, with the [focus on quality and performance](https://blog.jetbrains.com/kotlin/2020/08/kotlin-1-4-released-with-a-focus-on-quality-and-performance/).
6
-
Below you will find the list of the most important changes in Kotlin 1.4.0.
5
+
* | Kotlin 1.4.0,
6
+
* improvements | ALL of its components
7
+
*[focus on quality and performance](https://blog.jetbrains.com/kotlin/2020/08/kotlin-1-4-released-with-a-focus-on-quality-and-performance/)
7
8
8
9
## Language features and improvements
9
10
10
-
Kotlin 1.4.0 comes with a variety of different language features and improvements. They include:
11
-
12
11
*[SAM conversions for Kotlin interfaces](#sam-conversions-for-kotlin-interfaces)
13
12
*[Explicit API mode for library authors](#explicit-api-mode-for-library-authors)
14
13
*[Mixing named and positional arguments](#mixing-named-and-positional-arguments)
@@ -18,6 +17,7 @@ Kotlin 1.4.0 comes with a variety of different language features and improvement
18
17
19
18
### SAM conversions for Kotlin interfaces
20
19
20
+
* TODO:
21
21
Before Kotlin 1.4.0, you could apply SAM (Single Abstract Method) conversions only [when working with Java methods and Java
22
22
interfaces from Kotlin](java-interop.md#sam-conversions). From now on, you can use SAM conversions for Kotlin interfaces as well.
23
23
To do so, mark a Kotlin interface explicitly as functional with the `fun` modifier.
@@ -42,75 +42,64 @@ fun main() {
42
42
43
43
### Explicit API mode for library authors
44
44
45
-
Kotlin compiler offers _explicit API mode_ for library authors. In this mode, the compiler performs additional checks that
46
-
help make the library's API clearer and more consistent. It adds the following requirements for declarations exposed
47
-
to the library's public API:
48
-
49
-
* Visibility modifiers are required for declarations if the default visibility exposes them to the public API.
50
-
This helps ensure that no declarations are exposed to the public API unintentionally.
51
-
* Explicit type specifications are required for properties and functions that are exposed to the public API.
52
-
This guarantees that API users are aware of the types of API members they use.
53
-
54
-
Depending on your configuration, these explicit APIs can produce errors (_strict_ mode) or warnings (_warning_ mode).
55
-
Certain kinds of declarations are excluded from such checks for the sake of readability and common sense:
56
-
57
-
* primary constructors
58
-
* properties of data classes
59
-
* property getters and setters
60
-
*`override` methods
61
-
62
-
Explicit API mode analyzes only the production sources of a module.
63
-
64
-
To compile your module in the explicit API mode, add the following lines to your Gradle build script:
65
-
66
-
<tabsgroup="build-script">
67
-
<tabtitle="Kotlin"group-key="kotlin">
68
-
69
-
```kotlin
70
-
kotlin {
71
-
// for strict mode
72
-
explicitApi()
73
-
// or
74
-
explicitApi =ExplicitApiMode.Strict
75
-
76
-
// for warning mode
77
-
explicitApiWarning()
78
-
// or
79
-
explicitApi =ExplicitApiMode.Warning
80
-
}
81
-
```
82
-
83
-
</tab>
84
-
<tabtitle="Groovy"group-key="groovy">
85
-
86
-
```groovy
87
-
kotlin {
88
-
// for strict mode
89
-
explicitApi()
90
-
// or
91
-
explicitApi = 'strict'
92
-
93
-
// for warning mode
94
-
explicitApiWarning()
95
-
// or
96
-
explicitApi = 'warning'
97
-
}
98
-
```
45
+
*_explicit API mode_
46
+
* Kotlin compiler's mode -- for -- library authors
47
+
* -> compiler -- performs -- additional checks / library's API clearer and more consistent
48
+
* -> 👀new requirements for declarations / exposed | library's public API👀
49
+
* if the default visibility -- exposes the -- declarations to the public API -> required visibility for declarations
50
+
* -> ensure / NO declarations -- are exposed unintentionally, to the -- public API
51
+
* explicit type specifications for properties & functions / -- are exposed to the -- public API
52
+
* -> ensure / API users -- are aware of the -- types of API members
53
+
* declarations / excluded -- from such -- checks
54
+
* primary constructors
55
+
* properties of data classes
56
+
* property getters and setters
57
+
*`override` methods
58
+
* ONLY | production sources of a module
59
+
*\+ other configurations
60
+
* if + _strict_ mode -> explicit APIs -- can produce -- errors
61
+
* if + _warning_ mode -> explicit APIs -- can produce -- warnings
62
+
63
+
* way to configure
64
+
* | your Gradle build script
99
65
100
-
</tab>
101
-
</tabs>
66
+
```kotlin
67
+
kotlin {
68
+
// for strict mode
69
+
explicitApi()
70
+
// or
71
+
explicitApi =ExplicitApiMode.Strict
72
+
73
+
// for warning mode
74
+
explicitApiWarning()
75
+
// or
76
+
explicitApi =ExplicitApiMode.Warning
77
+
}
78
+
```
102
79
103
-
When using the command-line compiler, switch to explicit API mode by adding the `-Xexplicit-api` compiler option
104
-
with the value `strict` or `warning`.
80
+
```groovy
81
+
kotlin {
82
+
// for strict mode
83
+
explicitApi()
84
+
// or
85
+
explicitApi ='strict'
86
+
87
+
// for warning mode
88
+
explicitApiWarning()
89
+
// or
90
+
explicitApi ='warning'
91
+
}
92
+
```
105
93
106
-
```bash
107
-
-Xexplicit-api={strict|warning}
108
-
```
94
+
*-- via --CL compiler
109
95
110
-
[Find more details about the explicit API mode in the KEEP](https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md).
96
+
```bash
97
+
... -Xexplicit-api={strict|warning}
98
+
```
99
+
* see [more details | KEEP](https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md)
111
100
112
101
### Mixing named and positional arguments
113
-
102
+
*TODO:
114
103
InKotlin1.3, when you called a function with [named arguments](functions.md#named-arguments), you had to place all the
115
104
arguments without names (positional arguments) before the first named argument. For example, you could call `f(1, y =2)`,
0 commit comments