Skip to content

Commit 7c379ce

Browse files
committed
Surivive TypeErrors when computing completions
The underlying machinery has various ways to throw a TypeError. I observed a MergeError when accidentally writing the same method twice. CyclicReferences are also possible. These should not lead to crashes to the presentation compiler.
1 parent c566e60 commit 7c379ce

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ object Interactive {
8787
/** Possible completions of members of `prefix` which are accessible when called inside `boundary` */
8888
def completions(prefix: Type, boundary: Symbol)(implicit ctx: Context): List[Symbol] = {
8989
val boundaryCtx = ctx.withOwner(boundary)
90-
prefix.memberDenots(completionsFilter, (name, buf) =>
91-
buf ++= prefix.member(name).altsWith(_.symbol.isAccessibleFrom(prefix)(boundaryCtx))
92-
).map(_.symbol).toList
90+
try
91+
prefix.memberDenots(completionsFilter, (name, buf) =>
92+
buf ++= prefix.member(name).altsWith(_.symbol.isAccessibleFrom(prefix)(boundaryCtx))
93+
).map(_.symbol).toList
94+
catch {
95+
case ex: TypeError => Nil
96+
}
9397
}
9498

9599
/** Filter for names that should appear when looking for completions. */

0 commit comments

Comments
 (0)