File tree 3 files changed +27
-7
lines changed
compiler/src/dotty/tools/dotc/ast
3 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -1236,11 +1236,15 @@ object desugar {
1236
1236
}
1237
1237
1238
1238
def checkOpaqueAlias (tree : MemberDef )(using Context ): MemberDef =
1239
- if ! tree.mods.is(Opaque ) then tree
1240
- else tree match
1241
- case TypeDef (_, bounds : TypeBoundsTree ) if bounds.alias.isEmpty =>
1239
+ def check (rhs : Tree ): MemberDef = rhs match
1240
+ case bounds : TypeBoundsTree if bounds.alias.isEmpty =>
1242
1241
report.error(i " opaque type must have a right-hand side " , tree.srcPos)
1243
1242
tree.withMods(tree.mods.withoutFlags(Opaque ))
1243
+ case LambdaTypeTree (_, body) => check(body)
1244
+ case _ => tree
1245
+ if ! tree.mods.is(Opaque ) then tree
1246
+ else tree match
1247
+ case TypeDef (_, rhs) => check(rhs)
1244
1248
case _ => tree
1245
1249
1246
1250
/** Check that modifiers are legal for the definition `tree`.
Original file line number Diff line number Diff line change
1
+ -- Error: tests/neg/i6055.scala:1:12 -----------------------------------------------------------------------------------
2
+ 1 |opaque type i0 // error: opaque type must have a right-hand side
3
+ |^^^^^^^^^^^^^^
4
+ |opaque type must have a right-hand side
5
+ -- Error: tests/neg/i6055.scala:2:12 -----------------------------------------------------------------------------------
6
+ 2 |opaque type i2 <: Int // error: opaque type must have a right-hand side
7
+ |^^^^^^^^^^^^^^^^^^^^^
8
+ |opaque type must have a right-hand side
9
+ -- Error: tests/neg/i6055.scala:4:12 -----------------------------------------------------------------------------------
10
+ 4 |opaque type i1[_] // error: opaque type must have a right-hand side
11
+ |^^^^^^^^^^^^^^^^^
12
+ |opaque type must have a right-hand side
13
+ -- Error: tests/neg/i6055.scala:5:12 -----------------------------------------------------------------------------------
14
+ 5 |opaque type x[_] <: Int // error: opaque type must have a right-hand side
15
+ |^^^^^^^^^^^^^^^^^^^^^^^
16
+ |opaque type must have a right-hand side
Original file line number Diff line number Diff line change 1
- opaque type i0 // error: opaque type must be an alias type
2
- opaque type i2 <: Int // error: opaque type must be an alias type
1
+ opaque type i0 // error: opaque type must have a right-hand side
2
+ opaque type i2 <: Int // error: opaque type must have a right-hand side
3
3
4
- opaque type i1 [_] // error: opaque type must be an alias type
5
- opaque type x [_] <: Int // error: opaque type must be an alias type
4
+ opaque type i1 [_] // error: opaque type must have a right-hand side
5
+ opaque type x [_] <: Int // error: opaque type must have a right-hand side
You can’t perform that action at this time.
0 commit comments