Skip to content

Commit de31113

Browse files
committed
other changes by integrating WithEndMarker
1 parent d0bd62c commit de31113

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ object Trees {
319319
extension (mdef: untpd.DefTree) def mods: untpd.Modifiers = mdef.rawMods
320320

321321
sealed trait WithEndMarker[+T <: Untyped]:
322-
self: PackageDef[T] | NamedDefTree[T] =>
322+
self: PackageDef[T] | NamedDefTree[T] | Apply[T] =>
323323

324324
import WithEndMarker.*
325325

@@ -521,6 +521,16 @@ object Trees {
521521
extends GenericApply[T] with WithEndMarker[T] {
522522
type ThisTree[+T <: Untyped] = Apply[T]
523523

524+
protected def srcName(using Context): Name =
525+
// Prefer stored method name when present (handles nested Apply cases)
526+
this.attachmentOrElse(untpd.MethodName, null) match
527+
case name: Name => name
528+
case _ =>
529+
fun match
530+
case Select(_, name) => name
531+
case Ident(name) => name
532+
case _ => nme.EMPTY
533+
524534
def setApplyKind(kind: ApplyKind) =
525535
putAttachment(untpd.KindOfApply, kind)
526536
this

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ object Parsers {
15441544
def updateSpanOfLast(last: T): Unit =
15451545
last match
15461546
case last: WithEndMarker[t] => last.withEndMarker()
1547-
case apply: Apply if sourceVersion.enablesMethodBlockEndMarkers => apply.setEndMarker()
1547+
case apply: Apply if sourceVersion.enablesMethodBlockEndMarkers => apply.withEndMarker()
15481548
case _ =>
15491549
last.span = last.span.withEnd(in.lastCharOffset)
15501550

0 commit comments

Comments
 (0)