From 5d8c6c898aa4031c69f9ef0f0dbe8a82e51f793e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 19 Jan 2011 03:53:15 +0000 Subject: There was a bunch of work adriaan and I did whi... There was a bunch of work adriaan and I did which ended up in some git backwaters. I think he is still working with the main code pieces but I didn't want to lose a couple comments/clarifications. No review. --- .../scala/tools/nsc/transform/InfoTransform.scala | 15 +++++++++------ src/compiler/scala/tools/nsc/transform/UnCurry.scala | 2 +- .../scala/tools/nsc/typechecker/TreeCheckers.scala | 8 ++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/compiler/scala/tools/nsc/transform/InfoTransform.scala b/src/compiler/scala/tools/nsc/transform/InfoTransform.scala index fa93a9b534..03076dc6aa 100644 --- a/src/compiler/scala/tools/nsc/transform/InfoTransform.scala +++ b/src/compiler/scala/tools/nsc/transform/InfoTransform.scala @@ -6,12 +6,15 @@ package scala.tools.nsc package transform -/**

- * A base class for transforms. - *

- *

- * A transform contains a compiler phase which applies a tree transformer. - *

+/** + * An InfoTransform contains a compiler phase that transforms trees and symbol infos -- making sure they stay consistent. + * The symbol info is transformed assuming it is consistent right before this phase. + * The info transformation is triggered by Symbol::rawInfo, which caches the results in the symbol's type history. + * This way sym.info (during an atPhase(p)) can look up what the symbol's info should look like at the beginning of phase p. + * (If the transformed info had not been stored yet, rawInfo will compute the info by composing the info-transformers + * of the most recent phase before p, up to the transformer of the phase right before p.) + * + * Concretely, atPhase(p) { sym.info } yields the info *before* phase p has transformed it. Imagine you're a phase and it all makes sense. */ trait InfoTransform extends Transform { import global.{Symbol, Type, InfoTransformer, infoTransformers} diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 2f56180c8d..1a6a36691d 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -10,7 +10,7 @@ import symtab.Flags._ import scala.collection.{ mutable, immutable } /* */ -/** - uncurry all symbol and tree types (@see UnCurryPhase) +/** - uncurry all symbol and tree types (@see UnCurryPhase) -- this includes normalizing all proper types. * - for every curried parameter list: (ps_1) ... (ps_n) ==> (ps_1, ..., ps_n) * - for every curried application: f(args_1)...(args_n) ==> f(args_1, ..., args_n) * - for every type application: f[Ts] ==> f[Ts]() unless followed by parameters diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index 2042b08d83..4199008754 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -261,12 +261,12 @@ abstract class TreeCheckers extends Analyzer { if (sym.ownerChain contains currentOwner) () else fail(sym + " owner chain does not contain currentOwner " + currentOwner) case _ => - def cond(s: Symbol) = s.isTerm && !s.isMethod && s != sym.owner + def cond(s: Symbol) = !s.isTerm || s.isMethod || s == sym.owner if (sym.owner != currentOwner) { - val found = currentOwner.ownerChain find (x => !cond(x)) getOrElse fail("DefTree can't find owner: ") - if (sym.owner != found) - fail("Expected owner %s, found %s: ".format(found, sym.owner)) + val expected = currentOwner.ownerChain find (x => cond(x)) getOrElse fail("DefTree can't find owner: ") + if (sym.owner != expected) + fail("Expected owner %s (out of %s), found %s: ".format(expected, currentOwner.ownerChain, sym.owner)) } } } -- cgit v1.2.3