File tree Expand file tree Collapse file tree 4 files changed +8
-12
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 4 files changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -201,11 +201,11 @@ object Parsers {
201
201
canStartExpressionTokens.contains(in.token) &&
202
202
! in.isSoftModifierInModifierPosition
203
203
204
- def isDefIntro (allowedMods : BitSet ): Boolean =
204
+ def isDefIntro (allowedMods : BitSet , excludedSoftModifiers : Set [ TermName ] = Set .empty ): Boolean =
205
205
in.token == AT ||
206
206
(defIntroTokens `contains` in.token) ||
207
207
(allowedMods `contains` in.token) ||
208
- in.isSoftModifierInModifierPosition
208
+ in.isSoftModifierInModifierPosition && ! excludedSoftModifiers.contains(in.name)
209
209
210
210
def isStatSep : Boolean =
211
211
in.token == NEWLINE || in.token == NEWLINES || in.token == SEMI
@@ -3081,7 +3081,7 @@ object Parsers {
3081
3081
stats += implicitClosure(in.offset, Location .InBlock , modifiers(closureMods))
3082
3082
else if (isExprIntro)
3083
3083
stats += expr(Location .InBlock )
3084
- else if (isDefIntro(localModifierTokens))
3084
+ else if (isDefIntro(localModifierTokens, excludedSoftModifiers = Set (nme.`opaque`) ))
3085
3085
if (closureMods.contains(in.token)) {
3086
3086
val start = in.offset
3087
3087
var imods = modifiers(closureMods)
Original file line number Diff line number Diff line change @@ -324,12 +324,12 @@ Binding ::= (id | ‘_’) [‘:’ Type]
324
324
Modifier ::= LocalModifier
325
325
| AccessModifier
326
326
| ‘override’
327
+ | ‘opaque’
327
328
LocalModifier ::= ‘abstract’
328
329
| ‘final’
329
330
| ‘sealed’
330
331
| ‘implicit’
331
332
| ‘lazy’
332
- | ‘opaque’
333
333
| ‘inline’
334
334
| ‘erased’
335
335
AccessModifier ::= (‘private’ | ‘protected’) [AccessQualifier]
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ object opaquetypes {
18
18
val s : O = " " // should be OK
19
19
}
20
20
21
+ def foo () = {
22
+ opaque type X = Int // error
23
+ }
24
+
21
25
}
22
26
23
27
object logs {
Original file line number Diff line number Diff line change 1
- object O {
2
- def m () = {
3
- opaque type T = Int
4
- object T
5
- }
6
- }
7
1
object A {
8
- {
9
2
opaque type T = Int
10
3
object T
11
4
println
12
- }
13
5
}
You can’t perform that action at this time.
0 commit comments