Skip to content

Commit df4b3dd

Browse files
authored
Merge pull request #2932 from dotty-staging/harden-ide-4
Harden IDE some more
2 parents 3d9080c + 4af2401 commit df4b3dd

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ object Trees {
115115
*/
116116
def withType(tpe: Type)(implicit ctx: Context): ThisTree[Type] = {
117117
if (tpe.isInstanceOf[ErrorType])
118-
assert(ctx.reporter.errorsReported)
118+
assert(ctx.mode.is(Mode.Interactive) || ctx.reporter.errorsReported)
119119
else if (Config.checkTreesConsistent)
120120
checkChildrenTyped(productIterator)
121121
withTypeUnchecked(tpe)

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,16 @@ object Parsers {
284284
}
285285

286286
def acceptStatSepUnlessAtEnd(altEnd: Token = EOF) =
287-
if (!isStatSeqEnd && in.token != altEnd) acceptStatSep()
287+
if (!isStatSeqEnd)
288+
in.token match {
289+
case EOF =>
290+
case `altEnd` =>
291+
case NEWLINE | NEWLINES => in.nextToken()
292+
case SEMI => in.nextToken()
293+
case _ =>
294+
in.nextToken() // needed to ensure progress; otherwise we might cycle forever
295+
accept(SEMI)
296+
}
288297

289298
def errorTermTree = atPos(in.offset) { Literal(Constant(null)) }
290299

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
284284
case (arg: NamedArg @unchecked) :: _ =>
285285
val nameAssocs = for (arg @ NamedArg(name, _) <- args) yield (name, arg)
286286
handleNamed(pnames, args, nameAssocs.toMap, Set())
287-
case arg :: args1 => arg :: handlePositional(pnames.tail, args1)
287+
case arg :: args1 =>
288+
arg :: handlePositional(if (pnames.isEmpty) Nil else pnames.tail, args1)
288289
case Nil => Nil
289290
}
290291

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ class Namer { typer: Typer =>
756756
else levels(c.outer) + 1
757757
completions.println(s"!!!completing ${denot.symbol.showLocated} in buried typerState, gap = ${levels(ctx)}")
758758
}
759+
assert(ctx.runId == creationContext.runId, "completing $denot in wrong run ${ctx.runId}, was created in ${creationContext.runId}")
759760
completeInCreationContext(denot)
760761
}
761762

tests/neg/i1779.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ object Test {
88
def f = {
99
val _parent = 3
1010
q"val hello = $_parent"
11-
q"class $_" // error // error
12-
}
11+
q"class $_" // error
12+
} // error
1313
}

0 commit comments

Comments
 (0)