diff options
author | Martin Odersky <odersky@gmail.com> | 2012-01-01 21:48:44 +0100 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-01-02 13:49:27 -0800 |
commit | 3ad66eb5a3335b29c9d5e56b17155e030aeb7243 (patch) | |
tree | ab7ad83fd59d12505b070448dff703bad9a93a7e /src | |
parent | 008a781f49feb567833e9347ff9d293defeafe6d (diff) | |
download | scala-3ad66eb5a3335b29c9d5e56b17155e030aeb7243.tar.gz scala-3ad66eb5a3335b29c9d5e56b17155e030aeb7243.tar.bz2 scala-3ad66eb5a3335b29c9d5e56b17155e030aeb7243.zip |
Hardening of adaptoNewRun to survive issues in presentation compiler.
Previously, adaptToNewRun crashed when an object declaration got replaced by a value with the same name, because the module class no longer existed. This caused crashes in the presentation compiler when class files disappeared because of a clean build. The new behavior avoids assertion errors.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/reflect/internal/Types.scala | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 690f9b7204..a644baf9f9 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -4284,10 +4284,14 @@ A type's typeSymbol should never be inspected directly. definitions.RootPackage } else if (sym.isModuleClass) { val sourceModule1 = adaptToNewRun(pre, sym.sourceModule) - val result = sourceModule1.moduleClass - val msg = "sym = %s, sourceModule = %s, sourceModule.moduleClass = %s => sourceModule1 = %s, sourceModule1.moduleClass = %s" - assert(result != NoSymbol, msg.format(sym, sym.sourceModule, sym.sourceModule.moduleClass, sourceModule1, sourceModule1.moduleClass)) - result + var result = sourceModule1.moduleClass + if (result == NoSymbol) result = sourceModule1.initialize.moduleClass + if (result != NoSymbol) result + else { + val msg = "Cannot adapt module class; sym = %s, sourceModule = %s, sourceModule.moduleClass = %s => sourceModule1 = %s, sourceModule1.moduleClass = %s" + debuglog(msg.format(sym, sym.sourceModule, sym.sourceModule.moduleClass, sourceModule1, sourceModule1.moduleClass)) + sym + } } else if ((pre eq NoPrefix) || (pre eq NoType) || sym.isPackageClass) { sym } else { |