Skip to content

Commit 7d3a462

Browse files
committed
Address review feedback
1 parent 7814a44 commit 7d3a462

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ object ErrorReporting {
1515

1616
import tpd._
1717

18+
def errorTree(tree: untpd.Tree, msg: => Message, pos: Position)(implicit ctx: Context): tpd.Tree =
19+
tree withType errorType(msg, pos)
20+
1821
def errorTree(tree: untpd.Tree, msg: => Message)(implicit ctx: Context): tpd.Tree =
19-
tree withType errorType(msg, tree.pos)
22+
errorTree(tree, msg, tree.pos)
2023

2124
def errorType(msg: => Message, pos: Position)(implicit ctx: Context): ErrorType = {
2225
ctx.error(msg, pos)

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -1863,12 +1863,11 @@ class Typer extends Namer
18631863
try adapt(typedUnadapted(tree, pt, locked), pt, locked)
18641864
catch {
18651865
case ex: TypeError =>
1866-
// This is equivalent to errorTree(tree, ex.toMessage) but
1867-
// uses tree.pos.focus instead of tree.pos. We use this because:
1866+
errorTree(tree, ex.toMessage, tree.pos.focus)
1867+
// We use tree.pos.focus instead of tree.pos, because:
18681868
// - since tree can be a top-level definition, tree.pos can point to the whole definition
18691869
// - that would in turn hide all other type errors inside tree.
18701870
// TODO: might be even better to store positions inside TypeErrors.
1871-
tree withType errorType(ex.toMessage, tree.pos.focus)
18721871
}
18731872
}
18741873

0 commit comments

Comments
 (0)