Skip to content

Commit 520805a

Browse files
fix: Only fallback to the definition of a synthetic valdef if it is zero extent
Co-Authored-By: Katarzyna Marek <[email protected]>
1 parent a56c622 commit 520805a

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

compiler/src/dotty/tools/dotc/interactive/Completion.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ object Completion:
218218
// Ignore synthetic select from `This` because in code it was `Ident`
219219
// See example in dotty.tools.languageserver.CompletionTest.syntheticThis
220220
case tpd.Select(qual @ tpd.This(_), _) :: _ if qual.span.isSynthetic => completer.scopeCompletions
221-
case tpd.Select(qual, _) :: _ if qual.typeOpt.hasSimpleKind => completer.selectionCompletions(qual)
222-
case tpd.Select(qual, _) :: _ => Map.empty
221+
case tpd.Select(qual, _) :: _ if qual.typeOpt.hasSimpleKind => completer.selectionCompletions(qual)
222+
case tpd.Select(qual, _) :: _ => Map.empty
223223
case (tree: tpd.ImportOrExport) :: _ => completer.directMemberCompletions(tree.expr)
224224
case _ => completer.scopeCompletions
225225

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

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)