From b8062e19d3da3c84e3fd73a1194a679aefcdf85a Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Thu, 2 Oct 2025 16:28:54 +0200 Subject: [PATCH] bugfix: Make sure that we can query tree.source Related to https://github.com/scalameta/metals/issues/7802 --- .../src/main/dotty/tools/pc/utils/InteractiveEnrichments.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presentation-compiler/src/main/dotty/tools/pc/utils/InteractiveEnrichments.scala b/presentation-compiler/src/main/dotty/tools/pc/utils/InteractiveEnrichments.scala index 15715143b217..5003f1469f69 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/utils/InteractiveEnrichments.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/utils/InteractiveEnrichments.scala @@ -313,7 +313,7 @@ object InteractiveEnrichments extends CommonMtagsEnrichments: case Select(_, name: TermName) if infixNames(name) => false case Select(This(_), _) => false // is a select statement without a dot `qual.name` - case sel @ Select(qual, _) if !sel.symbol.is(Synthetic) => + case sel @ Select(qual, _) if !sel.symbol.is(Synthetic) && sel.nameSpan.start < tree.source.length => val source = tree.source !(qual.span.end until sel.nameSpan.start) .map(source.apply)