Skip to content

Commit 7d0a0f9

Browse files
committed
tw review: captured types (part 3)
1 parent 48f43f2 commit 7d0a0f9

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

docs/topics/generics.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,12 @@ array.set(0, "New value")
302302

303303
In this example:
304304

305-
* Array has the projected type `Array<out CharSequence>`. The compiler represents the projected type
305+
* The variable `array` has the projected type `Array<out CharSequence>`. The compiler represents the projected type
306306
argument `out CharSequence` as a captured type with `CharSequence` as its upper bound and `Nothing` as its lower bound.
307-
* For the `get()` operation, the compiler approximates the captured type to its upper bound and infers `CharSequence` as
308-
the type of `item`. The exact element type behind the projection can be `CharSequence` or one of its subtypes.
309-
* For the `set()` operation, the captured type has `Nothing` as its lower bound. Because `Nothing` has no instances, no
310-
value can satisfy this bound. Therefore, writing to the projected type with the `set()` function isn't type-safe and
311-
results in an error.
307+
* For the `get()` operation, the compiler approximates the captured type to its upper bound, `CharSequence`, and infers
308+
`CharSequence` as the type of `item`.
309+
* For the `set()` operation, the captured type has `Nothing` as its lower bound. Since `Nothing` has no instances, writing
310+
a value to the projected type isn’t type-safe and results in an error.
312311

313312
## Generic functions
314313

0 commit comments

Comments
 (0)