Skip to content

Commit 8c8e03e

Browse files
committed
Disallow private opaque type aliases
Fixes scala#14660
1 parent 9abe753 commit 8c8e03e

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ object Checking {
537537
checkCombination(Private, Protected)
538538
checkCombination(Abstract, Override)
539539
checkCombination(Private, Override)
540+
checkCombination(Private, Opaque)
540541
checkCombination(Lazy, Inline)
541542
// The issue with `erased inline` is that the erased semantics get lost
542543
// as the code is inlined and the reference is removed before the erased usage check.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ object o:
5151
def id(x: o.T): o.T = x
5252
```
5353

54+
Opaque type aliases cannot be `private` and cannot overridden in subclasses.
55+
5456
## Type Parameters of Opaque Types
5557

5658
Opaque type aliases can have a single type parameter list. The following aliases

tests/neg/i14660.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Bar:
2+
private opaque type Baz = Int // error

0 commit comments

Comments
 (0)