From 43cc66eefd3a6915bb149b9a97156a248983d12e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 22 May 2010 16:31:36 +0000 Subject: A workaround for the crasher described in the c... A workaround for the crasher described in the comments of #3431 (not related to #3431 per se.) Thanks to iulian for pinpointing what I can't do during completion member discovery. No review. --- src/compiler/scala/tools/nsc/interpreter/Completion.scala | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/compiler/scala/tools/nsc/interpreter/Completion.scala b/src/compiler/scala/tools/nsc/interpreter/Completion.scala index fddb1ee928..bdbcde31a2 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Completion.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Completion.scala @@ -166,7 +166,19 @@ class Completion(val repl: Interpreter) extends CompletionOutput { override def follow(id: String) = if (completions(0) contains id) { for (clazz <- repl clazzForIdent id) yield { - (typeOf(clazz.getName) map TypeMemberCompletion.apply) getOrElse new InstanceCompletion(clazz) + // XXX The isMemberClass check is a workaround for the crasher described + // in the comments of #3431. The issue as described by iulian is: + // + // Inner classes exist as symbols + // inside their enclosing class, but also inside their package, with a mangled + // name (A$B). The mangled names should never be loaded, and exist only for the + // optimizer, which sometimes cannot get the right symbol, but it doesn't care + // and loads the bytecode anyway. + // + // So this solution is incorrect, but in the short term the simple fix is + // to skip the compiler any time completion is requested on a nested class. + if (clazz.isMemberClass) new InstanceCompletion(clazz) + else (typeOf(clazz.getName) map TypeMemberCompletion.apply) getOrElse new InstanceCompletion(clazz) } } else None -- cgit v1.2.3