Skip to content

Commit 863e903

Browse files
committed
Exclude symbols w/o sourceSymbol in completions
For instance, Scala classes have a synthetic accompanying `Module` which doesn't have a corresponding source symbol. We don't want to show the `Module` in the completions.
1 parent bd3a18f commit 863e903

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,10 @@ object Completion {
227227
* 1. start with given name prefix, and
228228
* 2. do not contain '$' except in prefix where it is explicitly written by user, and
229229
* 3. are not a primary constructor,
230-
* 4. are the module class in case of packages,
231-
* 5. are mutable accessors, to exclude setters for `var`,
232-
* 6. have same term/type kind as name prefix given so far
230+
* 4. have an existing source symbol,
231+
* 5. are the module class in case of packages,
232+
* 6. are mutable accessors, to exclude setters for `var`,
233+
* 7. have same term/type kind as name prefix given so far
233234
*
234235
* The reason for (2) is that we do not want to present compiler-synthesized identifiers
235236
* as completion results. However, if a user explicitly writes all '$' characters in an
@@ -239,6 +240,7 @@ object Completion {
239240
nameInScope.startsWith(prefix) &&
240241
!nameInScope.toString.drop(prefix.length).contains('$') &&
241242
!sym.isPrimaryConstructor &&
243+
sym.sourceSymbol.exists &&
242244
(!sym.is(Package) || !sym.moduleClass.exists) &&
243245
!sym.is(allOf(Mutable, Accessor)) &&
244246
(

0 commit comments

Comments
 (0)