Skip to content

Commit b0fb714

Browse files
committed
Update docs
1 parent b8be20f commit b0fb714

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

docs/docs/reference/new-types/union-types-spec.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ treatment of singleton types which are also widened to their underlying type
8888
unless explicitly specified. and the motivation is the same: inferring types
8989
which are "too precise" can lead to unintuitive typechecking issues later on.
9090

91-
Note: Since this behavior severely limits the usability of union types, it might
91+
Note: Since this behavior limits the usability of union types, it might
9292
be changed in the future. For example by not widening unions that have been
9393
explicitly written down by the user and not inferred, or by not widening a type
9494
argument when the corresponding type parameter is covariant. See
@@ -149,7 +149,3 @@ the erased lub is computed as follows:
149149
The reason to pick last is that we prefer classes over traits that way,
150150
which leads to more predictable bytecode and (?) faster dynamic dispatch.
151151

152-
## Limitations
153-
154-
In a union type `A | B`, neither `A` nor `B` is allowed to be a singleton type.
155-
This is an implementation restriction that may be lifted in the future.

docs/docs/reference/new-types/union-types.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ layout: doc-page
33
title: "Union Types"
44
---
55

6-
Used on types, the `|` operator creates a union type.
6+
A union type `A | B` has as values all values of type `A` and also all values of type `B`.
7+
78

89
```scala
910
case class UserName(name: String) {
@@ -22,13 +23,11 @@ def help(id: UserName | Password) = {
2223
}
2324
```
2425

25-
Union types are dual of intersection types. Values of type `A | B` are
26-
all values of type `A` and all values of type `B`. `|` is _commutative_:
26+
Union types are duals of intersection types. `|` is _commutative_:
2727
`A | B` is the same type as `B | A`.
2828

2929
The compiler will assign a union type to an expression only if such a
30-
type is explicitly given.
31-
This can be seen in the following REPL transcript:
30+
type is explicitly given. This can be seen in the following REPL transcript:
3231

3332
```scala
3433
scala> val password = Password(123)

0 commit comments

Comments
 (0)