Skip to content

Commit b6bf727

Browse files
committed
Add NamedDefTree.namePos
1 parent 92f18b9 commit b6bf727

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,12 @@ object Trees {
353353
}
354354
}
355355
else span
356+
357+
/** The source position of the name defined by this definition.
358+
* This is a point position if the definition is synthetic, or a range position
359+
* if the definition comes from source.
360+
*/
361+
def namePos: SourcePosition = source.atSpan(nameSpan)
356362
}
357363

358364
/** Tree defines a new symbol and carries modifiers.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ trait QuotesAndSplices {
231231
cpy.AppliedTypeTree(tree)(transform(tpt), args1)
232232
case tree: NamedDefTree =>
233233
if tree.isTerm && !tree.nameSpan.isSynthetic && tree.symbol.name.startsWith("$") then
234-
ctx.error("Names cannot start with $ quote pattern", ctx.source.atSpan(tree.nameSpan))
234+
ctx.error("Names cannot start with $ quote pattern", tree.namePos)
235235
super.transform(tree)
236236
case _ =>
237237
super.transform(tree)

0 commit comments

Comments
 (0)