Skip to content

Commit 483e455

Browse files
noti0na1tgodzik
authored andcommitted
Only allow opaque type def at outermost
[Cherry-picked 16ebbea]
1 parent a178222 commit 483e455

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4377,7 +4377,7 @@ object Parsers {
43774377
* | Expr1
43784378
* |
43794379
*/
4380-
def blockStatSeq(): List[Tree] = checkNoEscapingPlaceholders {
4380+
def blockStatSeq(outermost: Boolean = false): List[Tree] = checkNoEscapingPlaceholders {
43814381
val stats = new ListBuffer[Tree]
43824382
while
43834383
var empty = false
@@ -4389,7 +4389,7 @@ object Parsers {
43894389
stats += closure(in.offset, Location.InBlock, modifiers(BitSet(IMPLICIT)))
43904390
else if isIdent(nme.extension) && followingIsExtension() then
43914391
stats += extension()
4392-
else if ctx.mode.is(Mode.Interactive) && isDefIntro(localModifierTokens) then
4392+
else if outermost && ctx.mode.is(Mode.Interactive) && isDefIntro(localModifierTokens) then
43934393
stats +++= localDef(in.offset)
43944394
else if isDefIntro(localModifierTokens, excludedSoftModifiers = Set(nme.`opaque`)) then
43954395
stats +++= localDef(in.offset)

compiler/src/dotty/tools/repl/ParseResult.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ object ParseResult {
122122

123123
private def parseStats(using Context): List[untpd.Tree] = {
124124
val parser = new Parser(ctx.source)
125-
val stats = parser.blockStatSeq()
125+
val stats = parser.blockStatSeq(outermost = true)
126126
parser.accept(Tokens.EOF)
127127
stats
128128
}

0 commit comments

Comments
 (0)