diff options
author | Martin Odersky <odersky@gmail.com> | 2006-03-09 17:50:10 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2006-03-09 17:50:10 +0000 |
commit | 0bef86d8e8b7ea7ebb790ebcec7fedcb9a24f5a8 (patch) | |
tree | a85a3276240467ad4994ae8f78174371e2a30ad1 /src | |
parent | c0c963afaf40b85914eff3497e116763268e6aa7 (diff) | |
download | scala-0bef86d8e8b7ea7ebb790ebcec7fedcb9a24f5a8.tar.gz scala-0bef86d8e8b7ea7ebb790ebcec7fedcb9a24f5a8.tar.bz2 scala-0bef86d8e8b7ea7ebb790ebcec7fedcb9a24f5a8.zip |
performed some renamings in the compiler & library
All -> Bottom
AllRef -> Null
mixin class -> trait
Diffstat (limited to 'src')
79 files changed, 160 insertions, 183 deletions
diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala index 30a4e77064..d22e3abfa5 100644 --- a/src/compiler/scala/tools/nsc/CompilationUnits.scala +++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala @@ -10,7 +10,7 @@ import scala.tools.nsc.util.FreshNameCreator; import scala.tools.util.AbstractFile; import scala.collection.mutable.HashSet; -mixin class CompilationUnits requires Global { +trait CompilationUnits requires Global { class CompilationUnit(val source: SourceFile, val mixinOnly: boolean) { diff --git a/src/compiler/scala/tools/nsc/EvalLoop.scala b/src/compiler/scala/tools/nsc/EvalLoop.scala index fc6c30f27a..12e9fdeb18 100644 --- a/src/compiler/scala/tools/nsc/EvalLoop.scala +++ b/src/compiler/scala/tools/nsc/EvalLoop.scala @@ -1,6 +1,6 @@ package scala.tools.nsc; -mixin class EvalLoop { +trait EvalLoop { def prompt: String; diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala index d0ccc76479..3477a84f03 100644 --- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala @@ -118,9 +118,9 @@ abstract class TreePrinters { case ClassDef(mods, name, tparams, tp, impl) => printAttributes(tree.symbol.attributes); printModifiers(tree, mods); - print("class " + symName(tree, name)); + print((if (mods hasFlag TRAIT) "trait " else "class ") + symName(tree, name)); printTypeParams(tparams); - printOpt(": ", tp); print(" extends "); print(impl); + printOpt("requires ", tp); print(" extends "); print(impl); case PackageDef(packaged, stats) => print("package "); print(packaged); printColumn(stats, " {", ";", "}") diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index e95d41bdd6..763e53d606 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -12,7 +12,7 @@ import scala.tools.nsc.util.{Position,SourceFile}; import symtab.Flags._; -mixin class Trees requires Global { +trait Trees requires Global { //statistics var nodeCount = 0; @@ -27,7 +27,7 @@ mixin class Trees requires Global { def isCase = ((flags & CASE ) != 0); def isSealed = ((flags & SEALED) != 0); def isFinal = ((flags & FINAL ) != 0); - def isMixin = ((flags & MIXIN ) != 0); + def isTrait = ((flags & TRAIT ) != 0); def isPublic = !isPrivate && !isProtected; def hasFlag(flag: int) = (flags & flag) != 0; def | (flag: int): Modifiers = { @@ -90,7 +90,7 @@ mixin class Trees requires Global { } } - mixin class SymTree extends Tree { + trait SymTree extends Tree { override def hasSymbol = true; override var symbol: Symbol = NoSymbol; } @@ -100,11 +100,11 @@ mixin class Trees requires Global { override def isDef = true; } - mixin class TermTree extends Tree { + trait TermTree extends Tree { override def isTerm = true } - mixin class TypTree extends Tree { + trait TypTree extends Tree { override def isType = true } diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index a74d6d4ba1..252288f750 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -11,7 +11,7 @@ import scala.tools.nsc.util.Position; import scala.xml.{Text,TextBuffer}; -mixin class MarkupParsers requires SyntaxAnalyzer { +trait MarkupParsers requires SyntaxAnalyzer { import global._ ; import posAssigner.atPos; diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index c02d59ce86..fe2eebb66a 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -38,7 +38,7 @@ import Tokens._; * (4) Wraps naked case definitions in a match as follows: * { cases } ==> (x => x.match {cases}), except when already argument to match */ -mixin class Parsers requires SyntaxAnalyzer { +trait Parsers requires SyntaxAnalyzer { import global._; import posAssigner.atPos; @@ -157,7 +157,7 @@ mixin class Parsers requires SyntaxAnalyzer { def isDefIntro: boolean = in.token match { case VAL | VAR | DEF | TYPE | OBJECT | - CASEOBJECT | CLASS | CASECLASS | MIXIN | TRAIT => true + CASEOBJECT | CLASS | CASECLASS | TRAIT => true case _ => false } @@ -324,8 +324,7 @@ mixin class Parsers requires SyntaxAnalyzer { in.nextToken(); name } else { - if (settings.migrate.value && - in.token == REQUIRES || in.token == IMPLICIT || in.token == MIXIN) + if (settings.migrate.value && in.token == REQUIRES || in.token == IMPLICIT) syntaxErrorMigrate(""+in+" is now a reserved word; cannot be used as identifier"); accept(IDENTIFIER); nme.ERROR @@ -852,7 +851,7 @@ mixin class Parsers requires SyntaxAnalyzer { if (settings.migrate.value) { if (in.token == MATCH) syntaxErrorMigrate("`match' must be preceded by a selector expression") - else if (in.token == REQUIRES || in.token == IMPLICIT || in.token == MIXIN) + else if (in.token == REQUIRES || in.token == IMPLICIT) syntaxErrorMigrate(""+in+" is now a reserved word; cannot be used as identifier"); } syntaxError("illegal start of simple expression", true); @@ -1101,7 +1100,7 @@ mixin class Parsers requires SyntaxAnalyzer { r case _ => if (settings.migrate.value && - in.token == REQUIRES || in.token == IMPLICIT || in.token == MIXIN) + in.token == REQUIRES || in.token == IMPLICIT) syntaxErrorMigrate(""+in+" is now a reserved word; cannot be used as identifier"); syntaxError("illegal start of simple pattern", true); errorPatternTree @@ -1575,15 +1574,11 @@ mixin class Parsers requires SyntaxAnalyzer { /** TmplDef ::= [case] class ClassDef * | [case] object ObjectDef - * | ([mixin class | trait]) MixinClassDef + * | trait MixinClassDef */ def tmplDef(mods: Modifiers): Tree = in.token match { case TRAIT => - classDef(mods | Flags.MIXIN | Flags.ABSTRACT); - case MIXIN => - in.nextToken(); - if (in.token != CLASS) accept(CLASS); - classDef(mods | Flags.MIXIN | Flags.ABSTRACT); + classDef(mods | Flags.TRAIT | Flags.ABSTRACT); case CLASS => classDef(mods); case CASECLASS => @@ -1609,7 +1604,7 @@ mixin class Parsers requires SyntaxAnalyzer { val vparamss = paramClauses(name, implicitViews.toList, mods.hasFlag(Flags.CASE)); val thistpe = requiresTypeOpt(); val template = classTemplate(mods, name, vparamss); - val mods1 = if (mods.hasFlag(Flags.MIXIN) && (template.body forall treeInfo.isInterfaceMember)) + val mods1 = if (mods.hasFlag(Flags.TRAIT) && (template.body forall treeInfo.isInterfaceMember)) mods | Flags.INTERFACE else mods; ClassDef(mods1, name, tparams, thistpe, template) @@ -1666,7 +1661,7 @@ mixin class Parsers requires SyntaxAnalyzer { var body = if (in.token == LBRACE) templateBody() else { acceptEmptyTemplateBody("`{' expected"); List() } - if (!mods.hasFlag(Flags.MIXIN)) Template(ps, vparamss, argss.toList, body) + if (!mods.hasFlag(Flags.TRAIT)) Template(ps, vparamss, argss.toList, body) else Template(ps, body) } @@ -1721,7 +1716,6 @@ mixin class Parsers requires SyntaxAnalyzer { } else if (in.token == CLASS || in.token == CASECLASS || in.token == TRAIT || - in.token == MIXIN || in.token == OBJECT || in.token == CASEOBJECT || in.token == LBRACKET || @@ -1800,7 +1794,7 @@ mixin class Parsers requires SyntaxAnalyzer { case _ => false } - if (attrs exists isMixinAttribute) Flags.MIXIN else 0 + if (attrs exists isMixinAttribute) Flags.TRAIT else 0 } def joinAttributes(attrs: List[Tree], defs: List[Tree]): List[Tree] = diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 1266252ffd..a38153f28c 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -10,7 +10,7 @@ import scala.tools.nsc.util.{Position, SourceFile} import SourceFile.{LF, FF, CR, SU} import scala.tools.nsc.util.CharArrayReader -mixin class Scanners requires SyntaxAnalyzer { +trait Scanners requires SyntaxAnalyzer { import global._ @@ -167,6 +167,13 @@ mixin class Scanners requires SyntaxAnalyzer { next.copyFrom(this) this.copyFrom(prev) } + } else if (token == IDENTIFIER && name == nme.MIXINkw) { //todo: remove eventually + prev.copyFrom(this); + fetchToken(); + if (token == CLASS) + unit.warning(pos, "`mixin' is no longer a reserved word; you should use `trait' instead of `mixin class'"); + next.copyFrom(this) + this.copyFrom(prev) } if (afterLineEnd() && inLastOfStat(lastToken) && inFirstOfStat(token) && @@ -786,7 +793,6 @@ mixin class Scanners requires SyntaxAnalyzer { enterKeyword(nme.IMPLICITkw, IMPLICIT) enterKeyword(nme.IMPORTkw, IMPORT) enterKeyword(nme.MATCHkw, MATCH) - enterKeyword(nme.MIXINkw, MIXIN) enterKeyword(nme.NEWkw, NEW) enterKeyword(nme.NULLkw, NULL) enterKeyword(nme.OBJECTkw, OBJECT) diff --git a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala index 2f07497ede..b99ee08811 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala @@ -67,7 +67,6 @@ object Tokens { final val RETURN = 57; final val MATCH = 58; final val REQUIRES = 59; - final val MIXIN = 60; /** special symbols */ final val COMMA = 61; diff --git a/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala b/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala index 3a13767900..d6b81a84fe 100644 --- a/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala +++ b/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala @@ -22,7 +22,7 @@ import scala.collection.mutable.MutableList; * * @see scala.tools.nsc.backend.icode.Linearizers */ -mixin class WorklistAlgorithm { +trait WorklistAlgorithm { type Elem; type WList <: MutableList[Elem]; diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index aa42da4273..0c9d6dc2c3 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -11,7 +11,7 @@ import scala.tools.nsc.ast._; import scala.collection.mutable.Map; import scala.tools.nsc.util.Position; -mixin class BasicBlocks requires ICodes { +trait BasicBlocks requires ICodes { import opcodes._; /** This class represents a basic block. Each diff --git a/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala index 1e80d0eac0..aa20ecb932 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala @@ -17,7 +17,7 @@ import scala.collection.mutable.HashSet; * all our handlers will catch `Throwable' and rely on proper ordering * in the generated code to preserve nesting. */ -mixin class ExceptionHandlers requires ICodes { +trait ExceptionHandlers requires ICodes { import global.{Symbol, NoSymbol}; class ExceptionHandler(val method: IMethod, label: String, val cls: Symbol) { diff --git a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala index c0b6ada3c3..ff4a2d4a0a 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala @@ -10,7 +10,7 @@ package scala.tools.nsc.backend.icode; import scala.tools.nsc.ast._; import scala.collection.mutable.{Stack, HashSet}; -mixin class Linearizers requires ICodes { +trait Linearizers requires ICodes { import opcodes._; abstract class Linearizer { diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index 02af695f37..e9e6445185 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -13,7 +13,7 @@ import scala.{Symbol => scala_Symbol}; import scala.tools.nsc.symtab.Flags; -mixin class Members requires ICodes { +trait Members requires ICodes { import global._; /** diff --git a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala index 57fa0ff327..912358762c 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala @@ -48,7 +48,7 @@ import scala.tools.nsc.util.Position; * erased types of Scala and references Symbols to refer named entities * in the source files. */ -mixin class Opcodes requires ICodes { +trait Opcodes requires ICodes { import global.{Symbol, NoSymbol, Type, Name, Constant}; /** This class represents an instruction of the intermediate code. diff --git a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala index b134819853..c07b7b0829 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala @@ -9,7 +9,7 @@ package scala.tools.nsc.backend.icode; import java.io.PrintWriter; -mixin class Primitives requires ICodes { +trait Primitives requires ICodes { /** This class represents a primitive operation. */ class Primitive { diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala index 362aeb9100..ce2895c8c7 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala @@ -25,7 +25,7 @@ package scala.tools.nsc.backend.icode; import scala.collection.mutable.{Map, HashMap}; -mixin class TypeKinds requires ICodes { +trait TypeKinds requires ICodes { import global._; /** This class represents a type kind. Type kinds diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala index 6aa8507c57..69f1f34cb7 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala @@ -9,7 +9,7 @@ package scala.tools.nsc.backend.icode; import scala.tools.nsc.backend.icode.Primitives; -mixin class TypeStacks requires ICodes { +trait TypeStacks requires ICodes { import opcodes._; import global.{Symbol, Type, definitions}; diff --git a/src/compiler/scala/tools/nsc/doc/DocUtil.scala b/src/compiler/scala/tools/nsc/doc/DocUtil.scala index c88b1cac35..e7a0d6cf88 100644 --- a/src/compiler/scala/tools/nsc/doc/DocUtil.scala +++ b/src/compiler/scala/tools/nsc/doc/DocUtil.scala @@ -26,7 +26,7 @@ object DocUtil { nodes.concat(x) } - mixin class UrlContext { + trait UrlContext { def relative: String def aref(href0: String, target: String, text: String): NodeSeq = { diff --git a/src/compiler/scala/tools/nsc/models/Models.scala b/src/compiler/scala/tools/nsc/models/Models.scala index f89e2da145..65eb769d67 100644 --- a/src/compiler/scala/tools/nsc/models/Models.scala +++ b/src/compiler/scala/tools/nsc/models/Models.scala @@ -47,7 +47,7 @@ abstract class Models { if (mods . isCase ) modString = "case" :: modString; if (mods . isSealed ) modString = "sealed" :: modString; if (mods . isFinal ) modString = "final" :: modString; - if (mods . isMixin ) modString = "mixin" :: modString; + if (mods . isTrait ) modString = "mixin" :: modString; modString; } @@ -161,7 +161,7 @@ abstract class Models { def treex = tree.asInstanceOf[PackageDef]; } - mixin class Composite extends Model { + trait Composite extends Model { import scala.collection.mutable._; @@ -245,7 +245,7 @@ abstract class Models { } abstract class MemberComposite(parent0: Composite) extends MemberMod(parent0) with Composite; - mixin class HasClassObjects extends Composite { + trait HasClassObjects extends Composite { override def isMember(tree : Tree) : Boolean = (super.isMember(tree) || (tree.isInstanceOf[ImplDef])); } diff --git a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala index ef8f60e6c8..c345226633 100644 --- a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala +++ b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala @@ -50,12 +50,12 @@ class SemanticTokens(val compiler: Global) { else pos; } - mixin class HasNext extends Token { + trait HasNext extends Token { var next0: HasPrev = _; def next = next0; } - mixin class HasPrev extends Token { + trait HasPrev extends Token { var prev0: HasNext = _; def prev = prev0; } diff --git a/src/compiler/scala/tools/nsc/symtab/Constants.scala b/src/compiler/scala/tools/nsc/symtab/Constants.scala index 48a0c0bdf0..263a02a46a 100644 --- a/src/compiler/scala/tools/nsc/symtab/Constants.scala +++ b/src/compiler/scala/tools/nsc/symtab/Constants.scala @@ -9,7 +9,7 @@ package scala.tools.nsc.symtab; import classfile.PickleFormat._; -mixin class Constants requires SymbolTable { +trait Constants requires SymbolTable { import definitions._; diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 4d2c3466f9..81a9448ddd 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -9,7 +9,7 @@ import scala.tools.nsc.util.Position; import collection.mutable.HashMap; import Flags._; -mixin class Definitions requires SymbolTable { +trait Definitions requires SymbolTable { object definitions { def isDefinitionsInitialized = isInitialized; @@ -318,10 +318,10 @@ mixin class Definitions requires SymbolTable { AnyRefClass = newAlias(ScalaPackageClass, "AnyRef", ObjectClass.typeConstructor); AllRefClass = newClass(ScalaPackageClass, "AllRef", List(AnyRefClass.typeConstructor)) - .setFlag(ABSTRACT | MIXIN | FINAL); + .setFlag(ABSTRACT | TRAIT | FINAL); AllClass = newClass(ScalaPackageClass, "All", List(AnyClass.typeConstructor)) - .setFlag(ABSTRACT | MIXIN | FINAL); + .setFlag(ABSTRACT | TRAIT | FINAL); StringClass = getClass("java.lang.String"); ThrowableClass = getClass("java.lang.Throwable"); diff --git a/src/compiler/scala/tools/nsc/symtab/Flags.scala b/src/compiler/scala/tools/nsc/symtab/Flags.scala index 2c9bc04b69..d54a12159b 100644 --- a/src/compiler/scala/tools/nsc/symtab/Flags.scala +++ b/src/compiler/scala/tools/nsc/symtab/Flags.scala @@ -48,7 +48,7 @@ object Flags { final val STATIC = 0x00800000; // static field, method or class final val CASEACCESSOR = 0x01000000; // symbol is a case parameter (or its accessor) - final val MIXIN = 0x02000000; // symbol is a mixin class + final val TRAIT = 0x02000000; // symbol is a trait final val BRIDGE = 0x04000000; // function is a bridge method. Set by Erasure final val ACCESSOR = 0x08000000; // a value or variable accessor @@ -99,8 +99,8 @@ object Flags { final val TopLevelCreationFlags = MODULE | PACKAGE | FINAL | JAVA; - final val ExplicitFlags = // these modifiers can be set explicitly in source programs. - PRIVATE | PROTECTED | ABSTRACT | MIXIN | FINAL | SEALED | OVERRIDE | CASE | IMPLICIT | ABSOVERRIDE; + final val ExplicitFlags = // these modifiers can be set explicitly in source programs. + PRIVATE | PROTECTED | ABSTRACT | FINAL | SEALED | OVERRIDE | CASE | IMPLICIT | ABSOVERRIDE; final val PrintableFlags = // these modifiers appear in TreePrinter output. (ExplicitFlags | LOCAL | SYNTHETIC | STABLE | CASEACCESSOR | ACCESSOR | @@ -161,7 +161,7 @@ object Flags { case STATIC => "<static>" case CASEACCESSOR => "<caseaccessor>" - case MIXIN => "mixin" + case TRAIT => "<trait>" case BRIDGE => "<bridge>" case ACCESSOR => "<accessor>" diff --git a/src/compiler/scala/tools/nsc/symtab/InfoTransformers.scala b/src/compiler/scala/tools/nsc/symtab/InfoTransformers.scala index 87f4ba7b12..bf01d4419a 100644 --- a/src/compiler/scala/tools/nsc/symtab/InfoTransformers.scala +++ b/src/compiler/scala/tools/nsc/symtab/InfoTransformers.scala @@ -5,7 +5,7 @@ // $Id$ package scala.tools.nsc.symtab; -mixin class InfoTransformers requires SymbolTable { +trait InfoTransformers requires SymbolTable { abstract class InfoTransformer { var prev: InfoTransformer = this; diff --git a/src/compiler/scala/tools/nsc/symtab/Scopes.scala b/src/compiler/scala/tools/nsc/symtab/Scopes.scala index 921d9f9cc0..a0f577c9a5 100644 --- a/src/compiler/scala/tools/nsc/symtab/Scopes.scala +++ b/src/compiler/scala/tools/nsc/symtab/Scopes.scala @@ -5,7 +5,7 @@ // $Id$ package scala.tools.nsc.symtab; -mixin class Scopes requires SymbolTable { +trait Scopes requires SymbolTable { class ScopeEntry(val sym: Symbol, val owner: Scope) { diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index 3bf7478a49..17f94dee33 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -7,7 +7,7 @@ package scala.tools.nsc.symtab; import scala.tools.nsc.util.NameTransformer; -mixin class StdNames requires SymbolTable { +trait StdNames requires SymbolTable { object nme { diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index ea85974721..a327a0e053 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -10,7 +10,7 @@ import scala.tools.util.AbstractFile; import scala.tools.nsc.util.{Position, SourceFile}; import Flags._; -mixin class Symbols requires SymbolTable { +trait Symbols requires SymbolTable { import definitions._; private var ids = 0; @@ -174,7 +174,7 @@ mixin class Symbols requires SymbolTable { final def isThisSym = isTerm && name == nme.this_; final def isThisSkolem = isTerm && deSkolemize != this; final def isError = hasFlag(IS_ERROR); - final def isMixin = isClass & hasFlag(MIXIN); + final def isTrait = isClass & hasFlag(TRAIT); final def isAliasType = isType && !isClass && !hasFlag(DEFERRED); final def isAbstractType = isType && !isClass && hasFlag(DEFERRED); final def isTypeParameterOrSkolem = isType && hasFlag(PARAM); @@ -202,11 +202,11 @@ mixin class Symbols requires SymbolTable { final def isImplClass: boolean = isClass && hasFlag(IMPLCLASS); final def needsImplClass: boolean = - isMixin && (!hasFlag(INTERFACE) || hasFlag(lateINTERFACE)) && !isImplClass; + isTrait && (!hasFlag(INTERFACE) || hasFlag(lateINTERFACE)) && !isImplClass; final def isImplOnly: boolean = ( hasFlag(PRIVATE) || - (owner.isImplClass || owner.isMixin) && + (owner.isImplClass || owner.isTrait) && (hasFlag(notPRIVATE | LIFTED) && !hasFlag(ACCESSOR | SUPERACCESSOR) || isConstructor) ); @@ -532,7 +532,7 @@ mixin class Symbols requires SymbolTable { /** The primary constructor of a class */ def primaryConstructor: Symbol = { - val c = info.decl(if (isMixin || isImplClass) nme.MIXIN_CONSTRUCTOR else nme.CONSTRUCTOR); + val c = info.decl(if (isTrait || isImplClass) nme.MIXIN_CONSTRUCTOR else nme.CONSTRUCTOR); if (c hasFlag OVERLOADED) c.alternatives.head else c } @@ -709,7 +709,8 @@ mixin class Symbols requires SymbolTable { /** String representation of symbol's definition key word */ final def keyString: String = - if (isMixin && hasFlag(JAVA)) "interface" + if (isTrait && hasFlag(JAVA)) "interface" + else if (isTrait) "trait" else if (isClass) "class" else if (isType && !hasFlag(PARAM)) "type" else if (isVariable) "var" @@ -726,6 +727,7 @@ mixin class Symbols requires SymbolTable { else if (isAnonymousClass) "<template>" else if (isRefinementClass) "" else if (isModuleClass) "singleton class" + else if (isTrait) "trait" else if (isClass) "class" else if (isType) "type" else if (isVariable) "variable" diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 2b4be691c9..2ddb95018c 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -30,7 +30,7 @@ import Flags._; case TypeVar(_, _) => */ -mixin class Types requires SymbolTable { +trait Types requires SymbolTable { import definitions._; //statistics @@ -425,7 +425,7 @@ mixin class Types requires SymbolTable { // Subclasses ------------------------------------------------------------ - mixin class UniqueType { + trait UniqueType { private val hashcode = { val h = super.hashCode(); if (h < 0) -h else h } override def hashCode() = hashcode; } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 29360f3ab1..4b7fe373c2 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -604,7 +604,7 @@ abstract class ClassfileParser { if ((flags & JAVA_ACC_FINAL) != 0) res = res | FINAL; if ((flags & JAVA_ACC_INTERFACE) != 0) - res = res | MIXIN | INTERFACE | ABSTRACT; + res = res | TRAIT | INTERFACE | ABSTRACT; if ((flags & JAVA_ACC_SYNTHETIC) != 0) res = res | SYNTHETIC; if ((flags & JAVA_ACC_STATIC) != 0) diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index e6110d3976..1e4be38767 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -115,7 +115,7 @@ abstract class AddInterfaces extends InfoTransform { val parents1 = if (parents.isEmpty) List() else { - assert(!parents.head.symbol.isMixin || clazz == RepeatedParamClass, clazz); + assert(!parents.head.symbol.isTrait || clazz == RepeatedParamClass, clazz); if (clazz hasFlag INTERFACE) erasedTypeRef(ObjectClass) :: parents.tail else if (clazz.isImplClass || clazz == ArrayClass) parents else parents map mixinToImplClass diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 68dfc794f4..ea474a68bb 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -529,7 +529,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { */ def addBridges(stats: List[Tree], base: Symbol): List[Tree] = - if (base.isMixin) stats + if (base.isTrait) stats else { val bridges = bridgeDefs(base); if (bridges.isEmpty) stats else stats ::: bridges diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index bb9b34d177..4f71be7b62 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -39,9 +39,9 @@ abstract class ExplicitOuter extends InfoTransform { def transformInfo(sym: Symbol, tp: Type): Type = tp match { case MethodType(formals, restpe) => //todo: needed? - if (sym.owner.isMixin && (sym hasFlag SUPERACCESSOR)) + if (sym.owner.isTrait && (sym hasFlag SUPERACCESSOR)) sym.makeNotPrivate(sym.owner); - if (sym.owner.isMixin && (sym hasFlag PROTECTED)) sym setFlag notPROTECTED; + if (sym.owner.isTrait && (sym hasFlag PROTECTED)) sym setFlag notPROTECTED; if (sym.isConstructor && !isStatic(sym.owner)) MethodType(formals ::: List(outerClass(sym.owner).toInterface.thisType), restpe) else tp; @@ -51,7 +51,7 @@ abstract class ExplicitOuter extends InfoTransform { if (!isStatic(clazz)) { decls1 = new Scope(decls1.toList); val outerAcc = clazz.newMethod(clazz.pos, nme.OUTER); - if (clazz.isMixin || (decls.toList exists (.isClass))) + if (clazz.isTrait || (decls.toList exists (.isClass))) outerAcc.expandName(clazz); decls1 enter ( outerAcc setFlag (PARAMACCESSOR | ACCESSOR | STABLE) @@ -60,7 +60,7 @@ abstract class ExplicitOuter extends InfoTransform { setFlag (LOCAL | PRIVATE | PARAMACCESSOR | (outerAcc getFlag EXPANDEDNAME)) setInfo outerClass(clazz).thisType); } - if (clazz.isMixin) { + if (clazz.isTrait) { decls1 = new Scope(decls1.toList); decls1 enter makeMixinConstructor(clazz); } @@ -258,7 +258,7 @@ abstract class ExplicitOuter extends InfoTransform { if (!(currentOwner hasFlag INTERFACE) || (currentOwner hasFlag lateINTERFACE)) { if (!isStatic(currentOwner)) decls1 = decls1 ::: outerDefs(currentOwner); // (1) - if (currentOwner.isMixin) + if (currentOwner.isTrait) decls1 = decls1 ::: List(mixinConstructorDef(currentOwner)) // (2) } localTyper = savedLocalTyper; @@ -327,7 +327,7 @@ abstract class ExplicitOuter extends InfoTransform { val tree1 = super.transform(tree); tree1 match { case DefDef(_, _, _, _, _, _) => - if (sym.owner.isMixin && (sym hasFlag (ACCESSOR | SUPERACCESSOR))) + if (sym.owner.isTrait && (sym hasFlag (ACCESSOR | SUPERACCESSOR))) sym.makeNotPrivate(sym.owner); //(2) tree1 case Select(qual, name) => diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index 8ad57a5bad..0802e00359 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -101,7 +101,7 @@ abstract class Mixin extends InfoTransform { def addMixedinMembers(clazz: Symbol): unit = { if (!(clazz hasFlag MIXEDIN) && (clazz != ObjectClass)) { - assert(!clazz.isMixin, clazz); + assert(!clazz.isTrait, clazz); clazz setFlag MIXEDIN; assert(!clazz.info.parents.isEmpty, clazz); val superclazz = clazz.info.parents.head.symbol; @@ -216,7 +216,7 @@ abstract class Mixin extends InfoTransform { case Template(parents, body) => localTyper = erasure.newTyper(rootContext.make(tree, currentOwner)); atPhase(phase.next)(currentOwner.owner.info);//needed? - if (!currentOwner.isMixin) addMixedinMembers(currentOwner) + if (!currentOwner.isTrait) addMixedinMembers(currentOwner) else if (currentOwner hasFlag lateINTERFACE) addLateInterfaceMembers(currentOwner); tree case DefDef(mods, name, tparams, List(vparams), tpt, rhs) if currentOwner.isImplClass => @@ -300,7 +300,7 @@ abstract class Mixin extends InfoTransform { if (sym hasFlag MIXEDIN) { if (clazz hasFlag lateINTERFACE) { addDefDef(sym, vparamss => EmptyTree) - } else if (!clazz.isMixin) { + } else if (!clazz.isTrait) { if (sym hasFlag ACCESSOR) { addDefDef(sym, vparams => { val accessedRef = sym.tpe match { @@ -325,7 +325,7 @@ abstract class Mixin extends InfoTransform { } } val stats1 = add(stats, newDefs.toList); - if (clazz.isMixin) stats1 else stats1 map completeSuperAccessor; + if (clazz.isTrait) stats1 else stats1 map completeSuperAccessor; } private def postTransform(tree: Tree): Tree = { diff --git a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala index ed7382dc8a..ed76cb6b91 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala @@ -7,7 +7,7 @@ package scala.tools.nsc.typechecker; /** The main attribution phase. */ -mixin class Analyzer +trait Analyzer extends AnyRef with Contexts with Namers diff --git a/src/compiler/scala/tools/nsc/typechecker/Codification.scala b/src/compiler/scala/tools/nsc/typechecker/Codification.scala index b7383fce5b..6a802d7c31 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Codification.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Codification.scala @@ -11,7 +11,7 @@ import scala.collection.immutable.ListMap; import scala.collection.mutable.ListBuffer; import scala.tools.nsc.util.FreshNameCreator; -mixin class Codification requires Analyzer { +trait Codification requires Analyzer { import global._; diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index ba35ebbb4b..0da9ee6177 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -8,7 +8,7 @@ package scala.tools.nsc.typechecker; import symtab.Flags._; import scala.tools.nsc.util.Position; -mixin class Contexts requires Analyzer { +trait Contexts requires Analyzer { import global._; val NoContext = new Context { diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala index 28bbff53c2..de70ccf5a7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala +++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala @@ -8,7 +8,7 @@ package scala.tools.nsc.typechecker; import scala.collection.mutable.ListBuffer; import symtab.Flags._; -mixin class EtaExpansion requires Analyzer { +trait EtaExpansion requires Analyzer { import global._; import posAssigner.atPos; diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 467b7b7465..1004b4b67d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -8,7 +8,7 @@ package scala.tools.nsc.typechecker; import scala.collection.mutable.ListBuffer; import symtab.Flags._; -mixin class Infer requires Analyzer { +trait Infer requires Analyzer { import global._; import definitions._; import posAssigner.atPos; diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 8668afae91..1b191da676 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -10,7 +10,7 @@ import symtab.Flags; import symtab.Flags._; /** Methods to create symbols and to enter them into scopes. */ -mixin class Namers requires Analyzer { +trait Namers requires Analyzer { import global._; import definitions._; @@ -544,15 +544,13 @@ mixin class Namers requires Analyzer { Flags.flagsToString(flag1) + " and " + Flags.flagsToString(flag2)); if (sym.hasFlag(IMPLICIT) && !sym.isTerm) context.error(sym.pos, "`implicit' modifier can be used only for values, variables and methods"); - if (sym.hasFlag(MIXIN) && !sym.isClass) - context.error(sym.pos, "`mixin' modifier can be used only for classes"); if (sym.hasFlag(ABSTRACT) && !sym.isClass) context.error(sym.pos, "`abstract' modifier can be used only for classes; " + "\nit should be omitted for abstract members"); if (sym.hasFlag(OVERRIDE | ABSOVERRIDE) && sym.isClass) context.error(sym.pos, "`override' modifier not allowed for classes"); - if (sym.hasFlag(ABSOVERRIDE) && !sym.owner.isMixin) - context.error(sym.pos, "`abstract override' modifier only allowed for members of mixin classes"); + if (sym.hasFlag(ABSOVERRIDE) && !sym.owner.isTrait) + context.error(sym.pos, "`abstract override' modifier only allowed for members of traits"); if (sym.info.symbol == FunctionClass(0) && sym.isValueParameter && sym.owner.isClass && sym.owner.hasFlag(CASE)) context.error(sym.pos, "pass-by-name arguments not allowed for case class parameters"); diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 5af2caf977..41cfdf30bf 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -230,7 +230,7 @@ abstract class RefChecks extends InfoTransform { } */ // 2. Check that only abstract classes have deferred members - if (clazz.isClass && !clazz.isMixin) { + if (clazz.isClass && !clazz.isTrait) { def abstractClassError(mustBeMixin: boolean, msg: String): unit = { unit.error(clazz.pos, (if (clazz.isAnonymousClass || clazz.isModuleClass) "object creation impossible" @@ -464,12 +464,12 @@ abstract class RefChecks extends InfoTransform { val ddef = atPhase(phase.next) { localTyper.typed { - if (sym.owner.isMixin) newModuleAccessDcl(sym) + if (sym.owner.isTrait) newModuleAccessDcl(sym) else newModuleAccessDef(sym, vdef.symbol) } } - if (sym.owner.isMixin) transformTrees(List(cdef, ddef)) + if (sym.owner.isTrait) transformTrees(List(cdef, ddef)) else transformTrees(List(cdef, vdef, ddef)) } @@ -597,7 +597,7 @@ abstract class RefChecks extends InfoTransform { unit.error(tree.pos, "symbol accessed from super may not be abstract"); } //System.out.println("super: " + tree + " in " + base);//DEBUG - if (base.isMixin && sym.isTerm && mix == nme.EMPTY.toTypeName) { + if (base.isTrait && sym.isTerm && mix == nme.EMPTY.toTypeName) { val superAccName = nme.superName(sym.name); val superAcc = base.info.decl(superAccName) suchThat (.alias.==(sym)); assert(superAcc != NoSymbol, "" + sym + " " + base + " " + superAccName);//debug diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 7e0562d633..4eb38f349b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -46,7 +46,7 @@ abstract class SuperAccessors extends transform.Transform { case Select(sup @ Super(_, mix), name) => val clazz = sup.symbol; if (tree.isTerm && mix == nme.EMPTY.toTypeName && - (clazz.isMixin || clazz != currentOwner.enclClass || !validCurrentOwner)) { + (clazz.isTrait || clazz != currentOwner.enclClass || !validCurrentOwner)) { val supername = nme.superName(tree.symbol.name); var superAcc = clazz.info.decl(supername).suchThat(.alias.==(tree.symbol)); if (superAcc == NoSymbol) { diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index b2268ff239..306dad37c6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -18,7 +18,7 @@ import scala.collection.mutable.ListBuffer; * unless they are defined in the class or a baseclass * different from java.lang.Object */ -mixin class SyntheticMethods requires Analyzer { +trait SyntheticMethods requires Analyzer { import global._; // the global environment import definitions._; // standard classes and methods import typer.{typed}; // methods to type trees diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 10c96ac749..4482480496 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -11,7 +11,7 @@ import scala.tools.nsc.util.Position import scala.collection.mutable.{HashMap, ListBuffer} /** Methods to create symbols and to enter them into scopes. */ -mixin class Typers requires Analyzer { +trait Typers requires Analyzer { import global._ import definitions._ import posAssigner.atPos @@ -510,8 +510,8 @@ mixin class Typers requires Analyzer { else { var supertpt = typedTypeConstructor(templ.parents.head) var mixins = templ.parents.tail map typedType - // If first parent is a mixin class, make it first mixin and add its superclass as first parent - while (supertpt.tpe.symbol != null && supertpt.tpe.symbol.initialize.isMixin) { + // If first parent is a trait, make it first mixin and add its superclass as first parent + while (supertpt.tpe.symbol != null && supertpt.tpe.symbol.initialize.isTrait) { mixins = typedType(supertpt) :: mixins supertpt = TypeTree(supertpt.tpe.parents.head) setOriginal supertpt /* setPos supertpt.pos */ } @@ -558,16 +558,16 @@ mixin class Typers requires Analyzer { if (!psym.isClass) error(parent.pos, "class type expected") else if (psym != superclazz) - if (psym.isMixin) { + if (psym.isTrait) { val ps = psym.info.parents if (!ps.isEmpty && !superclazz.isSubClass(ps.head.symbol)) error(parent.pos, "illegal inheritance; super"+superclazz+ "\n is not a subclass of the super"+ps.head.symbol+ "\n of the mixin " + psym); } else if (settings.migrate.value) - error(parent.pos, migrateMsg+psym+" needs to be a declared as a mixin class") + error(parent.pos, migrateMsg+psym+" needs to be a declared as a trait") else - error(parent.pos, ""+psym+" is not declared to be a mixin class") + error(parent.pos, ""+psym+" is not declared to be a trait") else if (psym.hasFlag(FINAL)) error(parent.pos, "illegal inheritance from final class") else if (!phase.erasedTypes && psym.isSealed && @@ -1295,7 +1295,6 @@ mixin class Typers requires Analyzer { val rhs1 = typed(rhs, lhs1.tpe) copy.Assign(tree, lhs1, rhs1) setType UnitClass.tpe } else { - System.out.println(""+lhs1+" "+varsym+" "+varsym.isValue+" "+flagsToString(varsym.flags));//debug if (!lhs1.tpe.isError) error(tree.pos, "assignment to non-variable ") setError(tree) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Variances.scala b/src/compiler/scala/tools/nsc/typechecker/Variances.scala index 2992f92d3c..2bdb019374 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Variances.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Variances.scala @@ -9,7 +9,7 @@ import symtab.Flags._; /** Variances form a lattice, 0 <= COVARIANT <= Variances, 0 <= CONTRAVARIANT <= VARIANCES */ -mixin class Variances { +trait Variances { val global: Global; import global._; diff --git a/src/library/scala/Application.scala b/src/library/scala/Application.scala index 8d5327e8be..2437a5ffaa 100644 --- a/src/library/scala/Application.scala +++ b/src/library/scala/Application.scala @@ -36,7 +36,7 @@ package scala; * @version 1.0, 10/09/03 */ -mixin class Application { +trait Application { /** The time when execution of this program started. */ diff --git a/src/library/scala/BufferedIterator.scala b/src/library/scala/BufferedIterator.scala index 0675f22167..7a5d26d281 100644 --- a/src/library/scala/BufferedIterator.scala +++ b/src/library/scala/BufferedIterator.scala @@ -12,13 +12,13 @@ package scala; -/** Buffered iterators are iterators which allow to inspect the next +/** Buffered iterators are iterators which llow to inspect the next * element without discarding it. * * @author Martin Odersky * @version 1.0, 16/07/2003 */ -mixin class BufferedIterator[+A] extends Iterator[A] { +trait BufferedIterator[+A] extends Iterator[A] { /** Checks what the next available element is. * diff --git a/src/library/scala/CaseClass.scala b/src/library/scala/CaseClass.scala index 91b290956e..d50220f737 100644 --- a/src/library/scala/CaseClass.scala +++ b/src/library/scala/CaseClass.scala @@ -16,7 +16,7 @@ package scala; * * @author Burak Emir */ -mixin class CaseClass extends AnyRef { +trait CaseClass extends AnyRef { /** for a case class A(x_0,...,x_(k-1)), returns x_i for 0 <= i < k, ** null otherwise diff --git a/src/library/scala/CountedIterator.scala b/src/library/scala/CountedIterator.scala index bce9fd45fe..cf45174e17 100644 --- a/src/library/scala/CountedIterator.scala +++ b/src/library/scala/CountedIterator.scala @@ -18,7 +18,7 @@ package scala; * @author Martin Odersky * @version 1.0, 16/07/2003 */ -mixin class CountedIterator[+A] extends Iterator[A] { +trait CountedIterator[+A] extends Iterator[A] { /** counts the elements in this iterator; counts start at 0 */ diff --git a/src/library/scala/Function0.scala b/src/library/scala/Function0.scala index 7309ed403c..e7d2da57f4 100644 --- a/src/library/scala/Function0.scala +++ b/src/library/scala/Function0.scala @@ -15,7 +15,7 @@ package scala; /** * Function with no parameters */ -mixin class Function0[+R] extends AnyRef { +trait Function0[+R] extends AnyRef { def apply(): R; override def toString() = "<function>"; } diff --git a/src/library/scala/Function1.scala b/src/library/scala/Function1.scala index a5e19bb2fa..f928596332 100644 --- a/src/library/scala/Function1.scala +++ b/src/library/scala/Function1.scala @@ -15,7 +15,7 @@ package scala; /** * Function with 1 parameter */ -mixin class Function1[-T0, +R] extends AnyRef { +trait Function1[-T0, +R] extends AnyRef { def apply(v0: T0): R; override def toString() = "<function>"; } diff --git a/src/library/scala/Function2.scala b/src/library/scala/Function2.scala index e58173d6b3..bea1a9a951 100644 --- a/src/library/scala/Function2.scala +++ b/src/library/scala/Function2.scala @@ -15,7 +15,7 @@ package scala; /** * Function with 2 parameters */ -mixin class Function2[-T0, -T1, +R] extends AnyRef { +trait Function2[-T0, -T1, +R] extends AnyRef { def apply(v0: T0, v1: T1): R; override def toString() = "<function>"; } diff --git a/src/library/scala/Function3.scala b/src/library/scala/Function3.scala index 09d8633f7f..d161362d03 100644 --- a/src/library/scala/Function3.scala +++ b/src/library/scala/Function3.scala @@ -15,7 +15,7 @@ package scala; /** * Function with 3 parameters */ -mixin class Function3[-T0, -T1, -T2, +R] extends AnyRef { +trait Function3[-T0, -T1, -T2, +R] extends AnyRef { def apply(v0: T0, v1: T1, v2: T2): R; override def toString() = "<function>"; } diff --git a/src/library/scala/Function4.scala b/src/library/scala/Function4.scala index 3bae61ead6..7ddbed0031 100644 --- a/src/library/scala/Function4.scala +++ b/src/library/scala/Function4.scala @@ -15,7 +15,7 @@ package scala; /** * Function with 4 parameters */ -mixin class Function4[-T0, -T1, -T2, -T3, +R] extends AnyRef { +trait Function4[-T0, -T1, -T2, -T3, +R] extends AnyRef { def apply(v0: T0, v1: T1, v2: T2, v3: T3): R; override def toString() = "<function>"; } diff --git a/src/library/scala/Function5.scala b/src/library/scala/Function5.scala index 7bebfa5d5b..74fe7d1ca1 100644 --- a/src/library/scala/Function5.scala +++ b/src/library/scala/Function5.scala @@ -15,7 +15,7 @@ package scala; /** * Function with 5 parameters */ -mixin class Function5[-T0, -T1, -T2, -T3, -T4, +R] extends AnyRef { +trait Function5[-T0, -T1, -T2, -T3, -T4, +R] extends AnyRef { def apply(v0: T0, v1: T1, v2: T2, v3: T3, v4: T4): R; override def toString() = "<function>"; } diff --git a/src/library/scala/Function6.scala b/src/library/scala/Function6.scala index d9709a0e46..a46f17bb61 100644 --- a/src/library/scala/Function6.scala +++ b/src/library/scala/Function6.scala @@ -15,7 +15,7 @@ package scala; /** * Function with 6 parameters */ -mixin class Function6[-T0, -T1, -T2, -T3, -T4, -T5, +R] extends AnyRef { +trait Function6[-T0, -T1, -T2, -T3, -T4, -T5, +R] extends AnyRef { def apply(v0: T0, v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): R; override def toString() = "<function>"; } diff --git a/src/library/scala/Function7.scala b/src/library/scala/Function7.scala index 0398c349ac..95bdb39275 100644 --- a/src/library/scala/Function7.scala +++ b/src/library/scala/Function7.scala @@ -15,7 +15,7 @@ package scala; /** * Function with 7 parameters */ -mixin class Function7[-T0, -T1, -T2, -T3, -T4, -T5, -T6, +R] extends AnyRef { +trait Function7[-T0, -T1, -T2, -T3, -T4, -T5, -T6, +R] extends AnyRef { def apply(v0: T0, v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): R; override def toString() = "<function>"; } diff --git a/src/library/scala/Function8.scala b/src/library/scala/Function8.scala index 0630402a3e..e0b87f00e2 100644 --- a/src/library/scala/Function8.scala +++ b/src/library/scala/Function8.scala @@ -15,7 +15,7 @@ package scala; /** * Function with 8 parameters */ -mixin class Function8[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, +R] extends AnyRef { +trait Function8[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, +R] extends AnyRef { def apply(v0: T0, v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): R; override def toString() = "<function>"; } diff --git a/src/library/scala/Function9.scala b/src/library/scala/Function9.scala index 8e82ded993..87761c6f59 100644 --- a/src/library/scala/Function9.scala +++ b/src/library/scala/Function9.scala @@ -15,7 +15,7 @@ package scala; /** * Function with 9 parameters */ -mixin class Function9[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, +R] extends AnyRef { +trait Function9[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, +R] extends AnyRef { def apply(v0: T0, v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; override def toString() = "<function>"; } diff --git a/src/library/scala/Iterable.scala b/src/library/scala/Iterable.scala index 4700649a63..581b39201a 100644 --- a/src/library/scala/Iterable.scala +++ b/src/library/scala/Iterable.scala @@ -65,7 +65,7 @@ object Iterable { * @author Matthias Zenger * @version 1.1, 04/02/2004 */ -mixin class Iterable[+A] { +trait Iterable[+A] { /** Creates a new iterator over all elements contained in this * object. diff --git a/src/library/scala/IterableProxy.scala b/src/library/scala/IterableProxy.scala index ed45c58f5c..0b8ddc88df 100644 --- a/src/library/scala/IterableProxy.scala +++ b/src/library/scala/IterableProxy.scala @@ -18,7 +18,7 @@ package scala; * @author Matthias Zenger * @version 1.0, 26/04/2004 */ -mixin class IterableProxy[+A] extends Iterable[A] with Proxy { +trait IterableProxy[+A] extends Iterable[A] with Proxy { def self: Iterable[A]; diff --git a/src/library/scala/Iterator.scala b/src/library/scala/Iterator.scala index ded761dcfc..ac394b2ce9 100644 --- a/src/library/scala/Iterator.scala +++ b/src/library/scala/Iterator.scala @@ -173,7 +173,7 @@ object Iterator { * @author Matthias Zenger * @version 1.2, 15/03/2004 */ -mixin class Iterator[+A] { +trait Iterator[+A] { /** Does this iterator provide another element? */ diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala index 3050fa9634..c9f5789310 100644 --- a/src/library/scala/List.scala +++ b/src/library/scala/List.scala @@ -1057,10 +1057,10 @@ sealed abstract class List[+a] extends Seq[a] { * @version 1.0, 15/07/2003 */ [SerialVersionUID(0 - 8256821097970055419L)] -case object Nil extends List[All] { +case object Nil extends List[Bottom] { def isEmpty = true; def head: All = error("head of empty list"); - def tail: List[All] = error("tail of empty list"); + def tail: List[Bottom] = error("tail of empty list"); } /** A non empty list characterized by a head and a tail. diff --git a/src/library/scala/MatchError.scala b/src/library/scala/MatchError.scala index 8607334e41..37fe5a00e9 100644 --- a/src/library/scala/MatchError.scala +++ b/src/library/scala/MatchError.scala @@ -11,6 +11,7 @@ package scala; +import Predef._ /** This class implements errors which are thrown whenever an * object doesn't match any pattern of a pattern matching @@ -23,7 +24,7 @@ package scala; object MatchError { // todo: change pattern matcher so that dummy type parameter T can be removed. - def fail[T](source: String, line: Int): All = throw new MatchError(source, line); + def fail[T](source: String, line: Int): Bottom = throw new MatchError(source, line); def report(source: String, line: Int, obj: Any) = try { diff --git a/src/library/scala/None.scala b/src/library/scala/None.scala deleted file mode 100644 index 00e9cdaf2f..0000000000 --- a/src/library/scala/None.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala; - - -/** This case object represents non-existent values. - * - * @author Martin Odersky - * @version 1.0, 16/07/2003 - */ -case object None extends Option[All]; diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index 0bd03599cf..ff93da86b0 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -11,6 +11,7 @@ package scala; +import Predef._ /** This class represents optional values. Instances of <code>Option</code> * are either instances of case class <code>Some</code> or it is case @@ -20,7 +21,7 @@ package scala; * @author Matthias Zenger * @version 1.0, 16/07/2003 */ -abstract class Option[+A] extends Iterable[A] { +sealed abstract class Option[+A] extends Iterable[A] { def isEmpty: Boolean = this match { case None => true @@ -68,3 +69,18 @@ abstract class Option[+A] extends Iterable[A] { } } + +/** Class <code>Some[A]</code> represents existing values of type + * <code>A</code>. + * + * @author Martin Odersky + * @version 1.0, 16/07/2003 + */ +final case class Some[+A](x: A) extends Option[A]; + +/** This case object represents non-existent values. + * + * @author Martin Odersky + * @version 1.0, 16/07/2003 + */ +case object None extends Option[Bottom]; diff --git a/src/library/scala/Ordered.scala b/src/library/scala/Ordered.scala index 2c14369575..eca26f290b 100644 --- a/src/library/scala/Ordered.scala +++ b/src/library/scala/Ordered.scala @@ -17,7 +17,7 @@ package scala; * @author Martin Odersky * @version 1.0, 23/04/2004 */ -mixin class Ordered[+a] { +trait Ordered[+a] { /** Result of comparing `this' with operand `that'. * returns `x' where diff --git a/src/library/scala/PartialFunction.scala b/src/library/scala/PartialFunction.scala index ed5d64ca1c..8af05728f1 100644 --- a/src/library/scala/PartialFunction.scala +++ b/src/library/scala/PartialFunction.scala @@ -20,7 +20,7 @@ package scala; * @author Martin Odersky * @version 1.0, 16/07/2003 */ -mixin class PartialFunction[-A, +B] extends AnyRef with (A => B) { +trait PartialFunction[-A, +B] extends AnyRef with (A => B) { /** Checks if a value is contained in the functions domain. * diff --git a/src/library/scala/PartiallyOrdered.scala b/src/library/scala/PartiallyOrdered.scala index ab8c5ae997..45aa1fc58b 100644 --- a/src/library/scala/PartiallyOrdered.scala +++ b/src/library/scala/PartiallyOrdered.scala @@ -17,7 +17,7 @@ package scala; * @author Martin Odersky * @version 1.0, 23/04/2004 */ -mixin class PartiallyOrdered[+a] { +trait PartiallyOrdered[+a] { /** Result of comparing `this' with operand `that'. * Returns `None' if operands are not comparable. diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index 37acc7a764..1d082d1db3 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -20,6 +20,9 @@ object Predef { // aliases ------------------------------------------------------- + type Bottom = All + type Null = AllRef + type byte = scala.Byte; type short = scala.Short; type char = scala.Char; @@ -149,11 +152,11 @@ object Predef { // errors and asserts ------------------------------------------------- - def error(message: String): All = throw new Error(message); + def error(message: String): Bottom = throw new Error(message); - def exit: All = exit(0); + def exit: Bottom = exit(0); - def exit(status: Int): All = { + def exit(status: Int): Bottom = { java.lang.System.exit(status); throw new Throwable() } diff --git a/src/library/scala/Proxy.scala b/src/library/scala/Proxy.scala index 4ccde24a23..64e2a333f8 100644 --- a/src/library/scala/Proxy.scala +++ b/src/library/scala/Proxy.scala @@ -20,7 +20,7 @@ package scala; * @author Matthias Zenger * @version 1.0, 26/04/2004 */ -mixin class Proxy { +trait Proxy { def self: Any; override def hashCode(): Int = self.hashCode(); override def equals(y: Any): Boolean = self.equals(y); diff --git a/src/library/scala/ScalaObject.scala b/src/library/scala/ScalaObject.scala index 5b328704ef..7d213e33b3 100644 --- a/src/library/scala/ScalaObject.scala +++ b/src/library/scala/ScalaObject.scala @@ -12,7 +12,7 @@ package scala -mixin class ScalaObject extends AnyRef { +trait ScalaObject extends AnyRef { /** This method is needed for optimizing pattern matching expressions * which match on constructors of case classes. diff --git a/src/library/scala/SeqProxy.scala b/src/library/scala/SeqProxy.scala index 5c3aa26179..0828349deb 100644 --- a/src/library/scala/SeqProxy.scala +++ b/src/library/scala/SeqProxy.scala @@ -19,7 +19,7 @@ package scala; * @author Matthias Zenger * @version 1.0, 16/07/2003 */ -mixin class SeqProxy[+A] extends Seq[A] with IterableProxy[A] { +trait SeqProxy[+A] extends Seq[A] with IterableProxy[A] { def self: Seq[A]; diff --git a/src/library/scala/Some.scala b/src/library/scala/Some.scala deleted file mode 100644 index e8235f26e8..0000000000 --- a/src/library/scala/Some.scala +++ /dev/null @@ -1,21 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala; - - -/** Class <code>Option[A]</code> represents existing values of type - * <code>A</code>. - * - * @author Martin Odersky - * @version 1.0, 16/07/2003 - */ -final case class Some[+A](x: A) extends Option[A]; diff --git a/src/library/scala/Stream.scala b/src/library/scala/Stream.scala index cfdc49f07b..d86af7392d 100644 --- a/src/library/scala/Stream.scala +++ b/src/library/scala/Stream.scala @@ -21,10 +21,10 @@ package scala; */ object Stream { - val empty: Stream[All] = new Stream[All] { + val empty: Stream[Bottom] = new Stream[Bottom] { def isEmpty = true; - def head: All = error("head of empty stream"); - def tail: Stream[All] = error("tail of empty stream"); + def head: Bottom = error("head of empty stream"); + def tail: Stream[Bottom] = error("tail of empty stream"); def printElems(buf: StringBuffer, prefix: String): StringBuffer = buf; } diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala index 610dc3f6e5..3f5b276aee 100644 --- a/src/library/scala/collection/mutable/DoubleLinkedList.scala +++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala @@ -20,7 +20,7 @@ package scala.collection.mutable; * @author Matthias Zenger * @version 1.0, 08/07/2003 */ -abstract class DoubleLinkedList[A, This >: AllRef <: DoubleLinkedList[A, This]] +abstract class DoubleLinkedList[A, This >: Null <: DoubleLinkedList[A, This]] requires This extends SingleLinkedList[A, This] { diff --git a/src/library/scala/collection/mutable/SingleLinkedList.scala b/src/library/scala/collection/mutable/SingleLinkedList.scala index 32b4690d4d..00346e83db 100644 --- a/src/library/scala/collection/mutable/SingleLinkedList.scala +++ b/src/library/scala/collection/mutable/SingleLinkedList.scala @@ -20,7 +20,7 @@ package scala.collection.mutable; * @author Matthias Zenger * @version 1.0, 08/07/2003 */ -abstract class SingleLinkedList[A, This >: AllRef <: SingleLinkedList[A, This]] +abstract class SingleLinkedList[A, This >: Null <: SingleLinkedList[A, This]] requires This extends AnyRef with Seq[A] { diff --git a/src/library/scala/concurrent/MailBox.scala b/src/library/scala/concurrent/MailBox.scala index 049259a988..44418d448d 100644 --- a/src/library/scala/concurrent/MailBox.scala +++ b/src/library/scala/concurrent/MailBox.scala @@ -139,7 +139,7 @@ mixin class ListQueueCreator { /** Efficient queue module creator based on linked lists. */ mixin class LinkedListQueueCreator { import scala.collection.mutable.LinkedList; - def queueCreate[a >: AllRef <: AnyRef]: QueueModule[a] = new QueueModule[a] { + def queueCreate[a >: Null <: AnyRef]: QueueModule[a] = new QueueModule[a] { type t = Pair[LinkedList[a], LinkedList[a]]; // fst = the list, snd = last elem def make: t = { val l = new LinkedList[a](null, null); diff --git a/src/library/scala/dbc/datatype/CharacterString.scala b/src/library/scala/dbc/datatype/CharacterString.scala index dae029d600..1f250475b3 100644 --- a/src/library/scala/dbc/datatype/CharacterString.scala +++ b/src/library/scala/dbc/datatype/CharacterString.scala @@ -15,10 +15,10 @@ package scala.dbc.datatype; /** A type category for all SQL types that store strings of characters. */ abstract class CharacterString extends String { - type NativeType = java.lang.String; - val nativeTypeId = DataType.STRING; + type NativeType = java.lang.String; + val nativeTypeId = DataType.STRING; - /** The name of the character set in which the string is encoded. */ - def encoding: Option[java.lang.String] = None; + /** The name of the character set in which the string is encoded. */ + def encoding: Option[java.lang.String] = None; } diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index 83fa174f4e..9612f9823d 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -90,7 +90,7 @@ object ScalaRunTime { false } - //def checkDefined[T >: AllRef](x: T): T = + //def checkDefined[T >: Null](x: T): T = // if (x == null) throw new UndefinedException else x def Seq[a](xs: a*): Seq[a] = null; // interpreted specially by new backend. |