@@ -3,6 +3,7 @@ package dotty.tools.dotc.interactive
33import dotty .tools .dotc .ast .Trees ._
44import dotty .tools .dotc .config .Printers .interactiv
55import dotty .tools .dotc .core .Contexts .{Context , NoContext }
6+ import dotty .tools .dotc .core .CheckRealizable
67import dotty .tools .dotc .core .Decorators .StringInterpolators
78import dotty .tools .dotc .core .Denotations .SingleDenotation
89import dotty .tools .dotc .core .Flags ._
@@ -13,7 +14,7 @@ import dotty.tools.dotc.core.Symbols.{defn, NoSymbol, Symbol}
1314import dotty .tools .dotc .core .Scopes
1415import dotty .tools .dotc .core .StdNames .{nme , tpnme }
1516import dotty .tools .dotc .core .TypeError
16- import dotty .tools .dotc .core .Types .{NamedType , NameFilter , Type , takeAllFilter }
17+ import dotty .tools .dotc .core .Types .{NamedType , Type , takeAllFilter }
1718import dotty .tools .dotc .printing .Texts ._
1819import dotty .tools .dotc .util .{NoSourcePosition , SourcePosition }
1920
@@ -219,9 +220,20 @@ object Completion {
219220 ! sym.is(allOf(Mutable , Accessor )) &&
220221 (
221222 (mode.is(Mode .Term ) && sym.isTerm)
223+ || (mode.is(Mode .StableTerm ) && sym.isTerm && validPathSegment(sym))
222224 || (mode.is(Mode .Type ) && sym.isType)
223225 )
224226
227+ /** Can this symbol be part of a path? See SLS 3.1 for a definition of a valid path. */
228+ private def validPathSegment (sym : Symbol )(implicit ctx : Context ): Boolean = {
229+ def isRealizable = {
230+ val realizability = CheckRealizable .realizability(sym.info)
231+ realizability == CheckRealizable .Realizable
232+ }
233+
234+ ! sym.is(Method ) && isRealizable
235+ }
236+
225237 /**
226238 * Find all the members of `site` that are accessible and which should be included in `info`.
227239 *
@@ -298,11 +310,13 @@ object Completion {
298310 /** Term symbols are allowed */
299311 val Term : Mode = new Mode (1 )
300312
313+ val StableTerm : Mode = new Mode (2 )
314+
301315 /** Type symbols are allowed */
302- val Type : Mode = new Mode (2 )
316+ val Type : Mode = new Mode (4 ) | StableTerm
303317
304318 /** Both term and type symbols are allowed */
305- val Import : Mode = new Mode (4 ) | Term | Type
319+ val Import : Mode = new Mode (8 ) | Term | Type
306320 }
307321
308322}
0 commit comments