Skip to content

Disallow private opaque type aliases #14666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ object Checking {
checkCombination(Private, Protected)
checkCombination(Abstract, Override)
checkCombination(Private, Override)
checkCombination(Private, Opaque)
checkCombination(Lazy, Inline)
// The issue with `erased inline` is that the erased semantics get lost
// as the code is inlined and the reference is removed before the erased usage check.
Expand Down
2 changes: 2 additions & 0 deletions docs/_docs/reference/other-new-features/opaques-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ object o:
def id(x: o.T): o.T = x
```

Opaque type aliases cannot be `private` and cannot overridden in subclasses.

## Type Parameters of Opaque Types

Opaque type aliases can have a single type parameter list. The following aliases
Expand Down
2 changes: 2 additions & 0 deletions tests/neg/i14660.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Bar:
private opaque type Baz = Int // error