Skip to content

Commit 40f2d5f

Browse files
author
alfredo-toledano
committed
doc(docs.topics.whatsNew14): add notes
1 parent a1f95f4 commit 40f2d5f

File tree

1 file changed

+56
-67
lines changed

1 file changed

+56
-67
lines changed

docs/topics/whatsnew14.md

Lines changed: 56 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
_[Released: 17 August 2020](releases.md#release-details)_
44

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/)
78

89
## Language features and improvements
910

10-
Kotlin 1.4.0 comes with a variety of different language features and improvements. They include:
11-
1211
* [SAM conversions for Kotlin interfaces](#sam-conversions-for-kotlin-interfaces)
1312
* [Explicit API mode for library authors](#explicit-api-mode-for-library-authors)
1413
* [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
1817

1918
### SAM conversions for Kotlin interfaces
2019

20+
* TODO:
2121
Before Kotlin 1.4.0, you could apply SAM (Single Abstract Method) conversions only [when working with Java methods and Java
2222
interfaces from Kotlin](java-interop.md#sam-conversions). From now on, you can use SAM conversions for Kotlin interfaces as well.
2323
To do so, mark a Kotlin interface explicitly as functional with the `fun` modifier.
@@ -42,75 +42,64 @@ fun main() {
4242

4343
### Explicit API mode for library authors
4444

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-
<tabs group="build-script">
67-
<tab title="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-
<tab title="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
9965

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+
```
10279

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+
```
10593

106-
```bash
107-
-Xexplicit-api={strict|warning}
108-
```
94+
* -- via -- CL compiler
10995

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)
111100

112101
### Mixing named and positional arguments
113-
102+
* TODO:
114103
In Kotlin 1.3, when you called a function with [named arguments](functions.md#named-arguments), you had to place all the
115104
arguments without names (positional arguments) before the first named argument. For example, you could call `f(1, y = 2)`,
116105
but you couldn't call `f(x = 1, 2)`.

0 commit comments

Comments
 (0)