Skip to content

Commit 37206cc

Browse files
fix: Only fallback to the definition of a synthetic valdef if it is zero extent (#22551)
closes scalameta/metals#7038 closes scalameta/metals#7191 fixes the reproduction issue from #22217 Co-authored-by: Katarzyna Marek <[email protected]>
1 parent 4ae474d commit 37206cc

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Diff for: presentation-compiler/src/main/dotty/tools/pc/completions/CompletionProvider.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ class CompletionProvider(
9999
* 4| $1$.sliding@@[Int](size, step)
100100
*
101101
*/
102-
if qual.symbol.is(Flags.Synthetic) && qual.symbol.name.isInstanceOf[DerivedName] =>
102+
if qual.symbol.is(Flags.Synthetic) && qual.span.isZeroExtent && qual.symbol.name.isInstanceOf[DerivedName] =>
103103
qual.symbol.defTree match
104-
case valdef: ValDef => Select(valdef.rhs, name) :: tail
104+
case valdef: ValDef if !valdef.rhs.isEmpty => Select(valdef.rhs, name) :: tail
105105
case _ => tpdPath0
106106
case _ => tpdPath0
107107

Diff for: presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala

+11
Original file line numberDiff line numberDiff line change
@@ -2168,3 +2168,14 @@ class CompletionSuite extends BaseCompletionSuite:
21682168
"""|build: Unit
21692169
|""".stripMargin,
21702170
)
2171+
2172+
@Test def i7191 =
2173+
check(
2174+
"""|val x = Some(3).map(_.@@)
2175+
|""".stripMargin,
2176+
"""|!=(x: Byte): Boolean
2177+
|!=(x: Char): Boolean
2178+
|!=(x: Double): Boolean
2179+
|""".stripMargin,
2180+
topLines = Some(3)
2181+
)

0 commit comments

Comments
 (0)