Skip to content

Commit 4aa00a7

Browse files
Merge pull request #5716 from dotty-staging/fix-#5237
Fix #5237: Do not list <xyz> in scala package completions
2 parents c975760 + 438c74d commit 4aa00a7

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Definitions {
8080
denot.info = ClassInfo(ScalaPackageClass.thisType, cls, parents, paramDecls)
8181
}
8282
}
83-
newClassSymbol(ScalaPackageClass, name, EmptyFlags, completer).entered
83+
newClassSymbol(ScalaPackageClass, name, Artifact, completer).entered
8484
}
8585

8686
/** The trait FunctionN, ImplicitFunctionN, ErasedFunctionN or ErasedImplicitFunction, for some N

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ object Completion {
140140
private[this] val completions = new RenameAwareScope
141141

142142
/**
143-
* Return the list of symbols that shoudl be included in completion results.
143+
* Return the list of symbols that should be included in completion results.
144144
*
145145
* If several symbols share the same name, the type symbols appear before term symbols inside
146146
* the same `Completion`.
@@ -240,7 +240,9 @@ object Completion {
240240
* 4. have an existing source symbol,
241241
* 5. are the module class in case of packages,
242242
* 6. are mutable accessors, to exclude setters for `var`,
243-
* 7. have same term/type kind as name prefix given so far
243+
* 7. symbol is not a package object
244+
* 8. symbol is not an artifact of the compiler
245+
* 9. have same term/type kind as name prefix given so far
244246
*/
245247
private def include(sym: Symbol, nameInScope: Name)(implicit ctx: Context): Boolean =
246248
nameInScope.startsWith(prefix) &&
@@ -249,6 +251,8 @@ object Completion {
249251
sym.sourceSymbol.exists &&
250252
(!sym.is(Package) || !sym.moduleClass.exists) &&
251253
!sym.is(allOf(Mutable, Accessor)) &&
254+
!sym.isPackageObject &&
255+
!sym.is(Artifact) &&
252256
(
253257
(mode.is(Mode.Term) && sym.isTerm)
254258
|| (mode.is(Mode.Type) && (sym.isType || sym.isStable))

compiler/test/dotty/tools/repl/TabcompleteTests.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,11 @@ class TabcompleteTests extends ReplTest {
9090
val expected = List("Renamed")
9191
assertEquals(expected, tabComplete("val foo: Rena"))
9292
}
93+
94+
@Test def importScala = fromInitialState { implicit s =>
95+
val comp = tabComplete("import scala.")
96+
// check that there are no special symbols leaked: <byname>, <special-ops>, ...
97+
assertEquals(comp.find(_.startsWith("<")), None)
98+
assert(!comp.contains("package"))
99+
}
93100
}

0 commit comments

Comments
 (0)