diff options
-rw-r--r-- | sources/scala/Unit.java | 7 | ||||
-rw-r--r-- | sources/scala/tools/nsc/symtab/Flags.scala | 3 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/symtab/Symbols.scala | 13 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/transform/AddInterfaces.scala | 5 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/transform/ExplicitOuter.scala | 9 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/transform/Mixin.scala | 22 |
6 files changed, 33 insertions, 26 deletions
diff --git a/sources/scala/Unit.java b/sources/scala/Unit.java index d2319ed762..dd50889c10 100644 --- a/sources/scala/Unit.java +++ b/sources/scala/Unit.java @@ -34,11 +34,4 @@ public abstract class Unit extends AnyVal { /** @meta method (scala.Any)scala.Boolean; */ public boolean $bang$eq(java.lang.Object other) { return !equals(other); } - - - - - - public String $plus (String that) { return this + that; } - } diff --git a/sources/scala/tools/nsc/symtab/Flags.scala b/sources/scala/tools/nsc/symtab/Flags.scala index 666501a83a..f0ed9318a4 100644 --- a/sources/scala/tools/nsc/symtab/Flags.scala +++ b/sources/scala/tools/nsc/symtab/Flags.scala @@ -61,6 +61,8 @@ object Flags { final val OVERLOADED = 0x200000000L; // symbol is overloaded final val LIFTED = 0x400000000L; // class has been lifted out to package level // local value has been lifted out to class level + //todo: make LIFTED = latePRIVATE? + final val MIXEDIN = 0x800000000L; // member has been mixed in final val EXPANDEDNAME = 0x1000000000L; // name has been expanded with class suffix @@ -76,6 +78,7 @@ object Flags { final val AntiShift = 52L; // late flags (set by a transformer phase) + final val latePRIVATE = (PRIVATE: long) << LateShift; final val lateDEFERRED = (DEFERRED: long) << LateShift; final val lateINTERFACE = (INTERFACE: long) << LateShift; final val lateMODULE = (MODULE: long) << LateShift; diff --git a/sources/scala/tools/nsc/symtab/Symbols.scala b/sources/scala/tools/nsc/symtab/Symbols.scala index f0a7132f79..0966f9a034 100755 --- a/sources/scala/tools/nsc/symtab/Symbols.scala +++ b/sources/scala/tools/nsc/symtab/Symbols.scala @@ -187,6 +187,12 @@ import Flags._; final def needsImplClass: boolean = isTrait && (!hasFlag(INTERFACE) || hasFlag(lateINTERFACE)) && !isImplClass; + final def isImplOnly: boolean = + hasFlag(PRIVATE) || + (owner.isImplClass || owner.isTrait) && + (hasFlag(notPRIVATE | LIFTED) && !hasFlag(ACCESSOR | SUPERACCESSOR) || + isConstructor); + /** Is this symbol a module variable ? */ final def isModuleVar: boolean = isVariable && nme.isModuleVarName(name); @@ -632,18 +638,11 @@ import Flags._; * term symbol rename it by expanding its name to avoid name clashes */ final def makeNotPrivate(base: Symbol): unit = -/* if (isTerm && (this hasFlag PRIVATE)) { setFlag(notPRIVATE); if (!hasFlag(DEFERRED)) setFlag(lateFINAL); expandName(base) } -*/ - if (isTerm && !(this hasFlag notPRIVATE) && ((this hasFlag PRIVATE) || this.owner.isTerm)) { - setFlag(notPRIVATE); - if (!hasFlag(DEFERRED)) setFlag(lateFINAL); - expandName(base) - } /** change name by appending $$<fully-qualified-name-of-class `base'> * Do the same for any accessed symbols or setters/getters diff --git a/sources/scala/tools/nsc/transform/AddInterfaces.scala b/sources/scala/tools/nsc/transform/AddInterfaces.scala index 8969e26865..5f8fd1b91c 100755 --- a/sources/scala/tools/nsc/transform/AddInterfaces.scala +++ b/sources/scala/tools/nsc/transform/AddInterfaces.scala @@ -37,7 +37,8 @@ abstract class AddInterfaces extends InfoTransform { private def isInterfaceMember(sym: Symbol): boolean = { sym.info; // to set lateMETHOD flag if necessary sym.isType || - sym.isMethod && !(sym hasFlag (PRIVATE | BRIDGE | LABEL)) && !sym.isConstructor + sym.isMethod && !(sym hasFlag (PRIVATE | BRIDGE | LABEL)) && + !sym.isConstructor && !sym.isImplOnly } def implClass(iface: Symbol): Symbol = implClassMap.get(iface) match { @@ -73,8 +74,6 @@ abstract class AddInterfaces extends InfoTransform { sym setFlag lateDEFERRED } } else { - if (sym.name == newTermName("definitions")) - System.out.println("definitions to impl class " + sym.isMethod + " " + sym.getFlag(PRIVATE | BRIDGE | LABEL)); sym.owner = implClass; decls enter sym; } diff --git a/sources/scala/tools/nsc/transform/ExplicitOuter.scala b/sources/scala/tools/nsc/transform/ExplicitOuter.scala index 2c6e4272d9..2a3fc9a19f 100755 --- a/sources/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/sources/scala/tools/nsc/transform/ExplicitOuter.scala @@ -39,6 +39,7 @@ abstract class ExplicitOuter extends InfoTransform { */ def transformInfo(sym: Symbol, tp: Type): Type = tp match { case MethodType(formals, restpe) => + //todo: needed? 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) @@ -283,7 +284,7 @@ abstract class ExplicitOuter extends InfoTransform { * 2. Remove private modifiers from members M of mixins T. (@see makeNotPrivate) * 3. Remove `private' modifier from class members M that are accessed from an inner class. * 4. Remove `protected' modifier from class members M that are accessed - * without a super qualifier accessed from an inner class. (@see makeNotPrivate) + * without a super qualifier accessed from an inner class. * 5. Remove `private' and `protected' modifiers from type symbols */ private val secondTransformer = new Transformer { @@ -295,18 +296,18 @@ abstract class ExplicitOuter extends InfoTransform { tree1 match { case DefDef(_, _, _, _, _, _) => if (sym.owner.isTrait && (sym hasFlag (ACCESSOR | SUPERACCESSOR))) - sym.makeNotPrivate(sym.owner); + sym.makeNotPrivate(sym.owner); //(2) tree1 case Select(qual, name) => if (currentOwner.enclClass != sym.owner) // (3) sym.makeNotPrivate(sym.owner); - if ((sym hasFlag PROTECTED) && + if ((sym hasFlag PROTECTED) && //(4) !(qual.isInstanceOf[Super] || (qual.tpe.widen.symbol isSubClass currentOwner.enclClass))) sym setFlag notPROTECTED; tree1 case _ => - if (sym != null && sym.isType) { + if (sym != null && sym.isType) {//(5) if (sym hasFlag PRIVATE) sym setFlag notPRIVATE; if (sym hasFlag PROTECTED) sym setFlag notPROTECTED; } diff --git a/sources/scala/tools/nsc/transform/Mixin.scala b/sources/scala/tools/nsc/transform/Mixin.scala index 7fb5817d02..f31e1ec8ba 100755 --- a/sources/scala/tools/nsc/transform/Mixin.scala +++ b/sources/scala/tools/nsc/transform/Mixin.scala @@ -24,11 +24,19 @@ abstract class Mixin extends InfoTransform { sym.owner.isImplClass && sym.isMethod && !sym.isModule && !(sym hasFlag (ACCESSOR | SUPERACCESSOR)); - private def isStatic(sym: Symbol) = isForwarded(sym) && (sym.hasFlag(PRIVATE) || sym.isConstructor); + private def isStatic(sym: Symbol) = isForwarded(sym) && sym.isImplOnly; private def toInterface(tp: Type): Type = atPhase(currentRun.mixinPhase)(tp.symbol.toInterface).tpe; + private val toInterfaceMap = new TypeMap { + def apply(tp: Type): Type = mapOver( tp match { + case TypeRef(pre, sym, args) if (sym.isImplClass) => + typeRef(pre, atPhase(currentRun.mixinPhase)(sym.toInterface), args) + case _ => tp + }) + } + private def rebindSuper(base: Symbol, member: Symbol, prevowner: Symbol): Symbol = atPhase(currentRun.refchecksPhase) { var bcs = base.info.baseClasses.dropWhile(prevowner !=).tail; @@ -80,9 +88,11 @@ abstract class Mixin extends InfoTransform { var setter = member.setter(clazz); if (setter == NoSymbol) setter = addMember(clazz, newSetter(member)); } - } else if ((member hasFlag (LIFTED | BRIDGE)) && !(member hasFlag PRIVATE)) { +/* + } else if ((member hasFlag BRIDGE) && !(member hasFlag PRIVATE)) { member.expandName(clazz); addMember(clazz, member.cloneSymbol(clazz) resetFlag FINAL); +*/ } } if (settings.debug.value) log("new defs of " + clazz + " = " + clazz.info.decls); @@ -182,8 +192,9 @@ abstract class Mixin extends InfoTransform { else ClassInfoType(parents1, decls1, clazz); case MethodType(formals, restp) => - if (isForwarded(sym)) MethodType(toInterface(sym.owner.typeOfThis) :: formals, restp) - else tp + toInterfaceMap( + if (isForwarded(sym)) MethodType(toInterface(sym.owner.typeOfThis) :: formals, restp) + else tp) case _ => tp @@ -338,7 +349,7 @@ abstract class Mixin extends InfoTransform { } assert(sym != NoSymbol, tree);//debug if (isStatic(sym)) { - assert(sym.isConstructor || currentOwner.enclClass.isImplClass, tree); + //assert(sym.isConstructor || currentOwner.enclClass.isImplClass, tree); staticCall(sym) } else qual match { case Super(_, mix) => @@ -364,6 +375,7 @@ abstract class Mixin extends InfoTransform { tree case Select(qual, name) if sym.owner.isImplClass && !isStatic(sym) => if (sym.isMethod) { + assert(false, sym);//!!! assert(sym hasFlag (LIFTED | BRIDGE), sym); val sym1 = toInterface(qual.tpe).member(sym.name); assert(sym1 != NoSymbol, sym);//debug |