File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 3 files changed +8
-4
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
@@ -3014,7 +3014,7 @@ object Parsers {
3014
3014
stats += implicitClosure(in.offset, Location .InBlock , modifiers(closureMods))
3015
3015
else if (isExprIntro)
3016
3016
stats += expr(Location .InBlock )
3017
- else if (isDefIntro(localModifierTokens))
3017
+ else if (isDefIntro(localModifierTokens, excludedSoftModifiers = Set (nme.`opaque`) ))
3018
3018
if (closureMods.contains(in.token)) {
3019
3019
val start = in.offset
3020
3020
var imods = modifiers(closureMods)
Original file line number Diff line number Diff line change @@ -320,12 +320,12 @@ Binding ::= (id | ‘_’) [‘:’ Type]
320
320
Modifier ::= LocalModifier
321
321
| AccessModifier
322
322
| ‘override’
323
+ | ‘opaque’
323
324
LocalModifier ::= ‘abstract’
324
325
| ‘final’
325
326
| ‘sealed’
326
327
| ‘implicit’
327
328
| ‘lazy’
328
- | ‘opaque’
329
329
| ‘inline’
330
330
| ‘erased’
331
331
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 {
You can’t perform that action at this time.
0 commit comments