From dbf2424c54aefddb50f6e7cb12d1fdc220bd9465 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 3 Jan 2006 17:07:10 +0000 Subject: --- src/compiler/scala/tools/nsc/Global.scala | 4 +- .../scala/tools/nsc/ast/TreeBrowsers.scala | 6 +- .../scala/tools/nsc/ast/TreePrinters.scala | 21 +++--- src/compiler/scala/tools/nsc/ast/Trees.scala | 26 ++++---- .../scala/tools/nsc/ast/parser/Parsers.scala | 76 +++++++++++++--------- .../scala/tools/nsc/ast/parser/Scanners.scala | 3 +- .../scala/tools/nsc/ast/parser/Tokens.scala | 1 + .../tools/nsc/backend/WorklistAlgorithm.scala | 2 +- .../scala/tools/nsc/backend/icode/Checkers.scala | 2 +- .../scala/tools/nsc/backend/icode/GenICode.scala | 6 +- .../scala/tools/nsc/backend/icode/Opcodes.scala | 6 +- .../scala/tools/nsc/matching/CodeFactory.scala | 3 +- .../scala/tools/nsc/symtab/Definitions.scala | 8 +-- src/compiler/scala/tools/nsc/symtab/Flags.scala | 22 ++----- src/compiler/scala/tools/nsc/symtab/StdNames.scala | 1 + src/compiler/scala/tools/nsc/symtab/Symbols.scala | 27 ++++---- .../nsc/symtab/classfile/ClassfileParser.scala | 2 +- .../scala/tools/nsc/transform/AddInterfaces.scala | 14 ++-- .../scala/tools/nsc/transform/Erasure.scala | 6 +- .../scala/tools/nsc/transform/ExplicitOuter.scala | 22 +++---- src/compiler/scala/tools/nsc/transform/Mixin.scala | 34 +++++----- .../scala/tools/nsc/transform/TailCalls.scala | 2 +- .../scala/tools/nsc/typechecker/Namers.scala | 18 +++-- .../scala/tools/nsc/typechecker/RefChecks.scala | 18 ++--- .../tools/nsc/typechecker/SuperAccessors.scala | 2 +- .../scala/tools/nsc/typechecker/Typers.scala | 48 +++++++------- src/compiler/scala/tools/nsc/util/Set.scala | 2 +- 27 files changed, 198 insertions(+), 184 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 66b264a4ce..e8d72fb88d 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -231,7 +231,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable val global: Global.this.type = Global.this; } - object mixin extends Mixin { + object mixer extends Mixin { val global: Global.this.type = Global.this; } @@ -274,7 +274,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable lambdaLift, constructors, flatten, - mixin, + mixer, genicode, genJVM, sampleTransform); diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index 9e4821a734..20c7ce05dd 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -317,8 +317,8 @@ abstract class TreeBrowsers { case Apply(fun, args) => Pair("Apply", EMPTY); - case Super(qualif, mixin) => - Pair("Super", qualif.toString() + ", mixin: " + mixin.toString()); + case Super(qualif, mix) => + Pair("Super", qualif.toString() + ", mix: " + mix.toString()); case This(qualifier) => Pair("This", qualifier); @@ -458,7 +458,7 @@ abstract class TreeBrowsers { case Apply(fun, args) => List(fun) ::: args; - case Super(qualif, mixin) => + case Super(qualif, mix) => Nil; case This(qualif) => diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala index 206fa58061..4d13548a08 100644 --- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala @@ -82,17 +82,20 @@ abstract class TreePrinters { def printModifiers(tree: Tree, mods: Modifiers): unit = { if (tree.symbol == NoSymbol) printFlags(mods.flags, mods.privateWithin) - else if (tree.symbol.privateWithin == null) + else if (tree.symbol.privateWithin == NoSymbol || + tree.symbol.privateWithin == tree.symbol.owner) printFlags(tree.symbol.flags, nme.EMPTY.toTypeName) else printFlags(tree.symbol.flags, tree.symbol.privateWithin.name) } def printFlags(flags: long, privateWithin: Name): unit = { - val mask = if (settings.debug.value) -1 else PrintableFlags; - val suffixes: List[Pair[long, String]] = - if (privateWithin.isEmpty) List() else List(Pair(PRIVATE, privateWithin.toString())); - val s = flagsToString(flags & mask, suffixes); + var mask = if (settings.debug.value) -1 else PrintableFlags; + if (!privateWithin.isEmpty) { + print("private["+privateWithin+"] "); + mask = mask & ~PRIVATE + } + val s = flagsToString(flags & mask); if (s.length() != 0) print(s + " ") } @@ -106,7 +109,7 @@ abstract class TreePrinters { case ClassDef(mods, name, tparams, tp, impl) => printModifiers(tree, mods); - print((if (mods.hasFlag(TRAIT)) "trait " else "class ") + symName(tree, name)); + print("class " + symName(tree, name)); printTypeParams(tparams); printOpt(": ", tp); print(" extends "); print(impl); @@ -221,11 +224,11 @@ abstract class TreePrinters { case Apply(fun, vargs) => print(fun); printRow(vargs, "(", ", ", ")"); - case Super(qual, mixin) => + case Super(qual, mix) => if (!qual.isEmpty || tree.symbol != NoSymbol) print(symName(tree, qual) + "."); print("super"); - if (!mixin.isEmpty) - print("[" + mixin + "]") + if (!mix.isEmpty) + print("[" + mix + "]") case This(qual) => if (!qual.isEmpty) print(symName(tree, qual) + "."); diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 92b147c947..48f6cbbd7b 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -19,7 +19,7 @@ import symtab.Flags._; case class Modifiers(flags: int, privateWithin: Name) { def isPrivate = ((flags & PRIVATE ) != 0); def isProtected = ((flags & PROTECTED) != 0); - def isVariable = ((flags & MUTABLE) != 0); + def isVariable = ((flags & MUTABLE ) != 0); def isPublic = !isPrivate && !isProtected; def hasFlag(flag: int) = (flags & flag) != 0; def | (flag: int): Modifiers = { @@ -452,10 +452,10 @@ import symtab.Flags._; } /** Super reference */ - case class Super(qual: Name, mixin: Name) + case class Super(qual: Name, mix: Name) extends TermTree with SymTree; - def Super(sym: Symbol, mixin: Name): Tree = Super(sym.name, mixin) setSymbol sym; + def Super(sym: Symbol, mix: Name): Tree = Super(sym.name, mix) setSymbol sym; /** Self reference */ case class This(qual: Name) @@ -590,7 +590,7 @@ import symtab.Flags._; case Typed(expr, tpt) => (eliminated by erasure) case TypeApply(fun, args) => case Apply(fun, args) => - case Super(qual, mixin) => + case Super(qual, mix) => case This(qual) => case Select(qualifier, selector) => case Ident(name) => @@ -633,7 +633,7 @@ import symtab.Flags._; def Typed(tree: Tree, expr: Tree, tpt: Tree): Typed; def TypeApply(tree: Tree, fun: Tree, args: List[Tree]): TypeApply; def Apply(tree: Tree, fun: Tree, args: List[Tree]): Apply; - def Super(tree: Tree, qual: Name, mixin: Name): Super; + def Super(tree: Tree, qual: Name, mix: Name): Super; def This(tree: Tree, qual: Name): This; def Select(tree: Tree, qualifier: Tree, selector: Name): Select; def Ident(tree: Tree, name: Name): Ident; @@ -706,8 +706,8 @@ import symtab.Flags._; new TypeApply(fun, args).copyAttrs(tree); def Apply(tree: Tree, fun: Tree, args: List[Tree]) = new Apply(fun, args).copyAttrs(tree); - def Super(tree: Tree, qual: Name, mixin: Name) = - new Super(qual, mixin).copyAttrs(tree); + def Super(tree: Tree, qual: Name, mix: Name) = + new Super(qual, mix).copyAttrs(tree); def This(tree: Tree, qual: Name) = new This(qual).copyAttrs(tree); def Select(tree: Tree, qualifier: Tree, selector: Name) = @@ -880,10 +880,10 @@ import symtab.Flags._; if ((fun0 == fun) && (args0 == args)) => t case _ => copy.Apply(tree, fun, args) } - def Super(tree: Tree, qual: Name, mixin: Name) = tree match { - case t @ Super(qual0, mixin0) - if ((qual0 == qual) && (mixin0 == mixin)) => t - case _ => copy.Super(tree, qual, mixin) + def Super(tree: Tree, qual: Name, mix: Name) = tree match { + case t @ Super(qual0, mix0) + if ((qual0 == qual) && (mix0 == mix)) => t + case _ => copy.Super(tree, qual, mix) } def This(tree: Tree, qual: Name) = tree match { case t @ This(qual0) @@ -1012,8 +1012,8 @@ import symtab.Flags._; copy.TypeApply(tree, transform(fun), transformTrees(args)) case Apply(fun, args) => copy.Apply(tree, transform(fun), transformTrees(args)) - case Super(qual, mixin) => - copy.Super(tree, qual, mixin) + case Super(qual, mix) => + copy.Super(tree, qual, mix) case This(qual) => copy.This(tree, qual) case Select(qualifier, selector) => diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 36f6d5890e..00c8cf99a5 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -133,12 +133,12 @@ import Tokens._; /////// TOKEN CLASSES ////////////////////////////////////////////////////// def isModifier: boolean = in.token match { - case ABSTRACT | FINAL | SEALED | PRIVATE | PROTECTED | OVERRIDE | IMPLICIT => true + case ABSTRACT | FINAL | SEALED | MIXIN | PRIVATE | PROTECTED | OVERRIDE | IMPLICIT => true case _ => false } def isLocalModifier: boolean = in.token match { - case ABSTRACT | FINAL | SEALED => true + case ABSTRACT | FINAL | SEALED | MIXIN => true case _ => false } @@ -1061,22 +1061,29 @@ import Tokens._; ////////// MODIFIERS //////////////////////////////////////////////////////////// /** Modifiers ::= {Modifier} - * Modifier ::= final - * | private [ "[" Id "]" ] - * | protected - * | override - * | abstract + * Modifier ::= LocalClassModifier + * | private [ "[" Id "]" ] + * | protected | override | implicit */ def modifiers(): Modifiers = { + var privateWithin: Name = nme.EMPTY.toTypeName; def loop(mods: int): int = in.token match { case ABSTRACT => loop(addMod(mods, Flags.ABSTRACT)) + case MIXIN => + loop(addMod(mods, Flags.MIXIN)) case FINAL => loop(addMod(mods, Flags.FINAL)) case SEALED => loop(addMod(mods, Flags.SEALED)) case PRIVATE => - loop(addMod(mods, Flags.PRIVATE)) + val mods1 = addMod(mods, Flags.PRIVATE); + if (in.token == LBRACKET) { + in.nextToken(); + privateWithin = ident().toTypeName; + accept(RBRACKET) + } + loop(mods1) case PROTECTED => loop(addMod(mods, Flags.PROTECTED)) case OVERRIDE => @@ -1089,17 +1096,18 @@ import Tokens._; var mods = loop(0); if ((mods & (Flags.ABSTRACT | Flags.OVERRIDE)) == (Flags.ABSTRACT | Flags.OVERRIDE)) mods = mods & ~(Flags.ABSTRACT | Flags.OVERRIDE) | Flags.ABSOVERRIDE; - Modifiers(mods) + Modifiers(mods, privateWithin) } /** LocalClassModifiers ::= {LocalClassModifier} - * LocalClassModifier ::= final - * | private + * LocalClassModifier ::= abstract | mixin | final | sealed */ def localClassModifiers(): Modifiers = { def loop(mods: int): int = in.token match { case ABSTRACT => loop(addMod(mods, Flags.ABSTRACT)) + case MIXIN => + loop(addMod(mods, Flags.MIXIN)) case FINAL => loop(addMod(mods, Flags.FINAL)) case SEALED => @@ -1506,20 +1514,23 @@ import Tokens._; /** TmplDef ::= ([case] class | trait) ClassDef * | [case] object ObjectDef */ - def tmplDef(mods: Modifiers): Tree = in.token match { - case TRAIT => - classDef(mods | Flags.TRAIT | Flags.ABSTRACT); - case CLASS => - classDef(mods); - case CASECLASS => - classDef(mods | Flags.CASE); - case OBJECT => - objectDef(mods); - case CASEOBJECT => - objectDef(mods | Flags.CASE); - case _ => - syntaxError("illegal start of definition", true); + def tmplDef(mods: Modifiers): Tree = { + val mods1 = if (mods.hasFlag(Flags.MIXIN)) mods | Flags.ABSTRACT else mods; + in.token match { + case TRAIT => + classDef(mods1 | Flags.MIXIN | Flags.ABSTRACT); + case CLASS => + classDef(mods1); + case CASECLASS => + classDef(mods1 | Flags.CASE); + case OBJECT => + objectDef(mods1); + case CASEOBJECT => + objectDef(mods1 | Flags.CASE); + case _ => + syntaxError("illegal start of definition", true); EmptyTree + } } /** ClassDef ::= ClassSig RequiresTypeOpt ClassTemplate @@ -1534,7 +1545,7 @@ import Tokens._; 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.TRAIT) && (template.body forall treeInfo.isInterfaceMember)) + val mods1 = if (mods.hasFlag(Flags.MIXIN) && (template.body forall treeInfo.isInterfaceMember)) mods | Flags.INTERFACE else mods; ClassDef(mods1, name, tparams, thistpe, template) @@ -1583,7 +1594,7 @@ import Tokens._; var body = if (in.token == LBRACE) templateBody() else { acceptEmptyTemplateBody("`{' expected"); List() } - if (!mods.hasFlag(Flags.TRAIT)) Template(ps, vparamss, argss.toList, body) + if (!mods.hasFlag(Flags.MIXIN)) Template(ps, vparamss, argss.toList, body) else Template(ps, body) } @@ -1644,7 +1655,7 @@ import Tokens._; isModifier) { val attrs = attributeClauses(); (stats ++ - joinAttributes(attrs, joinComment(List(tmplDef(modifiers() | traitAttribute(attrs)))))) + joinAttributes(attrs, joinComment(List(tmplDef(modifiers() | mixinAttribute(attrs)))))) } else if (in.token != SEMI && in.token != NEWLINE) { syntaxError("illegal start of class or object definition", true); } @@ -1670,7 +1681,7 @@ import Tokens._; } else if (isDefIntro || isModifier || in.token == LBRACKET) { val attrs = attributeClauses(); (stats ++ - joinAttributes(attrs, joinComment(defOrDcl(modifiers() | traitAttribute(attrs))))) + joinAttributes(attrs, joinComment(defOrDcl(modifiers() | mixinAttribute(attrs))))) } else if (in.token != SEMI && in.token != NEWLINE) { syntaxError("illegal start of definition", true); } @@ -1708,14 +1719,15 @@ import Tokens._; atPos(pos) { New(t, List(args)) } } - def traitAttribute(attrs: List[Tree]) = { - def isTraitAttribute(attr: Tree) = attr match { - case Apply(Select(New(Ident(name)), constr), List()) if (name.toString() == "_trait_") => + def mixinAttribute(attrs: List[Tree]) = { + def isMixinAttribute(attr: Tree) = attr match { + case Apply(Select(New(Ident(name)), constr), List()) + if (name.toString() == "_mixin_" || name.toString() == "_trait_") => true case _ => false } - if (attrs exists isTraitAttribute) Flags.TRAIT else 0 + if (attrs exists isMixinAttribute) Flags.MIXIN 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 091a4faa05..717d4fd23a 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -768,7 +768,7 @@ import scala.tools.nsc.util.CharArrayReader enterKeyword(nme.IMPLICITkw, IMPLICIT) enterKeyword(nme.IMPORTkw, IMPORT) enterKeyword(nme.MATCHkw, MATCH) - enterKeyword(nme.REQUIRESkw, REQUIRES) + enterKeyword(nme.MIXINkw, MIXIN) enterKeyword(nme.NEWkw, NEW) enterKeyword(nme.NULLkw, NULL) enterKeyword(nme.OBJECTkw, OBJECT) @@ -776,6 +776,7 @@ import scala.tools.nsc.util.CharArrayReader enterKeyword(nme.PACKAGEkw, PACKAGE) enterKeyword(nme.PRIVATEkw, PRIVATE) enterKeyword(nme.PROTECTEDkw, PROTECTED) + enterKeyword(nme.REQUIRESkw, REQUIRES) enterKeyword(nme.RETURNkw, RETURN) enterKeyword(nme.SEALEDkw, SEALED) enterKeyword(nme.SUPERkw, SUPER) diff --git a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala index b99ee08811..2f07497ede 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala @@ -67,6 +67,7 @@ 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 6676c820bc..d6b81a84fe 100644 --- a/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala +++ b/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala @@ -15,7 +15,7 @@ import scala.collection.mutable.MutableList; * function is applied repeatedly to the first element in the * worklist, as long as the stack is not empty. * - * The client class should mix-in this trait and initialize the + * The client class should mix-in this class and initialize the * worklist field and define the processElement method. Then call * the 'run' method providing a function that initializes the * worklist. diff --git a/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala b/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala index be6aef6251..00741a1e0e 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala @@ -419,7 +419,7 @@ abstract class Checkers { stack.push(toTypeKind(method.info.resultType)); } - case SuperCall(mixin) => + case SuperCall(mix) => checkStack(1 + method.info.paramTypes.length); checkMethodArgs(method); checkMethod(stack.pop, method); diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index a7940cd66a..0e7c126f0d 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -526,11 +526,11 @@ abstract class GenICode extends SubComponent { // to call super constructors explicitly and/or use their 'returned' value. // therefore, we can ignore this fact, and generate code that leaves nothing // on the stack (contrary to what the type in the AST says). - case Apply(fun @ Select(Super(_, mixin), _), args) => + case Apply(fun @ Select(Super(_, mix), _), args) => if (settings.debug.value) log("Call to super: " + tree); - val invokeStyle = SuperCall(mixin); -// if (fun.symbol.isConstructor) Static(true) else SuperCall(mixin); + val invokeStyle = SuperCall(mix); +// if (fun.symbol.isConstructor) Static(true) else SuperCall(mix); ctx.bb.emit(THIS(ctx.clazz.symbol), tree.pos); val ctx1 = genLoadArguments(args, fun.symbol.info.paramTypes, ctx); diff --git a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala index 24eb1132f6..bb2b0c39eb 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala @@ -454,7 +454,7 @@ import scala.tools.nsc.util.Position; case Dynamic => "dynamic"; case Static(false) => "static-class"; case Static(true) => "static-instance"; - case SuperCall(mixin) => "super(" + mixin + ")"; + case SuperCall(mix) => "super(" + mix + ")"; } } @@ -466,8 +466,8 @@ import scala.tools.nsc.util.Position; */ case class Static(onInstance: Boolean) extends InvokeStyle; - /** Call through super[mixin]. */ - case class SuperCall(mixin: Name) extends InvokeStyle; + /** Call through super[mix]. */ + case class SuperCall(mix: Name) extends InvokeStyle; } } diff --git a/src/compiler/scala/tools/nsc/matching/CodeFactory.scala b/src/compiler/scala/tools/nsc/matching/CodeFactory.scala index 1d6882a0fa..d4678738ec 100644 --- a/src/compiler/scala/tools/nsc/matching/CodeFactory.scala +++ b/src/compiler/scala/tools/nsc/matching/CodeFactory.scala @@ -134,6 +134,7 @@ import scala.tools.nsc.util.Position; } // used by Equals + /* private def getCoerceToInt(left: Type): Symbol = { val sym = left.nonPrivateMember( nme.coerce ); //assert sym != Symbol.NONE : Debug.show(left); @@ -145,7 +146,7 @@ import scala.tools.nsc.util.Position; } }.get } - + */ // used by Equals /* private def getEqEq(left: Type, right: Type): Symbol = { diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index b4f760220f..af2f8e55d8 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -80,7 +80,7 @@ import Flags._; def SeqFactory = getMember(ScalaRunTimeModule, "Seq"); var RepeatedParamClass: Symbol = _; var ByNameParamClass: Symbol = _; - var TraitClass: Symbol = _; + //var TraitClass: Symbol = _; val MaxTupleArity = 9; val MaxFunctionArity = 9; @@ -310,10 +310,10 @@ import Flags._; AnyRefClass = newAlias(ScalaPackageClass, "AnyRef", ObjectClass.typeConstructor); AllRefClass = newClass(ScalaPackageClass, "AllRef", List(AnyRefClass.typeConstructor)) - .setFlag(ABSTRACT | TRAIT | FINAL); + .setFlag(ABSTRACT | MIXIN | FINAL); AllClass = newClass(ScalaPackageClass, "All", List(AnyClass.typeConstructor)) - .setFlag(ABSTRACT | TRAIT | FINAL); + .setFlag(ABSTRACT | MIXIN | FINAL); StringClass = getClass("java.lang.String"); ThrowableClass = getClass("java.lang.Throwable"); @@ -352,7 +352,7 @@ import Flags._; tparam => typeRef(SeqClass.typeConstructor.prefix, SeqClass, List(tparam.typeConstructor))); ByNameParamClass = newCovariantPolyClass( ScalaPackageClass, nme.BYNAME_PARAM_CLASS_NAME, tparam => AnyClass.typeConstructor); - TraitClass = getClass("scala._trait_"); + //TraitClass = getClass("scala._trait_"); TupleClass = new Array(MaxTupleArity + 1); for (val i <- List.range(1, MaxTupleArity + 1)) TupleClass(i) = getClass("scala.Tuple" + i); diff --git a/src/compiler/scala/tools/nsc/symtab/Flags.scala b/src/compiler/scala/tools/nsc/symtab/Flags.scala index 2627640d2e..39563cab29 100644 --- a/src/compiler/scala/tools/nsc/symtab/Flags.scala +++ b/src/compiler/scala/tools/nsc/symtab/Flags.scala @@ -43,8 +43,8 @@ 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 TRAIT = 0x02000000; // symbol is a trait - final val BRIDGE = 0x04000000; // function is a bridge method. Set by Erasure + final val MIXIN = 0x02000000; // symbol is a mixin class + final val BRIDGE = 0x04000000; // function is a bridge method. Set by Erasure final val ACCESSOR = 0x08000000; // a value or variable accessor final val SUPERACCESSOR = 0x10000000; // a super accessor @@ -100,7 +100,7 @@ object Flags { MODULE | PACKAGE | FINAL | JAVA; final val ExplicitFlags = // these modifiers can be set explicitly in source programs. - PRIVATE | PROTECTED | ABSTRACT | FINAL | SEALED | OVERRIDE | CASE | IMPLICIT | ABSOVERRIDE; + PRIVATE | PROTECTED | ABSTRACT | MIXIN | FINAL | SEALED | OVERRIDE | CASE | IMPLICIT | ABSOVERRIDE; final val PrintableFlags = // these modifiers appear in TreePrinter output. (ExplicitFlags | LOCAL | SYNTHETIC | STABLE | CASEACCESSOR | ACCESSOR | @@ -116,17 +116,9 @@ object Flags { /** Module flags inherited by their module-class */ final val ModuleToClassFlags = AccessFlags | PACKAGE | CASE; - def flagsToString(flags: long, suffixes: List[Pair[long, String]]): String = - (for (val i <- List.range(0, 63)) yield { - var s = flagToString(flags & (1L << i)); - suffixes.find(._1.==(i)) match { - case Some(Pair(i, suffix)) => s = s + "[" + suffix + "]" - case None => - } - s - }).filter("" !=).mkString("", " ", ""); - - def flagsToString(flags: long): String = flagsToString(flags, List()); + def flagsToString(flags: long): String = + (for (val i <- List.range(0, 63)) yield flagToString(flags & (1L << i))) + .filter("" !=).mkString("", " ", ""); private def flagToString(flag: long): String = { if (flag == LABEL) "