@@ -62,6 +62,9 @@ object Interactive {
6262 sourceSymbol(sym.owner)
6363 else sym
6464
65+ private def safely [T ](default : T )(op : => T ) =
66+ try op catch { case ex : TypeError => default }
67+
6568 /** Possible completions at position `pos` */
6669 def completions (trees : List [SourceTree ], pos : SourcePosition )(implicit ctx : Context ): List [Symbol ] = {
6770 val path = pathTo(trees, pos)
@@ -85,16 +88,13 @@ object Interactive {
8588 }
8689
8790 /** Possible completions of members of `prefix` which are accessible when called inside `boundary` */
88- def completions (prefix : Type , boundary : Symbol )(implicit ctx : Context ): List [Symbol ] = {
89- val boundaryCtx = ctx.withOwner(boundary)
90- try
91+ def completions (prefix : Type , boundary : Symbol )(implicit ctx : Context ): List [Symbol ] =
92+ safely( Nil ) {
93+ val boundaryCtx = ctx.withOwner(boundary)
9194 prefix.memberDenots(completionsFilter, (name, buf) =>
9295 buf ++= prefix.member(name).altsWith(d => ! d.isAbsent && d.symbol.isAccessibleFrom(prefix)(boundaryCtx))
9396 ).map(_.symbol).toList
94- catch {
95- case ex : TypeError => Nil
9697 }
97- }
9898
9999 /** Filter for names that should appear when looking for completions. */
100100 private [this ] object completionsFilter extends NameFilter {
@@ -131,7 +131,7 @@ object Interactive {
131131 * @param includeReferences If true, include references and not just definitions
132132 */
133133 def namedTrees (trees : List [SourceTree ], includeReferences : Boolean , treePredicate : NameTree => Boolean )
134- (implicit ctx : Context ): List [SourceTree ] = {
134+ (implicit ctx : Context ): List [SourceTree ] = safely( Nil ) {
135135 val buf = new mutable.ListBuffer [SourceTree ]
136136
137137 trees foreach { case SourceTree (topTree, source) =>
0 commit comments