Skip to content

Commit 079b4f9

Browse files
committed
Document restriction
1 parent 9173aba commit 079b4f9

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

docs/docs/reference/other-new-features/opaques-details.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ object o {
4646
def id(x: o.T): o.T = x
4747
```
4848

49+
### Type Parameters of Opaque Types
50+
51+
Opaque type aliases can have a single type parameter list. The following aliases
52+
are well-formed
53+
```scala
54+
opaque type F[T] = (T, T)
55+
opaque type G = [T] =>> List[T]
56+
```
57+
but the following are not:
58+
```scala
59+
opaque type BadF[T] = [U] =>> (T, U)
60+
opaque type BadG = [T] =>> [U] => (T, U)
61+
```
62+
4963
### Translation of Equality
5064

5165
Comparing two values of opaque type with `==` or `!=` normally uses universal equality,

tests/neg/i9735.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ opaque type T = [A] =>> [B] =>> String // error: opaque type alias cannot have m
55
opaque type S = [B] =>> String // ok
66
opaque type IArray[+T] = Array[? <: T] // ok
77
opaque type S2[B] = String // ok
8+
9+
opaque type BadF[T] = [U] =>> (T, U) // error
10+
opaque type BadG = [T] =>> [U] =>> (T, U) // error
11+
12+

0 commit comments

Comments
 (0)