diff options
author | michelou <michelou@epfl.ch> | 2007-06-21 12:42:16 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2007-06-21 12:42:16 +0000 |
commit | aba747cf8d0145d6c10726151bf55ff997e8b0e6 (patch) | |
tree | fa619fc190d9f2739fa10f55fc5b6b0dc29354d4 /src/compiler | |
parent | 72c1d53647bc4e6899cf21b8e7ea12ca252b31dd (diff) | |
download | scala-aba747cf8d0145d6c10726151bf55ff997e8b0e6.tar.gz scala-aba747cf8d0145d6c10726151bf55ff997e8b0e6.tar.bz2 scala-aba747cf8d0145d6c10726151bf55ff997e8b0e6.zip |
removed more primitive type aliases, removed so...
removed more primitive type aliases, removed some tabs
Diffstat (limited to 'src/compiler')
14 files changed, 155 insertions, 132 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index c15794a929..fd58a9ad71 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -512,14 +512,17 @@ class Interpreter(val settings: Settings, out: PrintWriter) { } /** A traverser that finds all mentioned identifiers, i.e. things - that need to be imported. - It might return extra names. */ + * that need to be imported. + * It might return extra names. + */ private class ImportVarsTraverser(definedVars: List[Name]) extends Traverser { val importVars = new HashSet[Name]() - override def traverse(ast: Tree): unit = ast match { - case Ident(name) => importVars += name - case _ => super.traverse(ast) + override def traverse(ast: Tree) { + ast match { + case Ident(name) => importVars += name + case _ => super.traverse(ast) + } } } @@ -544,10 +547,11 @@ class Interpreter(val settings: Settings, out: PrintWriter) { /** A computed variable name, if one is needed */ def varName = varNameCache match { - case None => + case None => varNameCache = Some(newVarName) varNameCache.get - case Some(name) => name + case Some(name) => + name } /** list of methods defined */ @@ -615,8 +619,6 @@ class Interpreter(val settings: Settings, out: PrintWriter) { * the request binds. */ val accessPath = myImportsCode._3 - - /** the line of code to compute */ def toCompute = line @@ -815,7 +817,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) { def keyword: String = if(classdef.mods.isTrait) "trait" else "class" - override def resultExtractionCode(code: PrintWriter): Unit = { + override def resultExtractionCode(code: PrintWriter) { super.resultExtractionCode(code) code.print( " + \"defined " + @@ -833,7 +835,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) { case List(TypeDef(_, name, _, _)) => name } - override def resultExtractionCode(code: PrintWriter): Unit = { + override def resultExtractionCode(code: PrintWriter) { super.resultExtractionCode(code) code.println(" + \"defined type alias " + newTypeName + "\\n\"") } @@ -843,7 +845,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) { private class ImportReq(line: String, lineName: String) extends Request(line, lineName) { override val boundNames = Nil - override def resultExtractionCode(code: PrintWriter): Unit = { + override def resultExtractionCode(code: PrintWriter) { code.println("+ \"" + trees.head.toString + "\\n\"") } @@ -873,14 +875,16 @@ object Interpreter { /** Delete a directory tree recursively. Use with care! */ - def deleteRecursively(path: File): Unit = { + def deleteRecursively(path: File) { path match { - case _ if !path.exists => {} + case _ if !path.exists => + () case _ if path.isDirectory => for (p <- path.listFiles) deleteRecursively(p) path.delete - case _ => path.delete + case _ => + path.delete } } diff --git a/src/compiler/scala/tools/nsc/InterpreterCommand.scala b/src/compiler/scala/tools/nsc/InterpreterCommand.scala index 308fe19860..8f9a104a9e 100644 --- a/src/compiler/scala/tools/nsc/InterpreterCommand.scala +++ b/src/compiler/scala/tools/nsc/InterpreterCommand.scala @@ -1,13 +1,17 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ package scala.tools.nsc -/** a command line for the interpreter */ -class InterpreterCommand(arguments: List[String], error: String => unit) +/** A command line for the interpreter. + * + * @author Lex Spoon + * @version 1.0 + */ +class InterpreterCommand(arguments: List[String], error: String => Unit) extends CompilerCommand(arguments, new Settings(error), error, false) { override val cmdName = "scala" override val fileEnding = ".scalaint" diff --git a/src/compiler/scala/tools/nsc/InterpreterLoop.scala b/src/compiler/scala/tools/nsc/InterpreterLoop.scala index 99a26e1336..80b233fa47 100644 --- a/src/compiler/scala/tools/nsc/InterpreterLoop.scala +++ b/src/compiler/scala/tools/nsc/InterpreterLoop.scala @@ -114,7 +114,7 @@ class InterpreterLoop(in0: BufferedReader, out: PrintWriter) { var first = true while (true) { if (interactive) { - out.print(prompt) + out.print(prompt) out.flush } if (first) { diff --git a/src/compiler/scala/tools/nsc/SubComponent.scala b/src/compiler/scala/tools/nsc/SubComponent.scala index ff759cdc9c..f3868e91ff 100644 --- a/src/compiler/scala/tools/nsc/SubComponent.scala +++ b/src/compiler/scala/tools/nsc/SubComponent.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -19,7 +19,7 @@ abstract class SubComponent { val phaseName: String /** New flags defined by the phase which are not valid before */ - def phaseNewFlags: long = 0 + def phaseNewFlags: Long = 0 /** The phase factory */ def newPhase(prev: Phase): Phase diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 1edcef5e5b..6dd366bbae 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -128,9 +128,9 @@ trait Trees { buffer.toString() } - override def hashCode(): int = super.hashCode() + override def hashCode(): Int = super.hashCode() - override def equals(that: Any): boolean = that match { + override def equals(that: Any): Boolean = that match { case t: Tree => this eq t case _ => false } @@ -441,7 +441,7 @@ trait Trees { case class DocDef(comment: String, definition: Tree) extends Tree { override def symbol: Symbol = definition.symbol - override def symbol_=(sym: Symbol): unit = { definition.symbol = sym } + override def symbol_=(sym: Symbol) { definition.symbol = sym } } /** Instantiation template @@ -624,14 +624,14 @@ trait Trees { case class TypeApply(fun: Tree, args: List[Tree]) extends GenericApply { override def symbol: Symbol = fun.symbol - override def symbol_=(sym: Symbol): unit = { fun.symbol = sym } + override def symbol_=(sym: Symbol) { fun.symbol = sym } } /** Value application */ case class Apply(fun: Tree, args: List[Tree]) extends GenericApply { override def symbol: Symbol = fun.symbol - override def symbol_=(sym: Symbol): unit = { fun.symbol = sym } + override def symbol_=(sym: Symbol) { fun.symbol = sym } } /** Dynamic value application. @@ -727,7 +727,7 @@ trait Trees { case class AppliedTypeTree(tpt: Tree, args: List[Tree]) extends TypTree { override def symbol: Symbol = tpt.symbol - override def symbol_=(sym: Symbol): unit = { tpt.symbol = sym } + override def symbol_=(sym: Symbol) { tpt.symbol = sym } } case class TypeBoundsTree(lo: Tree, hi: Tree) @@ -1324,7 +1324,7 @@ trait Trees { List.mapConserve(stats)(stat => if (exprOwner != currentOwner && stat.isTerm) atOwner(exprOwner)(transform(stat)) else transform(stat)) filter (EmptyTree !=) - def transformUnit(unit: CompilationUnit): unit = { unit.body = transform(unit.body) } + def transformUnit(unit: CompilationUnit) { unit.body = transform(unit.body) } def atOwner[A](owner: Symbol)(trans: => A): A = { val prevOwner = currentOwner @@ -1337,7 +1337,7 @@ trait Trees { class Traverser { protected var currentOwner: Symbol = definitions.RootClass - def traverse(tree: Tree): unit = tree match { + def traverse(tree: Tree): Unit = tree match { case EmptyTree => ; case PackageDef(name, stats) => @@ -1446,17 +1446,20 @@ trait Trees { traverse(tpt); traverseTrees(whereClauses) } - def traverseTrees(trees: List[Tree]): unit = + def traverseTrees(trees: List[Tree]) { trees foreach traverse - def traverseTreess(treess: List[List[Tree]]): unit = + } + def traverseTreess(treess: List[List[Tree]]) { treess foreach traverseTrees - def traverseStats(stats: List[Tree], exprOwner: Symbol): unit = + } + def traverseStats(stats: List[Tree], exprOwner: Symbol) { stats foreach (stat => if (exprOwner != currentOwner && stat.isTerm) atOwner(exprOwner)(traverse(stat)) else traverse(stat)) + } def apply[T <: Tree](tree: T): T = { traverse(tree); tree } - def atOwner(owner: Symbol)(traverse: => unit): unit = { + def atOwner(owner: Symbol)(traverse: => Unit) { val prevOwner = currentOwner currentOwner = owner traverse @@ -1479,7 +1482,7 @@ trait Trees { class TreeTypeSubstituter(from: List[Symbol], to: List[Type]) extends Traverser { val typeSubst = new SubstTypeMap(from, to) - override def traverse(tree: Tree): unit = { + override def traverse(tree: Tree) { if (tree.tpe ne null) tree.tpe = typeSubst(tree.tpe) super.traverse(tree) } @@ -1488,8 +1491,8 @@ trait Trees { class TreeSymSubstituter(from: List[Symbol], to: List[Symbol]) extends Traverser { val symSubst = new SubstSymMap(from, to) - override def traverse(tree: Tree): unit = { - def subst(from: List[Symbol], to: List[Symbol]): unit = { + override def traverse(tree: Tree) { + def subst(from: List[Symbol], to: List[Symbol]) { if (!from.isEmpty) if (tree.symbol == from.head) tree setSymbol to.head else subst(from.tail, to.tail) @@ -1502,7 +1505,7 @@ trait Trees { } class ChangeOwnerTraverser(val oldowner: Symbol, val newowner: Symbol) extends Traverser { - override def traverse(tree: Tree): unit = { + override def traverse(tree: Tree) { if ((tree.isDef || tree.isInstanceOf[Function]) && tree.symbol != NoSymbol && tree.symbol.owner == oldowner) tree.symbol.owner = newowner; @@ -1519,11 +1522,12 @@ trait Trees { object posAssigner extends Traverser { var pos: Position = _ - override def traverse(t: Tree): unit = + override def traverse(t: Tree) { if (t != EmptyTree && t.pos == NoPosition) { t.setPos(pos) super.traverse(t) } + } def atPos[T <: Tree](pos: Position)(tree: T): T = { this.pos = pos traverse(tree) @@ -1532,7 +1536,7 @@ trait Trees { } class ForeachTraverser(f: Tree => Unit) extends Traverser { - override def traverse(t: Tree) = { + override def traverse(t: Tree) { f(t) super.traverse(t) } @@ -1540,7 +1544,7 @@ trait Trees { class FilterTraverser(p: Tree => Boolean) extends Traverser { val hits = new ListBuffer[Tree] - override def traverse(t: Tree) = { + override def traverse(t: Tree) { if (p(t)) hits += t super.traverse(t) } @@ -1548,15 +1552,16 @@ trait Trees { class FindTraverser(p: Tree => Boolean) extends Traverser { var result: Option[Tree] = None - override def traverse(t: Tree) = + override def traverse(t: Tree) { if (result.isEmpty) { if (p(t)) result = Some(t) super.traverse(t) } + } } object resetPos extends Traverser { - override def traverse(t: Tree): unit = { + override def traverse(t: Tree) { if (t != EmptyTree) t.setPos(NoPosition) super.traverse(t) } @@ -1569,7 +1574,7 @@ trait Trees { */ object resetAttrs extends Traverser { private val erasedSyms = new HashSet[Symbol](8) - override def traverse(tree: Tree): unit = tree match { + override def traverse(tree: Tree): Unit = tree match { case EmptyTree | TypeTree() => ; case Template(parents, self, body) => diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index f0995d1b3c..6240a97e27 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -29,7 +29,7 @@ trait MarkupParsers { import global._ //import posAssigner.atPos - class MarkupParser(p: UnitParser, presWS: boolean) /*with scala.xml.parsing.MarkupParser[Tree,Tree] */{ + class MarkupParser(p: UnitParser, presWS: Boolean) /*with scala.xml.parsing.MarkupParser[Tree,Tree] */{ import Tokens.{EMPTY, LBRACE, RBRACE} @@ -54,7 +54,7 @@ trait MarkupParsers { /*[Duplicate]*/ protected val cbuf = new StringBuilder() /** append Unicode character to name buffer*/ - /*[Duplicate]*/ protected def putChar(c: char) = cbuf.append(c) + /*[Duplicate]*/ protected def putChar(c: Char) = cbuf.append(c) /*[Duplicate]*/ var xEmbeddedBlock = false @@ -128,7 +128,7 @@ trait MarkupParsers { /** attribute value, terminated by either ' or ". value may not contain <. * @param endch either ' or " */ - /*[Duplicate]*/ def xAttributeValue(endCh: char): String = { + /*[Duplicate]*/ def xAttributeValue(endCh: Char): String = { while (ch != endCh) { putChar(ch) nextch @@ -251,7 +251,7 @@ trait MarkupParsers { } nextch } - new String(Array(i.asInstanceOf[char])) + new String(Array(i.asInstanceOf[Char])) } /** Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->' @@ -280,7 +280,7 @@ trait MarkupParsers { * @param txt ... */ /*[Duplicate]*/ def appendText(pos: Position, ts: mutable.Buffer[Tree], - txt: String): Unit = + txt: String) { if (!preserveWS) { for (t <- TextBuffer.fromString(txt).toText) { ts.append(handle.text(pos, t.text)) @@ -288,6 +288,7 @@ trait MarkupParsers { } else ts.append( handle.text(pos, txt)) + } /** adds entity/character to to ts as side-effect * @precond ch == '&' diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 884854f29d..c65f73ad85 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -99,7 +99,8 @@ trait Parsers { def xmlp = { if (xmlp0 == null) xmlp0 = this match { - case in: UnitParser => new MarkupParser(in, true) + case in: UnitParser => + new MarkupParser(in, true) case _ => Console.println("Cannot create XML PARSER " + in) null @@ -208,11 +209,13 @@ trait Parsers { } } - def syntaxError(msg: String, skipIt: boolean): unit = + def syntaxError(msg: String, skipIt: Boolean) { syntaxError(inCurrentPos, msg, skipIt) - def syntaxError(pos : ScanPosition, msg : String) = in.error(pos, msg) - - def syntaxError(pos: ScanPosition, msg: String, skipIt: boolean): Unit = { + } + def syntaxError(pos: ScanPosition, msg: String) { + in.error(pos, msg) + } + def syntaxError(pos: ScanPosition, msg: String, skipIt: Boolean) { if (pos != in.errpos) { syntaxError(pos, msg) in.errpos = pos @@ -245,8 +248,9 @@ trait Parsers { } } - def incompleteInputError(msg: String): Unit = + def incompleteInputError(msg: String) { incompleteInputError(inCurrentPos, msg) // inCurrentPos should be at the EOF + } def syntaxErrorOrIncomplete(msg: String, skipIt: Boolean) { if (inToken == EOF) @@ -294,9 +298,10 @@ trait Parsers { /** semi = nl {nl} | `;' * nl = `\n' // where allowed */ - def acceptStatSep(): Unit = + def acceptStatSep() { if (inToken == NEWLINE || inToken == NEWLINES) inNextToken else accept(SEMI) + } def errorTypeTree = TypeTree().setType(ErrorType).setPos((inCurrentPos)) def errorTermTree = Literal(Constant(null)).setPos((inCurrentPos)) @@ -327,7 +332,7 @@ trait Parsers { def isIdent = inToken == IDENTIFIER || inToken == BACKQUOTED_IDENT - def isExprIntroToken(token: int): Boolean = token match { + def isExprIntroToken(token: Int): Boolean = token match { case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT | STRINGLIT | SYMBOLLIT | TRUE | FALSE | NULL | IDENTIFIER | BACKQUOTED_IDENT | THIS | SUPER | IF | FOR | NEW | USCORE | TRY | WHILE | @@ -424,7 +429,7 @@ trait Parsers { case class OpInfo(operand: Tree, operator: Name, pos: ScanPosition) var opstack: List[OpInfo] = Nil - def precedence(operator: Name): int = + def precedence(operator: Name): Int = if (operator eq nme.ERROR) -1 else { val firstCh = operator(0) @@ -445,16 +450,16 @@ trait Parsers { } } - def checkSize(kind: String, size: int, max: int) { + def checkSize(kind: String, size: Int, max: Int) { if (size > max) syntaxError("too many "+kind+", maximum = "+max, false) } - def checkAssoc(pos: ScanPosition, op: Name, leftAssoc: boolean) = + def checkAssoc(pos: ScanPosition, op: Name, leftAssoc: Boolean) = if (treeInfo.isLeftAssoc(op) != leftAssoc) syntaxError( pos, "left- and right-associative operators with same precedence may not be mixed", false) - def reduceStack(isExpr: boolean, base: List[OpInfo], top0: Tree, prec: int, leftAssoc: boolean): Tree = { + def reduceStack(isExpr: Boolean, base: List[OpInfo], top0: Tree, prec: Int, leftAssoc: Boolean): Tree = { var top = top0 if (opstack != base && precedence(opstack.head.operator) == prec) checkAssoc(opstack.head.pos, opstack.head.operator, leftAssoc) @@ -504,7 +509,7 @@ trait Parsers { * | [Ident `.'] this * AnnotType ::= Path [`.' type] */ - def path(thisOK: boolean, typeOK: boolean): Tree = { + def path(thisOK: Boolean, typeOK: Boolean): Tree = { var t: Tree = null if (inToken == THIS) { t = atPos(inSkipToken) { This(nme.EMPTY.toTypeName) } @@ -544,7 +549,7 @@ trait Parsers { t } - def selectors(t: Tree, typeOK: boolean, pos : ScanPosition): Tree = + def selectors(t: Tree, typeOK: Boolean, pos : ScanPosition): Tree = if (typeOK && inToken == TYPE) { inNextToken atPos(pos) { SingletonTypeTree(t) } @@ -586,7 +591,7 @@ trait Parsers { * | null */ - def literal(isPattern: boolean, isNegated: boolean): Tree = { + def literal(isPattern: Boolean, isNegated: Boolean): Tree = { def litToTree() = atPos(inCurrentPos) { Literal( inToken match { @@ -619,24 +624,26 @@ trait Parsers { } } - def newLineOpt(): unit = + def newLineOpt() { if (inToken == NEWLINE) { if (settings.migrate.value) in.newNewLine = false inNextToken } + } - def newLinesOpt(): unit = + def newLinesOpt() { if (inToken == NEWLINE || inToken == NEWLINES) { if (settings.migrate.value) in.newNewLine = false inNextToken } + } - def newLineOptWhenFollowedBy(token: int) { + def newLineOptWhenFollowedBy(token: Int) { // note: next is defined here because current == NEWLINE if (inToken == NEWLINE && inNextTokenCode == token) newLineOpt() } - def newLineOptWhenFollowing(p: int => boolean) { + def newLineOptWhenFollowing(p: Int => Boolean) { // note: next is defined here because current == NEWLINE if (inToken == NEWLINE && p(inNextTokenCode)) newLineOpt() } @@ -662,7 +669,7 @@ trait Parsers { * * (also eats trailing comma if it finds one) */ - def types(isPattern: boolean): List[Tree] = { + def types(isPattern: Boolean): List[Tree] = { val ts = new ListBuffer[Tree] + argType(isPattern) while (inToken == COMMA) { inNextToken @@ -732,10 +739,10 @@ trait Parsers { /** InfixType ::= CompoundType {id [nl] CompoundType} * TypePat ::= CompoundTypePat {id [nl] CompoundTypePat */ - def infixType(isPattern: boolean, mode: int): Tree = + def infixType(isPattern: Boolean, mode: Int): Tree = infixTypeRest(inCurrentPos, annotType(isPattern), isPattern, mode) - def infixTypeRest(pos: ScanPosition, t0: Tree, isPattern: boolean, mode: int): Tree = { + def infixTypeRest(pos: ScanPosition, t0: Tree, isPattern: Boolean, mode: Int): Tree = { val t = compoundTypeRest(pos, t0, isPattern) if (isIdent && inName != nme.STAR) { val opPos = inCurrentPos @@ -755,10 +762,10 @@ trait Parsers { /** CompoundType ::= AnnotType {with AnnotType} [Refinement] * CompoundTypePat ::= AnnotTypePat {with AnnotTypePat} */ - def compoundType(isPattern: boolean): Tree = + def compoundType(isPattern: Boolean): Tree = compoundTypeRest(inCurrentPos, annotType(isPattern), isPattern) - def compoundTypeRest(pos: ScanPosition, t: Tree, isPattern: boolean): Tree = { + def compoundTypeRest(pos: ScanPosition, t: Tree, isPattern: Boolean): Tree = { var ts = new ListBuffer[Tree] + t while (inToken == WITH) { inNextToken; ts += annotType(isPattern) @@ -785,7 +792,7 @@ trait Parsers { * | Path `.' type * | `(' ArgTypePats [`,'] `)' */ - def annotType(isPattern: boolean): Tree = { + def annotType(isPattern: Boolean): Tree = { val annots = annotations() val pos = inCurrentPos var t: Tree = @@ -826,7 +833,7 @@ trait Parsers { /** TypeArgs ::= `[' ArgType {`,' ArgType} `]' * TypePatArgs ::= '[' ArgTypePat {`,' ArgTypePat} `]' */ - def typeArgs(isPattern: boolean): List[Tree] = { + def typeArgs(isPattern: Boolean): List[Tree] = { accept(LBRACKET) val ts = types(isPattern) accept(RBRACKET) @@ -838,7 +845,7 @@ trait Parsers { * | `_' * | Type // for array elements only! */ - def argType(isPattern: boolean): Tree = + def argType(isPattern: Boolean): Tree = if (isPattern) { if (inToken == USCORE) atPos(inSkipToken) { Bind(nme.WILDCARD.toTypeName, EmptyTree) } @@ -935,8 +942,8 @@ trait Parsers { def expr(): Tree = expr(Local) /** XXX: Hook for IDE */ - def expr(location: int): Tree = { - def isWildcard(t: Tree): boolean = t match { + def expr(location: Int): Tree = { + def isWildcard(t: Tree): Boolean = t match { case Ident(name1) if !placeholderParams.isEmpty && name1 == placeholderParams.head.name => true case Typed(t1, _) => isWildcard(t1) case Annotated(t1, _) => isWildcard(t1) @@ -1195,7 +1202,8 @@ trait Parsers { } simpleExprRest(t, canApply) } - def simpleExprRest(t: Tree, canApply: boolean): Tree = { + + def simpleExprRest(t: Tree, canApply: Boolean): Tree = { if (canApply) newLineOptWhenFollowedBy(LBRACE) inToken match { case DOT => @@ -1295,7 +1303,7 @@ trait Parsers { /** Generator ::= val Pattern1 `<-' Expr [Guard] */ - def generator(enums: ListBuffer[Enumerator], eqOK: boolean) { + def generator(enums: ListBuffer[Enumerator], eqOK: Boolean) { val pos = inCurrentPos; if (inToken == VAL) inNextToken val pat = pattern1(false) @@ -1314,7 +1322,7 @@ trait Parsers { * * (also eats trailing comma if it finds one) */ - def patterns(seqOK: boolean): List[Tree] = { + def patterns(seqOK: Boolean): List[Tree] = { val ts = new ListBuffer[Tree] + pattern(seqOK) while (inToken == COMMA) { inNextToken; @@ -1327,7 +1335,7 @@ trait Parsers { /** Pattern ::= Pattern1 { `|' Pattern1 } * SeqPattern ::= SeqPattern1 { `|' SeqPattern1 } */ - def pattern(seqOK: boolean): Tree = { + def pattern(seqOK: Boolean): Tree = { val pos = inCurrentPos val t = pattern1(seqOK) if (isIdent && inName == BAR) { @@ -1348,7 +1356,7 @@ trait Parsers { * | `_' `:' TypePat * | [SeqPattern2] */ - def pattern1(seqOK: boolean): Tree = { + def pattern1(seqOK: Boolean): Tree = { //if (false && /*disabled, no regexp matching*/ seqOK && !isExprIntro) { //atPos(inCurrentPos) { Sequence(List()) } //} else { @@ -1367,7 +1375,7 @@ trait Parsers { * SeqPattern2 ::= varid [ @ SeqPattern3 ] * | SeqPattern3 */ - def pattern2(seqOK: boolean): Tree = { + def pattern2(seqOK: Boolean): Tree = { val p = pattern3(seqOK) if (inToken == AT) { p match { @@ -1391,7 +1399,7 @@ trait Parsers { * SeqPattern3 ::= SeqSimplePattern [ '*' | '?' | '+' ] * | SeqSimplePattern {Id [nl] SeqSimplePattern} */ - def pattern3(seqOK: boolean): Tree = { + def pattern3(seqOK: Boolean): Tree = { val base = opstack var top = simplePattern(seqOK) if (seqOK && isIdent) { @@ -1429,7 +1437,7 @@ trait Parsers { * * XXX: Hook for IDE */ - def simplePattern(seqOK: boolean): Tree = inToken match { + def simplePattern(seqOK: Boolean): Tree = inToken match { case IDENTIFIER | BACKQUOTED_IDENT | THIS => var t = stableId() inToken match { @@ -1491,7 +1499,7 @@ trait Parsers { else mods - private def addMod(mods: Modifiers, mod: long): Modifiers = { + private def addMod(mods: Modifiers, mod: Long): Modifiers = { if (mods hasFlag mod) syntaxError(inCurrentPos, "repeated modifier", false) inNextToken mods | mod @@ -1653,7 +1661,7 @@ trait Parsers { * ClassParams ::= ClassParam {`,' ClassParam} * ClassParam ::= Annotations [{Modifier} (`val' | `var')] Id [`:' ParamType] */ - def paramClauses(owner: Name, implicitViews: List[Tree], ofCaseClass: boolean): List[List[ValDef]] = { + def paramClauses(owner: Name, implicitViews: List[Tree], ofCaseClass: Boolean): List[List[ValDef]] = { var implicitmod = 0 var caseParam = ofCaseClass def param(): ValDef = { @@ -1806,7 +1814,7 @@ trait Parsers { bound(SUPERTYPE, nme.Nothing), bound(SUBTYPE, nme.Any)) - def bound(tok: int, default: Name): Tree = + def bound(tok: Int, default: Name): Tree = if (inToken == tok) { inNextToken; placeholderTypeBoundary(typ()) } else scalaDot(default.toTypeName) @@ -1882,7 +1890,7 @@ trait Parsers { /** ImportSelector ::= Id [`=>' Id | `=>' `_'] */ - def importSelector(names: ListBuffer[(Name, Name)]): boolean = + def importSelector(names: ListBuffer[(Name, Name)]): Boolean = if (inToken == USCORE) { inNextToken; names += (nme.WILDCARD, null); true } else { @@ -2156,7 +2164,7 @@ trait Parsers { /** ClassParents ::= AnnotType {`(' [Exprs [`,']] `)'} {with AnnotType} * TraitParents ::= AnnotType {with AnnotType} */ - def templateParents(isTrait: boolean): (List[Tree], List[List[Tree]]) = { + def templateParents(isTrait: Boolean): (List[Tree], List[List[Tree]]) = { val parents = new ListBuffer[Tree] + placeholderTypeBoundary(annotType(false)) val argss = new ListBuffer[List[Tree]] if (inToken == LPAREN && !isTrait) @@ -2174,7 +2182,7 @@ trait Parsers { * EarlyDefs ::= `{' [EarlyDef {semi EarlyDef}] `}' * EarlyDef ::= Annotations Modifiers PatDef */ - def template(isTrait: boolean): (List[Tree], List[List[Tree]], ValDef, List[Tree]) = { + def template(isTrait: Boolean): (List[Tree], List[List[Tree]], ValDef, List[Tree]) = { newLineOptWhenFollowedBy(LBRACE) if (inToken == LBRACE) { val (self, body) = templateBody() @@ -2231,7 +2239,7 @@ trait Parsers { if (stats.isEmpty) (self, List(EmptyTree)) else result } - def templateBodyOpt(traitParentSeen: boolean): (ValDef, List[Tree]) = { + def templateBodyOpt(traitParentSeen: Boolean): (ValDef, List[Tree]) = { newLineOptWhenFollowedBy(LBRACE) if (inToken == LBRACE) { templateBody() diff --git a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala index 7f9a7e385c..057a15e651 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala @@ -102,7 +102,7 @@ abstract class SymbolicXMLBuilder(make: TreeBuilder, p: Parsers # Parser, preser * @todo map: a map of attributes !!! */ - protected def mkXML(pos: Position, isPattern: boolean, pre: Tree, label: Tree, attrs: /*Array[*/Tree/*]*/ , scope:Tree, children: mutable.Buffer[Tree]): Tree = { + protected def mkXML(pos: Position, isPattern: Boolean, pre: Tree, label: Tree, attrs: /*Array[*/Tree/*]*/ , scope:Tree, children: mutable.Buffer[Tree]): Tree = { if (isPattern) { convertToTextPat(children) atPos (pos) { //@todo maybe matching on attributes, scope? diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index 57e6607d5b..f8efc95c74 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -1,21 +1,21 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ package scala.tools.nsc.ast.parser -import scala.tools.nsc.util.Position import symtab.Flags._ import scala.collection.mutable.ListBuffer +import scala.tools.nsc.util.Position abstract class TreeBuilder { val global: Global import global._ import posAssigner.atPos; - def freshName(prefix: String, pos : Position): Name + def freshName(prefix: String, pos: Position): Name def freshName(pos : Position): Name = freshName("x$", pos) @@ -59,7 +59,7 @@ abstract class TreeBuilder { private object getvarTraverser extends Traverser { val buf = new ListBuffer[(Name, Tree)] def init: Traverser = { buf.clear; this } - override def traverse(tree: Tree): unit = tree match { + override def traverse(tree: Tree): Unit = tree match { case Bind(name, Typed(tree1, tpt)) => if ((name != nme.WILDCARD) && (buf.elements forall (name !=))) buf += (name, if (treeInfo.mayBeTypePat(tpt)) TypeTree() else tpt) @@ -81,18 +81,18 @@ abstract class TreeBuilder { getvarTraverser.buf.toList } - private def makeTuple(trees: List[Tree], isType: boolean): Tree = { + private def makeTuple(trees: List[Tree], isType: Boolean): Tree = { val tupString = "Tuple" + trees.length Apply(scalaDot(if (isType) newTypeName(tupString) else newTermName(tupString)), trees) } - def makeTupleTerm(trees: List[Tree], flattenUnary: boolean): Tree = trees match { + def makeTupleTerm(trees: List[Tree], flattenUnary: Boolean): Tree = trees match { case List() => Literal(()) case List(tree) if flattenUnary => tree case _ => makeTuple(trees, false) } - def makeTupleType(trees: List[Tree], flattenUnary: boolean): Tree = trees match { + def makeTupleType(trees: List[Tree], flattenUnary: Boolean): Tree = trees match { case List() => scalaUnitConstr case List(tree) if flattenUnary => tree case _ => AppliedTypeTree(scalaDot(newTypeName("Tuple" + trees.length)), trees) @@ -119,7 +119,7 @@ abstract class TreeBuilder { } /** Create tree representing (unencoded) binary operation expression or pattern. */ - def makeBinop(isExpr: boolean, left: Tree, op: Name, right: Tree): Tree = { + def makeBinop(isExpr: Boolean, left: Tree, op: Name, right: Tree): Tree = { val arguments = right match { case Parens(args) => args case _ => List(right) @@ -184,7 +184,7 @@ abstract class TreeBuilder { else Block(stats.init, stats.last) /** Create tree for for-comprehension generator <val pat0 <- rhs0> */ - def makeGenerator(pos: Position, pat: Tree, valeq: boolean, rhs: Tree): Enumerator = { + def makeGenerator(pos: Position, pat: Tree, valeq: Boolean, rhs: Tree): Enumerator = { val pat1 = patvarTransformer.transform(pat); val rhs1 = if (valeq) rhs @@ -368,14 +368,14 @@ abstract class TreeBuilder { makeAlternative(List(p, Sequence(List()))) /** Create visitor <x => x match cases> */ - def makeVisitor(cases: List[CaseDef], checkExhaustive: boolean): Tree = + def makeVisitor(cases: List[CaseDef], checkExhaustive: Boolean): Tree = makeVisitor(cases, checkExhaustive, "x$") private def makeUnchecked(expr: Tree): Tree = Annotated(Annotation(New(scalaDot(definitions.UncheckedClass.name), List(List())), List()), expr) /** Create visitor <x => x match cases> */ - def makeVisitor(cases: List[CaseDef], checkExhaustive: boolean, prefix: String): Tree = { + def makeVisitor(cases: List[CaseDef], checkExhaustive: Boolean, prefix: String): Tree = { val x = freshName(prefix, posAssigner.pos) val sel = if (checkExhaustive) Ident(x) else makeUnchecked(Ident(x)) Function(List(makeSyntheticParam(x)), Match(sel, cases)) diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 7430a6f2d5..612633bc62 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -261,7 +261,7 @@ trait Definitions { productType({val es = elems; if(useWildCards) elems map { x => WildcardType} else elems}) */ - def unapplyReturnTypeExpected(argsLength: int) = argsLength match { + def unapplyReturnTypeExpected(argsLength: Int) = argsLength match { case 0 => BooleanClass.tpe case 1 => optionType(WildcardType) case n => optionType(productType(List.range(0,n).map (arg => WildcardType))) @@ -290,7 +290,7 @@ trait Definitions { false } - def isCorrespondingDelegate(delegateType: Type, functionType: Type): boolean = { + def isCorrespondingDelegate(delegateType: Type, functionType: Type): Boolean = { var isCD: Boolean = false if (DelegateClass != null && delegateType != null && isSubType(delegateType, DelegateClass.tpe)) @@ -384,7 +384,7 @@ trait Definitions { result } - private def getModuleOrClass(fullname: Name, module: boolean): Symbol = { + private def getModuleOrClass(fullname: Name, module: Boolean): Symbol = { var sym = RootClass var i = 0 var j = fullname.pos('.', i) @@ -445,7 +445,7 @@ trait Definitions { private def newParameterlessMethod(owner: Symbol, name: Name, restpe: Type) = newMethod(owner, name).setInfo(PolyType(List(),restpe)) - private def newTypeParam(owner: Symbol, index: int): Symbol = + private def newTypeParam(owner: Symbol, index: Int): Symbol = owner.newTypeParameter(NoPosition, "T" + index) .setInfo(mkTypeBounds(AllClass.typeConstructor, AnyClass.typeConstructor)) @@ -476,9 +476,9 @@ trait Definitions { } val refClass = new HashMap[Symbol, Symbol] - private val abbrvTag = new HashMap[Symbol, char] + private val abbrvTag = new HashMap[Symbol, Char] - private def newValueClass(name: Name, tag: char): Symbol = { + private def newValueClass(name: Name, tag: Char): Symbol = { val boxedName = if (!forMSIL) "java.lang." + (name match { case nme.Boolean => "Boolean" @@ -643,7 +643,7 @@ trait Definitions { initValueClass(FloatClass, false) initValueClass(DoubleClass, false) } - def addModuleMethod(clazz: Symbol, name: Name, value: Any): Unit = { + def addModuleMethod(clazz: Symbol, name: Name, value: Any) { val owner = clazz.linkedClassOfClass newParameterlessMethod(owner, name, mkConstantType(Constant(value))) } @@ -676,18 +676,18 @@ trait Definitions { } /** Is symbol a value class? */ - def isValueClass(sym: Symbol): boolean = + def isValueClass(sym: Symbol): Boolean = (sym eq UnitClass) || (boxedClass contains sym) /** Is symbol a value class? */ - def isNumericValueClass(sym: Symbol): boolean = + def isNumericValueClass(sym: Symbol): Boolean = (sym ne BooleanClass) && (boxedClass contains sym) def isValueType(sym: Symbol) = isValueClass(sym) || unboxMethod.contains(sym) /** Is symbol a value or array class? */ - def isUnboxedClass(sym: Symbol): boolean = + def isUnboxedClass(sym: Symbol): Boolean = isValueType(sym) || sym == ArrayClass def signature(tp: Type): String = { @@ -696,7 +696,7 @@ trait Definitions { case RefinedType(parents, _) => erasure(parents.head) case _ => tp } - def flatNameString(sym: Symbol, separator: char): String = + def flatNameString(sym: Symbol, separator: Char): String = if (sym.owner.isPackageClass) sym.fullNameString('.') else flatNameString(sym.owner, separator) + "$" + sym.simpleName; def signature1(etp: Type): String = { diff --git a/src/compiler/scala/tools/nsc/symtab/Scopes.scala b/src/compiler/scala/tools/nsc/symtab/Scopes.scala index abf977fd3d..791ae7e9d4 100644 --- a/src/compiler/scala/tools/nsc/symtab/Scopes.scala +++ b/src/compiler/scala/tools/nsc/symtab/Scopes.scala @@ -121,7 +121,7 @@ trait Scopes { var s = 0 var e = elems while (e ne null) { - s = s + 1 + s += 1 e = e.next } s @@ -131,7 +131,7 @@ trait Scopes { * * @param e ... */ - def enter(e: ScopeEntry): unit = { + def enter(e: ScopeEntry) { elemsCache = null if (hashtable ne null) { val i = e.sym.name.start & HASHMASK @@ -146,7 +146,7 @@ trait Scopes { * * @param sym ... */ - def enter(sym: Symbol): unit = enter(newScopeEntry(sym, this)) + def enter(sym: Symbol) { enter(newScopeEntry(sym, this)) } /** enter a symbol, asserting that no symbol with same name exists in scope * diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index a56fe5e60d..0c0dbb96a8 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -79,7 +79,7 @@ trait StdNames { val INTERPRETER_IMPORT_WRAPPER = "$iw" def LOCAL(clazz: Symbol) = newTermName(LOCALDUMMY_PREFIX_STRING + clazz.name+">") - def TUPLE_FIELD(index: int) = newTermName(TUPLE_FIELD_PREFIX_STRING + index) + def TUPLE_FIELD(index: Int) = newTermName(TUPLE_FIELD_PREFIX_STRING + index) val LOCAL_SUFFIX = newTermName(" ") val SETTER_SUFFIX = encode("_=") @@ -101,10 +101,10 @@ trait StdNames { * @see Symbol.expandedName */ def originalName(name: Name): Name = { - var i = name.length; - while (i >= 2 && !(name(i - 1) == '$' && name(i - 2) == '$')) i = i - 1; + var i = name.length + while (i >= 2 && !(name(i - 1) == '$' && name(i - 2) == '$')) i -= 1 if (i >= 2) { - while (i >= 3 && name(i - 3) == '$') i = i - 1; + while (i >= 3 && name(i - 3) == '$') i -= 1 name.subName(i, name.length) } else name } @@ -131,7 +131,7 @@ trait StdNames { def getterName(name: Name): Name = if (isLocalName(name)) localToGetter(name) else name; - def isImplClassName(name: Name): boolean = + def isImplClassName(name: Name): Boolean = name endsWith IMPL_CLASS_SUFFIX; def implClassName(name: Name): Name = diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index 596d9619cf..5dd47ad8c3 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -363,7 +363,7 @@ trait Symbols { final def isContravariant: Boolean = isType && hasFlag(CONTRAVARIANT) /** The variance of this symbol as an integer */ - final def variance: int = + final def variance: Int = if (isCovariant) 1 else if (isContravariant) -1 else 0 diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index 88e630705a..615fc2c1c8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -1,12 +1,11 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ package scala.tools.nsc.typechecker -import scala.tools.nsc.reporters.AbstractReporter import scala.tools.nsc.symtab.Flags._ import scala.tools.nsc.util.{Position, NoPosition} @@ -16,12 +15,12 @@ abstract class TreeCheckers extends Analyzer { val tpeOfTree = new scala.collection.mutable.HashMap[Tree, Type] - def checkTrees: unit = { + def checkTrees { Console.println("[consistency check at start of phase " + phase + "]") - for (val unit <- currentRun.units) check(unit) + for (unit <- currentRun.units) check(unit) } - def check(unit: CompilationUnit): unit = { + def check(unit: CompilationUnit) { val context = rootContext(unit) context.checking = true tpeOfTree.clear @@ -67,7 +66,7 @@ abstract class TreeCheckers extends Analyzer { } object precheck extends Traverser { - override def traverse(tree: Tree): unit = + override def traverse(tree: Tree) { try { tree match { case DefDef(_, _, _, _, _, _) => @@ -121,10 +120,11 @@ abstract class TreeCheckers extends Analyzer { Console.println("exception when traversing " + tree); throw(ex) } + } } object postcheck extends Traverser { - override def traverse(tree: Tree): unit = + override def traverse(tree: Tree) { try { tree match { case EmptyTree | TypeTree() => @@ -146,6 +146,7 @@ abstract class TreeCheckers extends Analyzer { Console.println("exception when traversing " + tree); throw(ex) } + } } } } |