summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2006-09-19 16:31:26 +0000
committermichelou <michelou@epfl.ch>2006-09-19 16:31:26 +0000
commit6cbc253b9b0f978957b8eddd7dd64538dfd3a1b3 (patch)
tree485233a33896436274d46848128637678778a505
parentbc80f0fd7962203e7a54fd4fa97a8db9de8b5918 (diff)
downloadscala-6cbc253b9b0f978957b8eddd7dd64538dfd3a1b3.tar.gz
scala-6cbc253b9b0f978957b8eddd7dd64538dfd3a1b3.tar.bz2
scala-6cbc253b9b0f978957b8eddd7dd64538dfd3a1b3.zip
removed leading/trailing tabs/blanks in typeche...
removed leading/trailing tabs/blanks in typechecker/*.scala
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala133
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala196
-rw-r--r--src/library/scala/Iterable.scala41
5 files changed, 243 insertions, 145 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index 4a4e5dffbe..04d1821d27 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -736,7 +736,7 @@ trait Trees requires Global {
}
class LazyTreeCopier(copy: TreeCopier) extends TreeCopier {
- def this() = this(new StrictTreeCopier);
+ def this() = this(new StrictTreeCopier)
def ClassDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[AbsTypeDef], tpt: Tree, impl: Template) = tree match {
case t @ ClassDef(mods0, name0, tparams0, tpt0, impl0)
if (mods0 == mods && (name0 == name) && (tparams0 == tparams) && (tpt0 == tpt) && (impl0 == impl)) => t
@@ -939,8 +939,8 @@ trait Trees requires Global {
}
abstract class Transformer {
- val copy: TreeCopier = new LazyTreeCopier;
- protected var currentOwner: Symbol = definitions.RootClass;
+ val copy: TreeCopier = new LazyTreeCopier
+ protected var currentOwner: Symbol = definitions.RootClass
protected def currentMethod = currentOwner.enclMethod
protected def currentClass = currentOwner.enclClass
protected def currentPackage = currentOwner.toplevelClass.owner
@@ -1064,7 +1064,7 @@ trait Trees requires Global {
def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] =
List.mapConserve(stats)(stat =>
if (exprOwner != currentOwner && stat.isTerm) atOwner(exprOwner)(transform(stat))
- else transform(stat)) filter (EmptyTree !=);
+ else transform(stat)) filter (EmptyTree !=)
def transformUnit(unit: CompilationUnit): unit = { unit.body = transform(unit.body) }
def atOwner[A](owner: Symbol)(trans: => A): A = {
@@ -1077,7 +1077,7 @@ trait Trees requires Global {
}
class Traverser {
- protected var currentOwner: Symbol = definitions.RootClass;
+ protected var currentOwner: Symbol = definitions.RootClass
def traverse(tree: Tree): unit = tree match {
case EmptyTree =>
;
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 08a92bb703..cfedec9775 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -11,7 +11,7 @@ import scala.tools.nsc.util.Position
/** This trait ...
*
- * @author Martin Odersky
+ * @author Martin Odersky
* @version 1.0
*/
trait Contexts requires Analyzer {
@@ -62,8 +62,8 @@ trait Contexts requires Analyzer {
var sc = startContext
while (sc != NoContext) {
sc.tree match {
- case Import(qual, _) => qual.tpe = singleType(qual.symbol.owner.thisType, qual.symbol)
- case _ =>
+ case Import(qual, _) => qual.tpe = singleType(qual.symbol.owner.thisType, qual.symbol)
+ case _ =>
}
sc = sc.outer
}
@@ -78,7 +78,7 @@ trait Contexts requires Analyzer {
var enclClass: Context = _ // The next outer context whose tree is a
// template or package definition
var enclMethod: Context = _ // The next outer context whose tree is a method
- var variance: int = _ // Variance relative to enclosing class.
+ var variance: int = _ // Variance relative to enclosing class
private var _undetparams: List[Symbol] = List() // Undetermined type parameters,
// not inherited to child contexts
var depth: int = 0
@@ -101,6 +101,14 @@ trait Contexts requires Analyzer {
_undetparams = ps
}
+ /**
+ * @param unit ...
+ * @param tree ...
+ * @param owner ...
+ * @param scope ...
+ * @param imports ...
+ * @return ...
+ */
def make(unit: CompilationUnit, tree: Tree, owner: Symbol,
scope: Scope, imports: List[ImportInfo]): Context = {
val c = new Context
@@ -110,11 +118,11 @@ trait Contexts requires Analyzer {
c.scope = scope
tree match {
case Template(_, _) | PackageDef(_, _) =>
- c.enclClass = c
+ c.enclClass = c
c.prefix = c.owner.thisType
c.inConstructorSuffix = false
- case _ =>
- c.enclClass = this.enclClass
+ case _ =>
+ c.enclClass = this.enclClass
c.prefix =
if (c.owner != this.owner && c.owner.isTerm) NoPrefix
else this.prefix
@@ -190,12 +198,12 @@ trait Contexts requires Analyzer {
c
}
- def error(pos: Int, er: Error): Unit = {
- val msg = er.getMessage()
+ def error(pos: Int, err: Error): Unit = {
+ val msg = err.getMessage()
if (reportGeneralErrors)
unit.error(pos, if (checking) "**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg)
else
- throw er
+ throw err
}
def error(pos: PositionType, msg: String): unit =
@@ -204,11 +212,19 @@ trait Contexts requires Analyzer {
else
throw new TypeError(pos, msg)
- def ambiguousError(pos: PositionType, pre: Type, sym1: Symbol, sym2: Symbol, rest: String): unit = {
+ /**
+ * @param pos ...
+ * @param pre ...
+ * @param sym1 ...
+ * @param sym2 ...
+ * @param rest ...
+ */
+ def ambiguousError(pos: PositionType, pre: Type, sym1: Symbol,
+ sym2: Symbol, rest: String): unit = {
val msg =
- ("ambiguous reference to overloaded definition,\n" +
- "both " + sym1 + sym1.locationString + " of type " + pre.memberType(sym1) +
- "\nand " + sym2 + sym2.locationString + " of type " + pre.memberType(sym2) +
+ ("ambiguous reference to overloaded definition,\n" +
+ "both " + sym1 + sym1.locationString + " of type " + pre.memberType(sym1) +
+ "\nand " + sym2 + sym2.locationString + " of type " + pre.memberType(sym2) +
"\nmatch " + rest)
if (reportAmbiguousErrors) {
if (!pre.isErroneous && !sym1.isErroneous && !sym2.isErroneous)
@@ -239,31 +255,33 @@ trait Contexts requires Analyzer {
" " + scope.toList + "\n:: " + outer.toString()
}
- /** Is `sym' accessible as a member of tree `site' with type `pre' in
- * current context?
+ /** Is <code>sym</code> accessible as a member of tree `site' with type
+ * <code>pre</code> in current context?
*
- * @param sym ...
- * @param pre ...
+ * @param sym ...
+ * @param pre ...
* @param superAccess ...
+ * @return ...
*/
def isAccessible(sym: Symbol, pre: Type, superAccess: boolean): boolean = {
/** Are we inside definition of `owner'? */
def accessWithin(owner: Symbol): boolean = {
- var c = this
- while (c != NoContext && c.owner != owner) {
- if (c.outer == null) assert(false, "accessWithin(" + owner + ") " + c);//debug
- if (c.outer.enclClass == null) assert(false, "accessWithin(" + owner + ") " + c);//debug
- c = c.outer.enclClass
- }
- c != NoContext
+ var c = this
+ while (c != NoContext && c.owner != owner) {
+ if (c.outer == null) assert(false, "accessWithin(" + owner + ") " + c);//debug
+ if (c.outer.enclClass == null) assert(false, "accessWithin(" + owner + ") " + c);//debug
+ c = c.outer.enclClass
+ }
+ c != NoContext
}
/** Is `clazz' a subclass of an enclosing class? */
def isSubClassOfEnclosing(clazz: Symbol): boolean = {
- var c = this.enclClass
- while (c != NoContext && !clazz.isNonBottomSubClass(c.owner)) c = c.outer.enclClass
- c != NoContext
+ var c = this.enclClass
+ while (c != NoContext && !clazz.isNonBottomSubClass(c.owner))
+ c = c.outer.enclClass
+ c != NoContext
}
(pre == NoPrefix) || {
@@ -275,7 +293,7 @@ trait Contexts requires Analyzer {
||
(sym hasFlag PROTECTED) &&
(superAccess ||
- (pre.widen.symbol.isNonBottomSubClass(sym.owner) &&
+ (pre.widen.symbol.isNonBottomSubClass(sym.owner) &&
isSubClassOfEnclosing(pre.widen.symbol))))
}
}
@@ -302,38 +320,42 @@ trait Contexts requires Analyzer {
private def collectImplicitImports(imp: ImportInfo): List[ImplicitInfo] = {
val pre = imp.qual.tpe
def collect(sels: List[Pair[Name, Name]]): List[ImplicitInfo] = sels match {
- case List() => List()
- case List(Pair(nme.WILDCARD, _)) => collectImplicits(pre.implicitMembers, pre)
- case Pair(from, to) :: sels1 =>
- var impls = collect(sels1) filter (info => info.name != from)
- if (to != nme.WILDCARD) {
- val sym = imp.importedSymbol(to)
- if (sym.hasFlag(IMPLICIT)) impls = new ImplicitInfo(to, pre, sym) :: impls
- }
- impls
+ case List() => List()
+ case List(Pair(nme.WILDCARD, _)) => collectImplicits(pre.implicitMembers, pre)
+ case Pair(from, to) :: sels1 =>
+ var impls = collect(sels1) filter (info => info.name != from)
+ if (to != nme.WILDCARD) {
+ val sym = imp.importedSymbol(to)
+ if (sym.hasFlag(IMPLICIT)) impls = new ImplicitInfo(to, pre, sym) :: impls
+ }
+ impls
}
- if (settings.debug.value) log("collect implicit imports " + imp + "=" + collect(imp.tree.selectors));//debug
+ if (settings.debug.value)
+ log("collect implicit imports " + imp + "=" + collect(imp.tree.selectors))//debug
collect(imp.tree.selectors)
}
def implicitss: List[List[ImplicitInfo]] = {
if (implicitsRunId != currentRunId) {
- implicitsRunId = currentRunId
+ implicitsRunId = currentRunId
implicitsCache = List()
- val newImplicits: List[ImplicitInfo] =
- if (owner != outer.owner && owner.isClass && !owner.isPackageClass) {
+ val newImplicits: List[ImplicitInfo] =
+ if (owner != outer.owner && owner.isClass && !owner.isPackageClass) {
if (!owner.isInitialized) return outer.implicitss
- if (settings.debug.value) log("collect member implicits " + owner + ", implicit members = " + owner.thisType.implicitMembers);//debug
- collectImplicits(owner.thisType.implicitMembers, owner.thisType)
- } else if (scope != outer.scope && !owner.isPackageClass) {
- if (settings.debug.value) log("collect local implicits " + scope.toList);//debug
- collectImplicits(scope.toList, NoPrefix)
- } else if (imports != outer.imports) {
- assert(imports.tail == outer.imports)
- collectImplicitImports(imports.head)
- } else List()
- implicitsCache = if (newImplicits.isEmpty) outer.implicitss
- else newImplicits :: outer.implicitss
+ if (settings.debug.value)
+ log("collect member implicits " + owner + ", implicit members = " +
+ owner.thisType.implicitMembers)//debug
+ collectImplicits(owner.thisType.implicitMembers, owner.thisType)
+ } else if (scope != outer.scope && !owner.isPackageClass) {
+ if (settings.debug.value)
+ log("collect local implicits " + scope.toList)//debug
+ collectImplicits(scope.toList, NoPrefix)
+ } else if (imports != outer.imports) {
+ assert(imports.tail == outer.imports)
+ collectImplicitImports(imports.head)
+ } else List()
+ implicitsCache = if (newImplicits.isEmpty) outer.implicitss
+ else newImplicits :: outer.implicitss
}
implicitsCache
}
@@ -351,7 +373,8 @@ trait Contexts requires Analyzer {
def isExplicitImport(name: Name): boolean =
tree.selectors exists (._2.==(name.toTermName))
- /** The symbol with name `name' imported from import clause `tree'.
+ /** The symbol with name <code>name</code> imported from import clause
+ * <code>tree</code>.
*/
def importedSymbol(name: Name): Symbol = {
var result: Symbol = NoSymbol
@@ -359,7 +382,7 @@ trait Contexts requires Analyzer {
var selectors = tree.selectors
while (selectors != Nil && result == NoSymbol) {
if (selectors.head._2 == name.toTermName)
- result = qual.tpe.member(
+ result = qual.tpe.member(
if (name.isTypeName) selectors.head._1.toTypeName else selectors.head._1)
else if (selectors.head._1 == name.toTermName)
renamed = true
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 41f81ae85b..7c789d4ff6 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -174,7 +174,7 @@ trait Infer requires Analyzer {
functionType(formals, normalize(restpe))
case PolyType(List(), restpe) =>
if (util.Statistics.enabled) normP = normP + 1;
- normalize(restpe);
+ normalize(restpe)
case tp1 =>
if (util.Statistics.enabled) normO = normO + 1;
tp1
@@ -221,13 +221,13 @@ trait Infer requires Analyzer {
);
def foundReqMsg(found: Type, req: Type): String =
- ";\n found : " + found.toLongString + "\n required: " + req;
+ ";\n found : " + found.toLongString + "\n required: " + req
def error(pos: PositionType, msg: String): unit =
- context.error(pos, msg);
+ context.error(pos, msg)
def errorTree(tree: Tree, msg: String): Tree = {
- if (!tree.isErroneous) error(tree.pos, msg);
+ if (!tree.isErroneous) error(tree.pos, msg)
setError(tree)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 01ddfae607..62422dc7d9 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -7,12 +7,17 @@
//todo: rewrite or disllow new T where T is a mixin (currently: <init> not a member of T)
package scala.tools.nsc.typechecker
+import scala.collection.mutable.{HashMap, ListBuffer}
+import scala.tools.nsc.util.{HashSet, Position, Set}
import symtab.Flags._
import util.HashSet
-import scala.tools.nsc.util.{Position, Set, HashSet}
-import scala.collection.mutable.{HashMap, ListBuffer}
-/** Methods to create symbols and to enter them into scopes. */
+/** This trait provides methods to create symbols and to enter them into
+ * scopes.
+ *
+ * @author Martin Odersky
+ * @version 1.0
+ */
trait Typers requires Analyzer {
import global._
import definitions._
@@ -31,15 +36,15 @@ trait Typers requires Analyzer {
def resetTyper: unit = {
resetContexts
transformed.clear
- superDefs .clear
+ superDefs.clear
}
def newTyper(context: Context): Typer = new Typer(context)
object UnTyper extends Traverser {
override def traverse(tree: Tree) = {
- if (tree != EmptyTree) tree.tpe = null;
- if (tree.hasSymbol) tree.symbol = NoSymbol;
+ if (tree != EmptyTree) tree.tpe = null
+ if (tree.hasSymbol) tree.symbol = NoSymbol
super.traverse(tree)
}
}
@@ -56,7 +61,7 @@ trait Typers requires Analyzer {
}
private def inferView(pos: PositionType, from: Type, to: Type, reportAmbiguous: boolean): Tree = {
- if (settings.debug.value) log("infer view from "+from+" to "+to);//debug
+ if (settings.debug.value) log("infer view from "+from+" to "+to)//debug
if (phase.id > currentRun.typerPhase.id) EmptyTree
else from match {
case MethodType(_, _) => EmptyTree
@@ -84,7 +89,8 @@ trait Typers requires Analyzer {
private var namerCache: Namer = null
def namer = {
- if (namerCache == null || namerCache.context != context) namerCache = new Namer(context)
+ if (namerCache == null || namerCache.context != context)
+ namerCache = new Namer(context)
namerCache
}
@@ -131,8 +137,10 @@ trait Typers requires Analyzer {
private def funMode(mode: int) = mode & stickyModes | FUNmode | POLYmode
/** Report a type error.
- * @param pos The position where to report the error
- * @param ex The exception that caused the error */
+ *
+ * @param pos0 The position where to report the error
+ * @param ex The exception that caused the error
+ */
def reportTypeError(pos0: PositionType, ex: TypeError): unit = {
if (settings.debug.value) ex.printStackTrace()
val pos = if (ex.pos == NoPos) pos0 else ex.pos
@@ -154,7 +162,7 @@ trait Typers requires Analyzer {
}
}
- /** Check that tree is a stable expression.
+ /** Check that <code>tree</code> is a stable expression.
*/
def checkStable(tree: Tree): Tree =
if (treeInfo.isPureExpr(tree)) tree
@@ -215,21 +223,33 @@ trait Typers requires Analyzer {
case _ =>
}
- /** Check that type of given tree does not contain local or private components
+ /** Check that type of given tree does not contain local or private
+ * components.
*/
object checkNoEscaping extends TypeMap {
private var owner: Symbol = _
private var scope: Scope = _
private var badSymbol: Symbol = _
- /** Check that type `tree' does not refer to private components unless
- * itself is wrapped in something private (`owner' tells where the type occurs).
+ /** Check that type <code>tree</code> does not refer to private
+ * components unless itself is wrapped in something private
+ * (<code>owner</code> tells where the type occurs).
+ *
+ * @param owner ...
+ * @param tree ...
+ * @return ...
*/
- def privates[T <: Tree](owner: Symbol, tree: T): T = {
+ def privates[T <: Tree](owner: Symbol, tree: T): T =
check(owner, EmptyScope, tree)
- }
- /** Check that type `tree' does not refer to entities defined in scope `scope'. */
+ /** Check that type <code>tree</code> does not refer to entities
+ * defined in scope <code>scope</code>.
+ *
+ * @param scope ...
+ * @param pt ...
+ * @param tree ...
+ * @return ...
+ */
def locals[T <: Tree](scope: Scope, pt: Type, tree: T): T =
if (isFullyDefined(pt)) tree setType pt else check(NoSymbol, scope, tree)
@@ -237,7 +257,7 @@ trait Typers requires Analyzer {
this.owner = owner
this.scope = scope
badSymbol = NoSymbol
- assert(tree.tpe != null, tree);//debug
+ assert(tree.tpe != null, tree)//debug
apply(tree.tpe)
if (badSymbol == NoSymbol) tree
else {
@@ -276,7 +296,8 @@ trait Typers requires Analyzer {
}
def reenterValueParams(vparamss: List[List[ValDef]]): unit =
- for (val vparams <- vparamss; val vparam <- vparams) context.scope enter vparam.symbol
+ for (val vparams <- vparamss; val vparam <- vparams)
+ context.scope enter vparam.symbol
def reenterTypeParams(tparams: List[AbsTypeDef]): List[Symbol] =
for (val tparam <- tparams) yield {
@@ -284,7 +305,12 @@ trait Typers requires Analyzer {
tparam.symbol.deSkolemize
}
- /** The qualifying class of a this or super with prefix `qual' */
+ /** The qualifying class of a this or super with prefix <code>qual</code>.
+ *
+ * @param tree ...
+ * @param qual ...
+ * @return ...
+ */
def qualifyingClassContext(tree: Tree, qual: Name): Context = {
if (qual.isEmpty) {
if (context.enclClass.owner.isPackageClass)
@@ -319,6 +345,12 @@ trait Typers requires Analyzer {
} else tree
}
+ /**
+ * @param tree ...
+ * @param mode ...
+ * @param pt ...
+ * @return ...
+ */
def stabilizeFun(tree: Tree, mode: int, pt: Type): Tree = {
val sym = tree.symbol
val pre = tree match {
@@ -327,7 +359,7 @@ trait Typers requires Analyzer {
}
if (tree.tpe.isInstanceOf[MethodType] && pre.isStable &&
(pt.isStable || (mode & QUALmode) != 0 && !sym.isConstant || sym.isModule)) {
- assert(sym.tpe.paramTypes.isEmpty);
+ assert(sym.tpe.paramTypes.isEmpty)
tree.setType(MethodType(List(), singleType(pre, sym)))
} else tree
}
@@ -368,7 +400,7 @@ trait Typers requires Analyzer {
case ct @ ConstantType(value) if ((mode & TYPEmode) == 0 && (ct <:< pt)) => // (0)
copy.Literal(tree, value)
case OverloadedType(pre, alts) if ((mode & FUNmode) == 0) => // (1)
- inferExprAlternative(tree, pt);
+ inferExprAlternative(tree, pt)
adapt(tree, mode, pt)
case PolyType(List(), restpe) => // (2)
adapt(tree setType restpe, mode, pt)
@@ -396,7 +428,7 @@ trait Typers requires Analyzer {
isCompatible(tparamsToWildcards(mt, context.undetparams), pt) &&
(pt <:< functionType(mt.paramTypes map (t => WildcardType), WildcardType))) { // (4.2)
if (settings.debug.value) log("eta-expanding "+tree+":"+tree.tpe+" to "+pt)
- checkParamsConvertible(tree.pos, tree.tpe);
+ checkParamsConvertible(tree.pos, tree.tpe)
typed(etaExpand(tree), mode, pt)
} else if (!tree.symbol.isConstructor && mt.paramTypes.isEmpty) { // (4.3)
adapt(typed(Apply(tree, List()) setPos tree.pos), mode, pt)
@@ -471,7 +503,7 @@ trait Typers requires Analyzer {
} else if ((mode & PATTERNmode) != 0 && treeInfo.isSequencePattern(tree)) {
tree
} else {
- val tree1 = constfold(tree, pt); // (10) (11)
+ val tree1 = constfold(tree, pt) // (10) (11)
if (tree1.tpe <:< pt) adapt(tree1, mode, pt)
else {
if ((mode & (EXPRmode | FUNmode)) == EXPRmode) {
@@ -512,8 +544,14 @@ trait Typers requires Analyzer {
adapt(tree, mode, pt)
}
+ /**
+ * @param qual ...
+ * @param name ...
+ * @param tp ...
+ * @return ...
+ */
def adaptToMember(qual: Tree, name: Name, tp: Type): Tree = {
- val qtpe = qual.tpe.widen;
+ val qtpe = qual.tpe.widen
if (qual.isTerm && (qual.symbol == null || !qual.symbol.isTerm || qual.symbol.isValue) &&
phase.id <= currentRun.typerPhase.id && !qtpe.isError && !tp.isError &&
qtpe.symbol != AllRefClass && qtpe.symbol != AllClass && qtpe != WildcardType) {
@@ -610,7 +648,7 @@ trait Typers requires Analyzer {
}else {
error(parent.pos, ""+psym+" needs to be a trait be mixed in")
}
- else if (psym.hasFlag(FINAL))
+ else if (psym hasFlag FINAL)
error(parent.pos, "illegal inheritance from final class")
else if (!phase.erasedTypes && psym.isSealed &&
context.unit.source.file != psym.sourceFile)
@@ -633,6 +671,10 @@ trait Typers requires Analyzer {
for (val p <- parents) validateParentClass(p, parents.head.tpe.symbol)
}
+ /**
+ * @param cdef ...
+ * @return ...
+ */
def typedClassDef(cdef: ClassDef): Tree = {
attributes(cdef)
val clazz = cdef.symbol
@@ -647,8 +689,12 @@ trait Typers requires Analyzer {
ret
}
+ /**
+ * @param mdef ...
+ * @return ...
+ */
def typedModuleDef(mdef: ModuleDef): Tree = {
- //System.out.println("sourcefile of " + mdef.symbol + "=" + mdef.symbol.sourceFile);
+ //System.out.println("sourcefile of " + mdef.symbol + "=" + mdef.symbol.sourceFile)
attributes(mdef)
val clazz = mdef.symbol.moduleClass
val impl1 = newTyper(context.make(mdef.impl, clazz, newScope))
@@ -693,16 +739,22 @@ trait Typers requires Analyzer {
List(stat)
}
+ /**
+ * @param templ ...
+ * @param parents1 ...
+ * @return ...
+ */
def typedTemplate(templ: Template, parents1: List[Tree]): Template = {
val clazz = context.owner
- if (templ.symbol == NoSymbol) templ setSymbol clazz.newLocalDummy(templ.pos)
+ if (templ.symbol == NoSymbol)
+ templ setSymbol clazz.newLocalDummy(templ.pos)
val selfType =
if (clazz.isAnonymousClass && !phase.erasedTypes)
intersectionType(clazz.info.parents, clazz.owner)
else clazz.typeOfThis
// the following is necessary for templates generated later
new Namer(context.outer.make(templ, clazz, clazz.info.decls)).enterSyms(templ.body)
- validateParentClasses(parents1, selfType);
+ validateParentClasses(parents1, selfType)
val body = if (phase.id <= currentRun.typerPhase.id) templ.body flatMap addGetterSetter
else templ.body
val body1 = typedStats(body, templ.symbol)
@@ -728,7 +780,12 @@ trait Typers requires Analyzer {
copy.ValDef(vdef, vdef.mods, vdef.name, tpt1, rhs1) setType NoType
}
- /** Enter all aliases of local parameter accessors. */
+ /** Enter all aliases of local parameter accessors.
+ *
+ * @param clazz ...
+ * @param vparamss ...
+ * @param rhs ...
+ */
def computeParamAliases(clazz: Symbol, vparamss: List[List[ValDef]], rhs: Tree): unit = {
if (settings.debug.value) log("computing param aliases for "+clazz+":"+clazz.primaryConstructor.tpe+":"+rhs);//debug
def decompose(call: Tree): Pair[Tree, List[Tree]] = call match {
@@ -746,7 +803,7 @@ trait Typers requires Analyzer {
Pair(call, List())
}
val Pair(superConstr, superArgs) = decompose(rhs)
- assert(superConstr.symbol != null);//debug
+ assert(superConstr.symbol != null)//debug
if (superConstr.symbol.isPrimaryConstructor) {
val superClazz = superConstr.symbol.owner
if (!superClazz.hasFlag(JAVA)) {
@@ -754,7 +811,8 @@ trait Typers requires Analyzer {
if (superParamAccessors.length != superArgs.length) {
System.out.println("" + superClazz + ":" +
superClazz.info.decls.toList.filter(.hasFlag(PARAMACCESSOR)))
- assert(false, "mismatch: "+superParamAccessors+";"+rhs+";"+superClazz.info.decls); //debug
+ assert(false, "mismatch: " + superParamAccessors +
+ ";" + rhs + ";" + superClazz.info.decls)//debug
}
List.map2(superParamAccessors, superArgs) { (superAcc, superArg) =>
superArg match {
@@ -793,7 +851,7 @@ trait Typers requires Analyzer {
case Apply(fun, _) =>
if (fun.symbol.isConstructor &&
fun.symbol.owner == meth.owner && fun.symbol.pos >= meth.pos)
- error(fun.pos, "called constructor must precede calling constructor");
+ error(fun.pos, "called constructor must precede calling constructor")
case _ =>
}
def typedSuperCall(tree: Tree, pt: Type): Tree = {
@@ -823,7 +881,7 @@ trait Typers requires Analyzer {
meth.owner.isModuleClass ||
meth.owner.isAnonymousClass ||
meth.owner.isRefinementClass))
- error(ddef.pos, "constructor definition not allowed here "+meth.owner);//debug
+ error(ddef.pos, "constructor definition not allowed here "+meth.owner)//debug
val result = ddef.rhs match {
case block @ Block(stat :: stats, expr) =>
// the following makes sure not to copy the tree if no subtrees have changed
@@ -1223,8 +1281,12 @@ trait Typers requires Analyzer {
}
}
- /** Try to apply function to arguments; if it does not work try to insert an implicit
- * conversion
+ /** Try to apply function to arguments; if it does not work try to
+ * insert an implicit conversion.
+ *
+ * @param fun ...
+ * @param args ...
+ * @return ...
*/
def tryTypedApply(fun: Tree, args: List[Tree]): Tree = try {
if (context.reportGeneralErrors) {
@@ -1286,13 +1348,14 @@ trait Typers requires Analyzer {
}
}
*/
- /** Attribute a selection where `tree' is `qual.name'.
- * `qual' is already attributed.
+ /** Attribute a selection where <code>tree</code> is `qual.name'.
+ * <code>qual</code> is already attributed.
*/
def typedSelect(qual: Tree, name: Name): Tree = {
val sym =
if (tree.symbol != NoSymbol) {
- if (phase.erasedTypes && qual.isInstanceOf[Super]) qual.tpe = tree.symbol.owner.tpe
+ if (phase.erasedTypes && qual.isInstanceOf[Super])
+ qual.tpe = tree.symbol.owner.tpe
if (false && settings.debug.value) { // todo: replace by settings.check.value?
val alts = qual.tpe.member(tree.symbol.name).alternatives
if (!(alts exists (alt =>
@@ -1322,7 +1385,8 @@ trait Typers requires Analyzer {
decode(name)+" is not a member of "+qual.tpe.widen +
(if (Position.line(context.unit.source, qual.pos) <
Position.line(context.unit.source, tree.pos))
- "\npossible cause: maybe a semicolon is missing before `"+name+"'?" else ""))
+ "\npossible cause: maybe a semicolon is missing before `"+name+"'?"
+ else ""))
}
setError(tree)
} else {
@@ -1346,7 +1410,7 @@ trait Typers requires Analyzer {
sym => sym.exists && context.isAccessible(sym, pre, false))) != NoSymbol) return true
cx = cx.outer
}
- var imports = context.imports; // impSym != NoSymbol => it is imported from imports.head
+ var imports = context.imports // impSym != NoSymbol => it is imported from imports.head
while (!imports.isEmpty) {
if (imports.head.importedSymbol(name) != NoSymbol) return true
imports = imports.tail
@@ -1444,7 +1508,7 @@ trait Typers requires Analyzer {
pre = qual.tpe
} else {
if (settings.debug.value) {
- log(context.imports);//debug
+ log(context.imports)//debug
}
error(tree.pos, "not found: "+decode(name))
defSym = context.owner.newErrorSymbol(name)
@@ -1453,7 +1517,7 @@ trait Typers requires Analyzer {
}
if (defSym.owner.isPackageClass) pre = defSym.owner.thisType
val tree1 = if (qual == EmptyTree) tree
- else atPos(tree.pos)(Select(qual, name));
+ else atPos(tree.pos)(Select(qual, name))
// atPos necessary because qualifier might come from startContext
stabilize(checkAccessible(tree1, defSym, pre, qual), pre, mode, pt)
}
@@ -1530,8 +1594,10 @@ trait Typers requires Analyzer {
namer.enterInScope(vble)
}
val body1 = typed(body, mode, pt)
- vble.setInfo(if (treeInfo.isSequenceValued(body)) seqType(body1.tpe) else body1.tpe)
- copy.Bind(tree, name, body1) setSymbol vble setType body1.tpe; // buraq, was: pt
+ vble.setInfo(
+ if (treeInfo.isSequenceValued(body)) seqType(body1.tpe)
+ else body1.tpe)
+ copy.Bind(tree, name, body1) setSymbol vble setType body1.tpe // buraq, was: pt
case ArrayValue(elemtpt, elems) =>
val elemtpt1 = typedType(elemtpt)
@@ -1587,11 +1653,12 @@ trait Typers requires Analyzer {
copy.Match(tree, selector1, cases1) setType ptOrLub(cases1 map (.tpe))
case Return(expr) =>
- val enclMethod = context.enclMethod;
+ val enclMethod = context.enclMethod
if (enclMethod == NoContext || enclMethod.owner.isConstructor)
errorTree(tree, "return outside method definition")
else if (!enclMethod.owner.isInitialized)
- errorTree(tree, "method "+enclMethod.owner+" has return statement; needs result type")
+ errorTree(tree, "method " + enclMethod.owner +
+ " has return statement; needs result type")
else {
val DefDef(_, _, _, _, restpt, _) = enclMethod.tree
assert(restpt.tpe != null, restpt)
@@ -1620,7 +1687,8 @@ trait Typers requires Analyzer {
.setType(appliedType(tpt1.tpe, context.undetparams map (.tpe)))
}
if (tpt1.tpe.symbol hasFlag ABSTRACT)
- error(tree.pos, ""+tpt1.tpe.symbol+" is abstract; cannot be instantiated")
+ error(tree.pos, "" + tpt1.tpe.symbol +
+ " is abstract; cannot be instantiated")
copy.New(tree, tpt1).setType(tpt1.tpe)
case Typed(expr, Function(List(), EmptyTree)) =>
@@ -1669,7 +1737,8 @@ trait Typers requires Analyzer {
if (stableApplication) fun1 = stabilizeFun(fun1, mode, pt)
// if function is overloaded, filter all alternatives that match
// number of arguments and expected result type.
- if (settings.debug.value) log("trans app "+fun1+":"+fun1.symbol+":"+fun1.tpe+" "+args);//DEBUG
+ if (settings.debug.value)
+ log("trans app "+fun1+":"+fun1.symbol+":"+fun1.tpe+" "+args)//DEBUG
if (util.Statistics.enabled) appcnt = appcnt + 1
if (phase.id <= currentRun.typerPhase.id &&
fun1.isInstanceOf[Select] &&
@@ -1795,9 +1864,8 @@ trait Typers requires Analyzer {
def typed(tree: Tree, mode: int, pt: Type): Tree =
try {
- if (settings.debug.value) {
- assert(pt != null, tree);//debug
- }
+ if (settings.debug.value)
+ assert(pt != null, tree)//debug
if (context.retyping &&
tree.tpe != null && (tree.tpe.isErroneous || !(tree.tpe <:< pt))) {
tree.tpe = null
@@ -1818,7 +1886,8 @@ trait Typers requires Analyzer {
case ex: Throwable =>
if (settings.debug.value)
System.out.println("exception when typing "+tree+", pt = "+pt)
- if (context != null && context.unit != null && context.unit.source != null && tree != null)
+ if (context != null && context.unit != null &&
+ context.unit.source != null && tree != null)
logError("AT: " + context.unit.source.dbg(tree.pos), ex);
throw(ex)
}
@@ -1847,7 +1916,7 @@ trait Typers requires Analyzer {
def typedOperator(tree: Tree): Tree =
typed(tree, EXPRmode | FUNmode | POLYmode | TAPPmode, WildcardType)
- /** Types a pattern with prototype `pt' */
+ /** Types a pattern with prototype <code>pt</code> */
def typedPattern(tree: Tree, pt: Type): Tree =
typed(tree, PATTERNmode, pt)
@@ -1896,12 +1965,15 @@ trait Typers requires Analyzer {
case _ => tp.isError
}
- /** Try to construct a typed tree from given implicit info with given expected type
+ /** Try to construct a typed tree from given implicit info with given
+ * expected type.
+ *
* @param pos Position for error reporting
* @param info The given implicit info describing the implicit definition
* @param pt The expected type
* @param isLocal Is implicit definition visible without prefix?
- * @returns A typed tree if the implicit info can be made to conform to `pt', EmptyTree otherwise.
+ * @return A typed tree if the implicit info can be made to conform
+ * to `pt', EmptyTree otherwise.
* @pre info.tpe does not contain an error
*/
private def typedImplicit(pos: PositionType, info: ImplicitInfo, pt: Type, isLocal: boolean): Tree = {
@@ -1916,15 +1988,15 @@ trait Typers requires Analyzer {
}
def fail(reason: String, sym1: Symbol, sym2: Symbol): Tree = {
if (settings.debug.value)
- log(""+tree+" is not a valid implicit value because:\n"+reason + sym1+" "+sym2);
+ log(""+tree+" is not a valid implicit value because:\n"+reason + sym1+" "+sym2)
EmptyTree
}
try {
// if (!isLocal) tree setSymbol info.sym
val tree1 = typed1(tree, EXPRmode, pt)
- if (settings.debug.value) log("typed implicit "+tree1+":"+tree1.tpe+", pt = "+pt);
+ if (settings.debug.value) log("typed implicit "+tree1+":"+tree1.tpe+", pt = "+pt)
val tree2 = adapt(tree1, EXPRmode, pt)
- if (settings.debug.value) log("adapted implicit "+tree1.symbol+":"+tree2.tpe+" to "+pt);
+ if (settings.debug.value) log("adapted implicit "+tree1.symbol+":"+tree2.tpe+" to "+pt)
if (tree2.tpe.isError) EmptyTree
else if (info.sym == tree1.symbol) tree2
else fail("syms differ: ", tree1.symbol, info.sym)
@@ -1934,7 +2006,8 @@ trait Typers requires Analyzer {
} else EmptyTree
}
- /** Infer implicit argument or view
+ /** Infer implicit argument or view.
+ *
* @param pos position for error reporting
* @param pt the expected type of the implicit
* @param isView are we searching for a view? (this affects the error message)
@@ -2028,7 +2101,8 @@ trait Typers requires Analyzer {
var tree = searchImplicit(context.implicitss, true)
if (tree == EmptyTree) tree = searchImplicit(implicitsOfType(pt), false)
- if (util.Statistics.enabled) impltime = impltime + System.currentTimeMillis() - startTime
+ if (util.Statistics.enabled)
+ impltime = impltime + System.currentTimeMillis() - startTime
tree
}
diff --git a/src/library/scala/Iterable.scala b/src/library/scala/Iterable.scala
index 527ff52fa8..175a584d0e 100644
--- a/src/library/scala/Iterable.scala
+++ b/src/library/scala/Iterable.scala
@@ -11,7 +11,6 @@
package scala
-
/** This object ...
*
* @author Matthias Zenger
@@ -23,15 +22,15 @@ object Iterable {
new Ordered[Iterable[A]] {
def compare[B >: Iterable[A] <% Ordered[B]](that: B): Int = that match {
case y: Iterable[A] =>
- val xs = x.elements;
- val ys = y.elements;
- var res = 0;
- while (xs.hasNext && ys.hasNext && (res == 0)) {
- res = xs.next compare ys.next;
+ val xs = x.elements
+ val ys = y.elements
+ var res = 0
+ while (xs.hasNext && ys.hasNext && (res == 0)) {
+ res = xs.next compare ys.next
}
- if (xs.hasNext) 1
- else if (ys.hasNext) -1
- else res;
+ if (xs.hasNext) 1
+ else if (ys.hasNext) -1
+ else res
case _ =>
-(that compare x)
}
@@ -40,11 +39,11 @@ object Iterable {
/** The minimum element of a non-empty sequence of ordered elements */
def min[A <% Ordered[A]](seq: Iterable[A]): A = {
val xs = seq.elements
- if (!xs.hasNext) Predef.error("min(<empty>)");
+ if (!xs.hasNext) Predef.error("min(<empty>)")
var min = xs.next
while (xs.hasNext) {
val x = xs.next
- if (x < min) min = x;
+ if (x < min) min = x
}
min
}
@@ -52,11 +51,11 @@ object Iterable {
/** The maximum element of a non-empty sequence of ordered elements */
def max[A <% Ordered[A]](seq: Iterable[A]): A = {
val xs = seq.elements
- if (!xs.hasNext) Predef.error("max(<empty>)");
+ if (!xs.hasNext) Predef.error("max(<empty>)")
var max = xs.next
while (xs.hasNext) {
val x = xs.next
- if (max < x) max = x;
+ if (max < x) max = x
}
max
}
@@ -123,17 +122,19 @@ trait Iterable[+A] {
def find(p: A => Boolean): Option[A] = elements.find(p)
/** Returns index of the first element satisying a predicate, or -1.
- * @param p the predicate
- * @return the index of the first element satisfying <code>p</code>, or -1 if such an element does not exist
+ *
+ * @param p the predicate
+ * @return the index of the first element satisfying <code>p</code>,
+ * or -1 if such an element does not exist
*/
def indexOf(p: A => Boolean): Int = {
val it = elements
- var i = 0
- while(it.hasNext)
- if(p(it.next))
- return i
+ var i = 0
+ while (it.hasNext)
+ if (p(it.next))
+ return i
else
- i = i + 1
+ i = i + 1
return -1
}