diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index a3f4191b7af1..24c7f5910f59 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -80,7 +80,7 @@ class Definitions { denot.info = ClassInfo(ScalaPackageClass.thisType, cls, parents, paramDecls) } } - newClassSymbol(ScalaPackageClass, name, EmptyFlags, completer).entered + newClassSymbol(ScalaPackageClass, name, Artifact, completer).entered } /** The trait FunctionN, ImplicitFunctionN, ErasedFunctionN or ErasedImplicitFunction, for some N diff --git a/compiler/src/dotty/tools/dotc/interactive/Completion.scala b/compiler/src/dotty/tools/dotc/interactive/Completion.scala index d740d4098e3e..5060aae3d2fb 100644 --- a/compiler/src/dotty/tools/dotc/interactive/Completion.scala +++ b/compiler/src/dotty/tools/dotc/interactive/Completion.scala @@ -140,7 +140,7 @@ object Completion { private[this] val completions = new RenameAwareScope /** - * Return the list of symbols that shoudl be included in completion results. + * Return the list of symbols that should be included in completion results. * * If several symbols share the same name, the type symbols appear before term symbols inside * the same `Completion`. @@ -240,7 +240,9 @@ object Completion { * 4. have an existing source symbol, * 5. are the module class in case of packages, * 6. are mutable accessors, to exclude setters for `var`, - * 7. have same term/type kind as name prefix given so far + * 7. symbol is not a package object + * 8. symbol is not an artifact of the compiler + * 9. have same term/type kind as name prefix given so far */ private def include(sym: Symbol, nameInScope: Name)(implicit ctx: Context): Boolean = nameInScope.startsWith(prefix) && @@ -249,6 +251,8 @@ object Completion { sym.sourceSymbol.exists && (!sym.is(Package) || !sym.moduleClass.exists) && !sym.is(allOf(Mutable, Accessor)) && + !sym.isPackageObject && + !sym.is(Artifact) && ( (mode.is(Mode.Term) && sym.isTerm) || (mode.is(Mode.Type) && (sym.isType || sym.isStable)) diff --git a/compiler/test/dotty/tools/repl/TabcompleteTests.scala b/compiler/test/dotty/tools/repl/TabcompleteTests.scala index 20b3552cdaef..7dc82fbb9988 100644 --- a/compiler/test/dotty/tools/repl/TabcompleteTests.scala +++ b/compiler/test/dotty/tools/repl/TabcompleteTests.scala @@ -90,4 +90,11 @@ class TabcompleteTests extends ReplTest { val expected = List("Renamed") assertEquals(expected, tabComplete("val foo: Rena")) } + + @Test def importScala = fromInitialState { implicit s => + val comp = tabComplete("import scala.") + // check that there are no special symbols leaked: , , ... + assertEquals(comp.find(_.startsWith("<")), None) + assert(!comp.contains("package")) + } }