diff options
Diffstat (limited to 'src/compiler')
4 files changed, 26 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index dd944aaa4a..d2092a1834 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -1348,12 +1348,15 @@ mixin class Types requires SymbolTable { object adaptToNewRunMap extends TypeMap { private def adaptToNewRun(pre: Type, sym: Symbol): Symbol = { - if (sym.isModuleClass) adaptToNewRun(pre, sym.sourceModule).moduleClass; + if (sym.isModuleClass && !phase.flatClasses) adaptToNewRun(pre, sym.sourceModule).moduleClass; else if ((pre eq NoPrefix) || (pre eq NoType) || sym.owner.isPackageClass) sym else { val rebind0 = pre.member(sym.name); val rebind = rebind0.suchThat(sym => sym.isType || sym.isStable); - if (rebind == NoSymbol) throw new MalformedType(pre, sym.name.toString()); + if (rebind == NoSymbol) { + System.out.println(""+phase+" "+phase.flatClasses+sym.owner+sym.name); + throw new MalformedType(pre, sym.name.toString()); + } rebind } } diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 0a6b09ac3f..82521b7568 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -67,7 +67,7 @@ abstract class UnCurry extends InfoTransform { private var needTryLift = false; private var inPattern = false; private var inConstructorFlag = 0L; - private var localTyper: analyzer.Typer = typer; + private var localTyper: analyzer.Typer = analyzer.newTyper(analyzer.startContext.make(unit)); override def transform(tree: Tree): Tree = try { //debug postTransform(mainTransform(tree)); @@ -218,6 +218,14 @@ abstract class UnCurry extends InfoTransform { t } + def withNewTyper(tree: Tree, owner: Symbol)(f: => Tree): Tree = { + val savedLocalTyper = localTyper; + localTyper = localTyper.atOwner(tree, owner); + val t = f + localTyper = savedLocalTyper; + t + } + tree match { case DefDef(mods, name, tparams, vparamss, tpt, rhs) => withNeedLift(false) { @@ -292,12 +300,11 @@ abstract class UnCurry extends InfoTransform { case fun @ Function(_, _) => mainTransform(transformFunction(fun)) + case PackageDef(_, _) => + withNewTyper(tree, tree.symbol.moduleClass) { super.transform(tree) } + case Template(_, _) => - val savedLocalTyper = localTyper; - localTyper = localTyper.atOwner(tree, currentOwner); - val tree1 = withInConstructorFlag(0) { super.transform(tree) } - localTyper = savedLocalTyper; - tree1 + withNewTyper(tree, currentOwner) { withInConstructorFlag(0) { super.transform(tree) } } case _ => val tree1 = super.transform(tree); diff --git a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala index 19a4484e1f..32d7fcd800 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala @@ -54,7 +54,7 @@ abstract class ConstantFolder { case _ => null } - private def foldBinop(op: Name, x: Constant, y: Constant): Constant = { + private def foldBinop(op: Name, x: Constant, y: Constant): Constant = try { val optag = if (x.tag > y.tag) x.tag else y.tag; optag match { case BooleanTag => @@ -148,5 +148,7 @@ abstract class ConstantFolder { case _ => null } + } catch { + case ex: ArithmeticException => null } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 31291b099e..2a2458ceec 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -610,10 +610,9 @@ mixin class Typers requires Analyzer { val getter = if (mods hasFlag DEFERRED) value else value.getter(value.owner) assert(getter != NoSymbol, getter);//debug val getterDef: DefDef = { - val result = atPos(vdef.pos)( - DefDef(getter, vparamss => + val result = DefDef(getter, vparamss => if (mods hasFlag DEFERRED) EmptyTree - else typed(atPos(vdef.pos)(Select(This(value.owner), value)), EXPRmode, value.tpe))) + else typed(atPos(vdef.pos)(Select(This(value.owner), value)), EXPRmode, value.tpe)) result.tpt.asInstanceOf[TypeTree] setOriginal tpt /* setPos tpt.pos */ checkNoEscaping.privates(getter, result.tpt) result @@ -1054,6 +1053,7 @@ mixin class Typers requires Analyzer { var cx = context while (defSym == NoSymbol && cx != NoContext) { + //if (phase.name == "uncurry") System.out.println("typing " + name + " " + cx.owner + " " + (if (cx.enclClass == null) "null" else cx.enclClass.owner));//DEBUG pre = cx.enclClass.prefix defEntry = cx.scope.lookupEntry(name) if (defEntry != null && defEntry.sym.tpe != NoType) { @@ -1482,7 +1482,8 @@ mixin class Typers requires Analyzer { case ex: Throwable => if (settings.debug.value) System.out.println("exception when typing "+tree+", pt = "+pt) - logError("AT: " + context.unit.source.dbg(tree.pos), ex); + if (context != null && context.unit != null && context.unit.source != null && tree != null) + logError("AT: " + context.unit.source.dbg(tree.pos), ex); throw(ex) } |