Skip to content

Commit b6d815e

Browse files
committed
Allow private objects containing opaque types
1 parent aed0f78 commit b6d815e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ object Checking {
537537
checkCombination(Private, Protected)
538538
checkCombination(Abstract, Override)
539539
checkCombination(Private, Override)
540-
checkCombination(Private, Opaque)
540+
if sym.isType && !sym.isClass then checkCombination(Private, Opaque)
541541
checkCombination(Lazy, Inline)
542542
// The issue with `erased inline` is that the erased semantics get lost
543543
// as the code is inlined and the reference is removed before the erased usage check.

tests/neg/i14660.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
class Bar:
22
private opaque type Baz = Int // error
3+
4+
private object Foo:
5+
opaque type O = Int // OK
6+
7+
val x: Baz = 1
8+

0 commit comments

Comments
 (0)