Skip to content

Commit 4019c30

Browse files
authored
Merge pull request #243 from scala/backport-lts-3.3-22551
Backport "fix: Only fallback to the definition of a synthetic valdef if it is zero extent" to 3.3 LTS
2 parents 6d12c19 + 2333135 commit 4019c30

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
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

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,3 +2134,14 @@ class CompletionSuite extends BaseCompletionSuite:
21342134
"""|build: Unit
21352135
|""".stripMargin,
21362136
)
2137+
2138+
@Test def i7191 =
2139+
check(
2140+
"""|val x = Some(3).map(_.@@)
2141+
|""".stripMargin,
2142+
"""|!=(x: Byte): Boolean
2143+
|!=(x: Char): Boolean
2144+
|!=(x: Double): Boolean
2145+
|""".stripMargin,
2146+
topLines = Some(3)
2147+
)

0 commit comments

Comments
 (0)