diff options
Diffstat (limited to 'src')
11 files changed, 157 insertions, 98 deletions
diff --git a/src/compiler/scala/reflect/internal/HasFlags.scala b/src/compiler/scala/reflect/internal/HasFlags.scala index 46dca0940a..ec4e919bdc 100644 --- a/src/compiler/scala/reflect/internal/HasFlags.scala +++ b/src/compiler/scala/reflect/internal/HasFlags.scala @@ -136,6 +136,9 @@ trait HasFlags { /** Whether this entity has NONE of the flags in the given mask. */ def hasNoFlags(mask: Long): Boolean = !hasFlag(mask) + + protected def isSetting(f: Long, mask: Long) = !hasFlag(f) && ((mask & f) != 0L) + protected def isClearing(f: Long, mask: Long) = hasFlag(f) && ((mask & f) != 0L) // Tests which come through cleanly: both Symbol and Modifiers use these // identically, testing for a single flag. diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala index a73ab32960..df6720d497 100644 --- a/src/compiler/scala/reflect/internal/Symbols.scala +++ b/src/compiler/scala/reflect/internal/Symbols.scala @@ -42,6 +42,10 @@ trait Symbols extends api.Symbols { self: SymbolTable => m setModuleClass moduleClass m } + /** Create a new free variable. Its owner is NoSymbol. + */ + def newFreeVar(name: TermName, tpe: Type, value: Any, flags: Long = 0L): FreeVar = + new FreeVar(name, value) initFlags flags setInfo tpe /** The original owner of a class. Used by the backend to generate * EnclosingMethod attributes. @@ -79,7 +83,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => private var rawpos = initPos val id = { ids += 1; ids } // identity displayed when -uniqid - //assert(id != 3204, initName) var validTo: Period = NoPeriod @@ -146,15 +149,18 @@ trait Symbols extends api.Symbols { self: SymbolTable => newTermSymbol(nme.this_, pos, SYNTHETIC) final def newImport(pos: Position) = newTermSymbol(nme.IMPORT, pos) - + /** Direct symbol factories. * For internal use; these are unlikely to be what you want. */ def newTermSymbol(name: TermName, pos: Position = NoPosition, flags: Long = 0L): TermSymbol = new TermSymbol(this, pos, name) initFlags flags - def newTypeSymbol(name: TypeName, pos: Position = NoPosition, flags: Long = 0L): TypeSymbol = - new TypeSymbol(this, pos, name) initFlags flags + def newAbstractTypeSymbol(name: TypeName, pos: Position = NoPosition, flags: Long = 0L): AbstractTypeSymbol = + new AbstractTypeSymbol(this, pos, name) initFlags flags + + def newAliasTypeSymbol(name: TypeName, pos: Position = NoPosition, flags: Long = 0L): AliasTypeSymbol = + new AliasTypeSymbol(this, pos, name) initFlags flags def newModuleSymbol(name: TermName, pos: Position = NoPosition, flags: Long = 0L): ModuleSymbol = new ModuleSymbol(this, pos, name) initFlags flags @@ -167,9 +173,21 @@ trait Symbols extends api.Symbols { self: SymbolTable => def newModuleClassSymbol(name: TypeName, pos: Position = NoPosition, flags: Long = 0L): ModuleClassSymbol = new ModuleClassSymbol(this, pos, name) initFlags flags + + /** Derive whether it is an abstract type from the flags; after creation + * the DEFERRED flag will be ignored. + */ + def newTypeSymbol(name: TypeName, pos: Position = NoPosition, flags: Long = 0L): TypeSymbol = + if ((flags & DEFERRED) == 0L) + newAliasTypeSymbol(name, pos, flags) + else + newAbstractTypeSymbol(name, pos, flags) def newTypeSkolemSymbol(name: TypeName, origin: AnyRef, pos: Position = NoPosition, flags: Long = 0L): TypeSkolem = - new TypeSkolem(this, pos, name, origin) initFlags flags + if ((flags & DEFERRED) == 0L) + new TypeSkolem(this, pos, name, origin) initFlags flags + else + new TypeSkolem(this, pos, name, origin) with AbstractTypeMixin initFlags flags /** @param pre type relative to which alternatives are seen. * for instance: @@ -211,12 +229,12 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** Symbol of a type definition type T = ... */ final def newAliasType(name: TypeName, pos: Position = NoPosition, flags: Long = 0L): Symbol = - newTypeSymbol(name, pos, flags) + newAliasTypeSymbol(name, pos, flags) /** Symbol of an abstract type type T >: ... <: ... */ final def newAbstractType(name: TypeName, pos: Position = NoPosition, flags: Long = 0L): Symbol = - newTypeSymbol(name, pos, DEFERRED | flags) + newAbstractTypeSymbol(name, pos, DEFERRED | flags) /** Symbol of a type parameter */ @@ -231,11 +249,19 @@ trait Symbols extends api.Symbols { self: SymbolTable => mmap(argtypess)(tp => newValueParameter(freshName(), focusPos(owner.pos), SYNTHETIC) setInfo tp) } + /** Create a new existential type skolem with this symbol its owner, + * based on the given symbol and origin. + */ + def newExistentialSkolem(basis: Symbol, origin: AnyRef): TypeSkolem = { + val skolem = newTypeSkolemSymbol(basis.name.toTypeName, origin, basis.pos, (basis.flags | EXISTENTIAL) & ~PARAM) + skolem setInfo (basis.info cloneInfo skolem) + } + final def newExistential(name: TypeName, pos: Position = NoPosition, flags: Long = 0L): Symbol = newAbstractType(name, pos, EXISTENTIAL | flags) final def freshExistential(suffix: String): Symbol = - newExistential(pos, freshExistentialName(suffix)) + newExistential(freshExistentialName(suffix), pos) /** Synthetic value parameters when parameter symbols are not available. * Calling this method multiple times will re-use the same parameter names. @@ -1180,15 +1206,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => * the bound of the type variable that stands for it * pre: symbol is a term, a class, or an abstract type (no alias type allowed) */ - def existentialBound: Type = - if (this.isClass) - polyType(this.typeParams, TypeBounds.upper(this.classBound)) - else if (this.isAbstractType) - this.info - else if (this.isTerm) - singletonBounds(this.tpe) - else - abort("unexpected alias type: "+this.ownerChain+ " " + hasFlagsToString(-1L)) + def existentialBound: Type /** Reset symbol to initial state */ @@ -1322,17 +1340,17 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** A clone of this symbol, but with given owner. */ final def cloneSymbol(owner: Symbol): Symbol = { - val newSym = cloneSymbolImpl(owner) + val newSym = cloneSymbolImpl(owner, this.rawflags) ( newSym - initFlags this.rawflags setPrivateWithin privateWithin setInfo (info cloneInfo newSym) setAnnotations this.annotations ) } - - /** Internal method to clone a symbol's implementation without flags or type. */ - def cloneSymbolImpl(owner: Symbol): Symbol + + /** Internal method to clone a symbol's implementation with the given flags and no info. */ + def cloneSymbolImpl(owner: Symbol, newFlags: Long): Symbol + def cloneSymbolImpl(owner: Symbol): Symbol = cloneSymbolImpl(owner, 0L) // ------ access to related symbols -------------------------------------------------- @@ -2036,9 +2054,11 @@ trait Symbols extends api.Symbols { self: SymbolTable => privateWithin = NoSymbol var referenced: Symbol = NoSymbol + + def existentialBound = singletonBounds(this.tpe) - def cloneSymbolImpl(owner: Symbol): Symbol = - owner.newTermSymbol(name, pos).copyAttrsFrom(this) + def cloneSymbolImpl(owner: Symbol, newFlags: Long): Symbol = + owner.newTermSymbol(name, pos, newFlags).copyAttrsFrom(this) def copyAttrsFrom(original: TermSymbol): this.type = { referenced = original.referenced @@ -2134,8 +2154,8 @@ trait Symbols extends api.Symbols { self: SymbolTable => else rawname.toTermName ) - override def cloneSymbolImpl(owner: Symbol): Symbol = - owner.newModuleSymbol(name, pos).copyAttrsFrom(this) + override def cloneSymbolImpl(owner: Symbol, newFlags: Long): Symbol = + owner.newModuleSymbol(name, pos, newFlags).copyAttrsFrom(this) } /** A class for method symbols */ @@ -2146,8 +2166,8 @@ trait Symbols extends api.Symbols { self: SymbolTable => private var mtpeResult: Type = _ private var mtpeInfo: Type = _ - override def cloneSymbolImpl(owner: Symbol): Symbol = - owner.newMethodSymbol(name, pos).copyAttrsFrom(this) + override def cloneSymbolImpl(owner: Symbol, newFlags: Long): Symbol = + owner.newMethodSymbol(name, pos, newFlags).copyAttrsFrom(this) def typeAsMemberOf(pre: Type): Type = { if (mtpePeriod == currentPeriod) { @@ -2164,24 +2184,71 @@ trait Symbols extends api.Symbols { self: SymbolTable => res } } + + class AliasTypeSymbol(initOwner: Symbol, initPos: Position, initName: TypeName) + extends TypeSymbol(initOwner, initPos, initName) { + // Temporary programmatic help tracking down who might do such a thing + override def setFlag(mask: Long): this.type = { + if (isSetting(DEFERRED, mask)) { + println("Setting DEFERRED on alias at") + (new Throwable).printStackTrace + } + super.setFlag(mask) + } + final override def isAliasType = true + override def cloneSymbolImpl(owner: Symbol, newFlags: Long): AliasTypeSymbol = + owner.newAliasTypeSymbol(name, pos, newFlags) + } + + class AbstractTypeSymbol(initOwner: Symbol, initPos: Position, initName: TypeName) + extends TypeSymbol(initOwner, initPos, initName) with AbstractTypeMixin { + override def cloneSymbolImpl(owner: Symbol, newFlags: Long): AbstractTypeSymbol = + owner.newAbstractTypeSymbol(name, pos, newFlags) + } + + /** Might be mixed into TypeSymbol or TypeSkolem. + */ + trait AbstractTypeMixin extends TypeSymbol { + override def resetFlag(mask: Long): this.type = { + // Temporary programmatic help tracking down who might do such a thing + if (settings.debug.value) { + if (isClearing(DEFERRED, mask)) { + println("Clearing DEFERRED on abstract type at") + (new Throwable).printStackTrace + } + } + super.resetFlag(mask) + } + final override def isAbstractType = true + override def existentialBound = this.info + } /** A class of type symbols. Alias and abstract types are direct instances * of this class. Classes are instances of a subclass. */ - class TypeSymbol(initOwner: Symbol, initPos: Position, initName: TypeName) - extends Symbol(initOwner, initPos, initName) { + sealed abstract class TypeSymbol(initOwner: Symbol, initPos: Position, initName: TypeName) extends Symbol(initOwner, initPos, initName) { privateWithin = NoSymbol private var tyconCache: Type = null private var tyconRunId = NoRunId private var tpeCache: Type = _ private var tpePeriod = NoPeriod + /** Overridden in subclasses for which it makes sense. + */ + def existentialBound: Type = abort("unexpected type: "+this.getClass+ " "+this.fullLocationString+ " " + hasFlagsToString(-1L)) + override def name: TypeName = super.name.asInstanceOf[TypeName] final override def isType = true override def isNonClassType = true - override def isAbstractType = isDeferred - override def isAliasType = !isDeferred - + override def isAbstractType = { + if (settings.debug.value) { + if (isDeferred) { + println("TypeSymbol claims to be abstract type: " + this.getClass + " " + hasFlagsToString(-1L) + " at ") + (new Throwable).printStackTrace + } + } + isDeferred + } private def newTypeRef(targs: List[Type]) = { val pre = if (hasFlag(PARAM | EXISTENTIAL)) NoPrefix else owner.thisType typeRef(pre, this, targs) @@ -2278,7 +2345,8 @@ trait Symbols extends api.Symbols { self: SymbolTable => } } - def cloneSymbolImpl(owner: Symbol): Symbol = owner.newTypeSymbol(name, pos) + def cloneSymbolImpl(owner: Symbol, newFlags: Long): Symbol = + owner.newTypeSymbol(name, pos, newFlags) incCounter(typeSymbolCount) } @@ -2316,8 +2384,8 @@ trait Symbols extends api.Symbols { self: SymbolTable => //@M! (not deSkolemize.typeParams!!), also can't leave superclass definition: use info, not rawInfo override def typeParams = info.typeParams - override def cloneSymbolImpl(owner: Symbol): Symbol = - owner.newTypeSkolemSymbol(name, origin, pos) + override def cloneSymbolImpl(owner: Symbol, newFlags: Long): Symbol = + owner.newTypeSkolemSymbol(name, origin, pos, newFlags) override def nameString: String = if (settings.debug.value) (super.nameString + "&" + level) @@ -2335,6 +2403,8 @@ trait Symbols extends api.Symbols { self: SymbolTable => final override def isNonClassType = false final override def isAbstractType = false final override def isAliasType = false + + override def existentialBound = polyType(this.typeParams, TypeBounds.upper(this.classBound)) override def sourceFile = if (owner.isPackageClass) source @@ -2397,8 +2467,8 @@ trait Symbols extends api.Symbols { self: SymbolTable => thissym = newThisSym(pos).setInfo(tp) } - override def cloneSymbolImpl(owner: Symbol): Symbol = { - val clone = owner.newClassSymbol(name, pos) + override def cloneSymbolImpl(owner: Symbol, newFlags: Long): Symbol = { + val clone = owner.newClassSymbol(name, pos, newFlags) if (thisSym != this) { clone.typeOfThis = typeOfThis clone.thisSym.name = thisSym.name @@ -2447,18 +2517,12 @@ trait Symbols extends api.Symbols { self: SymbolTable => override def sourceModule = module override def sourceModule_=(module: Symbol) { this.module = module } } - - def newFreeVar(name0: TermName, tpe: Type, value: Any, flags: Long = 0L) = - new FreeVar(name0, tpe, value) initFlags flags - - class FreeVar(name0: TermName, tpe: Type, val value: Any) extends TermSymbol(definitions.RootClass, NoPosition, name0) { - setInfo(tpe) + class FreeVar(name0: TermName, val value: Any) extends TermSymbol(NoSymbol, NoPosition, name0) { override def hashCode = value.hashCode - override def equals(other: Any): Boolean = other match { case that: FreeVar => this.value.asInstanceOf[AnyRef] eq that.value.asInstanceOf[AnyRef] - case _ => false + case _ => false } } @@ -2485,10 +2549,11 @@ trait Symbols extends api.Symbols { self: SymbolTable => override def alternatives: List[Symbol] = List() override def reset(completer: Type) {} override def info: Type = NoType + override def existentialBound: Type = NoType override def rawInfo: Type = NoType protected def doCookJavaRawInfo() {} override def accessBoundary(base: Symbol): Symbol = RootClass - def cloneSymbolImpl(owner: Symbol): Symbol = abort() + def cloneSymbolImpl(owner: Symbol, newFlags: Long): Symbol = abort() override def originalEnclosingMethod = this } @@ -2560,13 +2625,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => */ def mapParamss[T](sym: Symbol)(f: Symbol => T): List[List[T]] = mmap(sym.info.paramss)(f) - /** Create a new existential type skolem with the given owner and origin. - */ - def newExistentialSkolem(sym: Symbol, owner: Symbol, origin: AnyRef): TypeSkolem = { - val skolem = owner.newTypeSkolemSymbol(sym.name.toTypeName, origin, sym.pos, (sym.flags | EXISTENTIAL) & ~PARAM) - skolem setInfo (sym.info cloneInfo skolem) - } - /** An exception for cyclic references of symbol definitions */ case class CyclicReference(sym: Symbol, info: Type) extends TypeError("illegal cyclic reference involving " + sym) { diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index fa62d00c6a..3bcd36131d 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -1868,12 +1868,28 @@ trait Types extends api.Types { self: SymbolTable => override def isVolatile = normalize.isVolatile override def narrow = normalize.narrow override def thisInfo = normalize - // override def prefix = normalize.prefix - // override def termSymbol = if (this ne normalize) normalize.termSymbol else super.termSymbol - // override def typeSymbol = if (this ne normalize) normalize.typeSymbol else sym + override def prefix = if (this ne normalize) normalize.prefix else pre + override def termSymbol = if (this ne normalize) normalize.termSymbol else super.termSymbol + override def typeSymbol = if (this ne normalize) normalize.typeSymbol else sym + // beta-reduce, but don't do partial application -- cycles have been checked in typeRef // override protected zzImpl = // if (typeParamsMatchArgs) betaReduce.normalize else ErrorType + + // #3731: return sym1 for which holds: pre bound sym.name to sym and + // pre1 now binds sym.name to sym1, conceptually exactly the same + // symbol as sym. The selection of sym on pre must be updated to the + // selection of sym1 on pre1, since sym's info was probably updated + // by the TypeMap to yield a new symbol, sym1 with transformed info. + // @returns sym1 + override def coevolveSym(pre1: Type): Symbol = + if (pre eq pre1) sym else (pre, pre1) match { + // don't look at parents -- it would be an error to override alias types anyway + case (RefinedType(_, _), RefinedType(_, decls1)) => decls1 lookup sym.name + // TODO: is there another way a typeref's symbol can refer to a symbol defined in its pre? + case _ => sym + } + } trait AbstractTypeRef extends NonClassTypeRef { @@ -1920,7 +1936,7 @@ trait Types extends api.Types { self: SymbolTable => thisInfoCache } override def isStable = bounds.hi.typeSymbol isSubClass SingletonClass - override def bounds = if (sym.isAbstractType) thisInfo.bounds else super.bounds + override def bounds = thisInfo.bounds // def transformInfo(tp: Type): Type = appliedType(tp.asSeenFrom(pre, sym.owner), typeArgsOrDummies) override protected def baseTypeSeqImpl: BaseTypeSeq = transform(bounds.hi).baseTypeSeq prepend this } @@ -1980,23 +1996,9 @@ trait Types extends api.Types { self: SymbolTable => else typeFunAnon(tpars, copyTypeRef(this, pre, sym, tpars map (_.tpeHK))) // todo: also beta-reduce? } - // #3731: return sym1 for which holds: pre bound sym.name to sym and - // pre1 now binds sym.name to sym1, conceptually exactly the same - // symbol as sym. The selection of sym on pre must be updated to the - // selection of sym1 on pre1, since sym's info was probably updated - // by the TypeMap to yield a new symbol, sym1 with transformed info. - // @returns sym1 - // // only need to rebind type aliases, as typeRef already handles abstract types // (they are allowed to be rebound more liberally) - def coevolveSym(pre1: Type): Symbol = - if (!sym.isAliasType || (pre eq pre1)) sym - else (pre, pre1) match { - // don't look at parents -- it would be an error to override alias types anyway - case (RefinedType(_, _), RefinedType(_, decls1)) => decls1 lookup sym.name - // TODO: is there another way a typeref's symbol can refer to a symbol defined in its pre? - case _ => sym - } + def coevolveSym(pre1: Type): Symbol = sym //@M! use appliedType on the polytype that represents the bounds (or if aliastype, the rhs) def transformInfo(tp: Type): Type = appliedType(asSeenFromOwner(tp), args) @@ -2009,13 +2011,13 @@ trait Types extends api.Types { self: SymbolTable => override def baseClasses = thisInfo.baseClasses override def baseTypeSeqDepth = baseTypeSeq.maxDepth override def isStable = (sym eq NothingClass) || (sym eq SingletonClass) - override def prefix = if (sym.isAliasType && (this ne normalize)) normalize.prefix else pre + override def prefix = pre + override def termSymbol = super.termSymbol + override def termSymbolDirect = super.termSymbol override def typeArgs = args override def typeOfThis = transform(sym.typeOfThis) - override def termSymbol = if (sym.isAliasType && (this ne normalize)) normalize.termSymbol else super.termSymbol - override def typeSymbol = if (sym.isAliasType && (this ne normalize)) normalize.typeSymbol else sym + override def typeSymbol = sym override def typeSymbolDirect = sym - override def termSymbolDirect = super.termSymbol override lazy val isTrivial: Boolean = !sym.isTypeParameter && pre.isTrivial && args.forall(_.isTrivial) @@ -2332,7 +2334,7 @@ trait Types extends api.Types { self: SymbolTable => override def isHigherKinded = false override def skolemizeExistential(owner: Symbol, origin: AnyRef) = - deriveType(quantified, tparam => newExistentialSkolem(tparam, owner orElse tparam.owner, origin))(underlying) + deriveType(quantified, tparam => (owner orElse tparam.owner).newExistentialSkolem(tparam, origin))(underlying) private def wildcardArgsString(available: Set[Symbol], args: List[Type]): List[String] = args match { case TypeRef(_, sym, _) :: args1 if (available contains sym) => diff --git a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala index 3fddc990e4..b21b33e138 100644 --- a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala @@ -282,7 +282,7 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ { finishSym(tag match { case TYPEsym => owner.newAbstractType(name.toTypeName) - case ALIASsym => owner.newTypeSymbol(name.toTypeName) + case ALIASsym => owner.newAliasType(name.toTypeName) case CLASSsym => val sym = (isClassRoot, isModuleFlag) match { case (true, true) => moduleRoot.moduleClass diff --git a/src/compiler/scala/reflect/runtime/JavaToScala.scala b/src/compiler/scala/reflect/runtime/JavaToScala.scala index fd3b9b9aa0..627bad632e 100644 --- a/src/compiler/scala/reflect/runtime/JavaToScala.scala +++ b/src/compiler/scala/reflect/runtime/JavaToScala.scala @@ -154,7 +154,7 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable => override def load(sym: Symbol) = { debugInfo("completing from Java " + sym + "/" + clazz.fullName)//debug assert(sym == clazz || (module != NoSymbol && (sym == module || sym == module.moduleClass)), sym) - val flags = toScalaFlags(jclazz.getModifiers, isClass = true) + val flags = toScalaClassFlags(jclazz.getModifiers) clazz setFlag (flags | JAVA) if (module != NoSymbol) { module setFlag (flags & PRIVATE | JAVA) @@ -469,7 +469,7 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable => */ private def jfieldAsScala(jfield: jField): Symbol = fieldCache.toScala(jfield) { val field = sOwner(jfield).newValue(NoPosition, newTermName(jfield.getName)) - .setFlag(toScalaFlags(jfield.getModifiers, isField = true) | JAVA) + .setFlag(toScalaFieldFlags(jfield.getModifiers) | JAVA) .setInfo(typeToScala(jfield.getGenericType)) fieldCache enter (jfield, field) copyAnnotations(field, jfield) @@ -489,7 +489,7 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable => private def jmethodAsScala(jmeth: jMethod): Symbol = methodCache.toScala(jmeth) { val clazz = sOwner(jmeth) val meth = clazz.newMethod(NoPosition, newTermName(jmeth.getName)) - .setFlag(toScalaFlags(jmeth.getModifiers) | JAVA) + .setFlag(toScalaMethodFlags(jmeth.getModifiers) | JAVA) methodCache enter (jmeth, meth) val tparams = jmeth.getTypeParameters.toList map createTypeParameter val paramtpes = jmeth.getGenericParameterTypes.toList map typeToScala @@ -512,7 +512,7 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable => // [Martin] Note: I know there's a lot of duplication wrt jmethodAsScala, but don't think it's worth it to factor this out. val clazz = sOwner(jconstr) val constr = clazz.newMethod(NoPosition, nme.CONSTRUCTOR) - .setFlag(toScalaFlags(jconstr.getModifiers) | JAVA) + .setFlag(toScalaMethodFlags(jconstr.getModifiers) | JAVA) constructorCache enter (jconstr, constr) val tparams = jconstr.getTypeParameters.toList map createTypeParameter val paramtpes = jconstr.getGenericParameterTypes.toList map typeToScala diff --git a/src/compiler/scala/reflect/runtime/TreeBuildUtil.scala b/src/compiler/scala/reflect/runtime/TreeBuildUtil.scala index 9d66ca6c6e..fc4177e956 100644 --- a/src/compiler/scala/reflect/runtime/TreeBuildUtil.scala +++ b/src/compiler/scala/reflect/runtime/TreeBuildUtil.scala @@ -39,7 +39,7 @@ trait TreeBuildUtil extends Universe with api.TreeBuildUtil { selectIn(owner.info, idx) } - def freeVar(name: String, info: Type, value: Any) = new FreeVar(newTermName(name), info, value) + def freeVar(name: String, info: Type, value: Any) = newFreeVar(newTermName(name), info, value) def modifiersFromInternalFlags(flags: Long, privateWithin: Name, annotations: List[Tree]): Modifiers = Modifiers(flags, privateWithin, annotations) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 61521ea250..eedc68fb46 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -499,7 +499,7 @@ abstract class ClassfileParser { def parseClass() { val jflags = in.nextChar val isAnnotation = hasAnnotation(jflags) - var sflags = toScalaFlags(jflags, isClass = true) + var sflags = toScalaClassFlags(jflags) var nameIdx = in.nextChar externalName = pool.getClassName(nameIdx) val c = if (externalName.toString.indexOf('$') < 0) pool.getClassSymbol(nameIdx) else clazz @@ -604,7 +604,7 @@ abstract class ClassfileParser { def parseField() { val jflags = in.nextChar - var sflags = toScalaFlags(jflags, isField = true) + var sflags = toScalaFieldFlags(jflags) if ((sflags & PRIVATE) != 0L && !global.settings.XO.value) { in.skip(4); skipAttributes() } else { @@ -635,7 +635,7 @@ abstract class ClassfileParser { def parseMethod() { val jflags = in.nextChar.toInt - var sflags = toScalaFlags(jflags) + var sflags = toScalaMethodFlags(jflags) if (isPrivate(jflags) && !global.settings.XO.value) { val name = pool.getName(in.nextChar) if (name == nme.CONSTRUCTOR) @@ -1074,7 +1074,7 @@ abstract class ClassfileParser { def enterClassAndModule(entry: InnerClassEntry, completer: global.loaders.SymbolLoader, jflags: Int) { val name = entry.originalName - var sflags = toScalaFlags(jflags, isClass = true) + var sflags = toScalaClassFlags(jflags) val innerClass = getOwner(jflags).newClass(name.toTypeName).setInfo(completer).setFlag(sflags) val innerModule = getOwner(jflags).newModule(name.toTermName).setInfo(completer).setFlag(sflags) diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index f3b1e77c8d..71696c24e6 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -768,10 +768,8 @@ abstract class Erasure extends AddInterfaces } ); if (bridgeNeeded) { - val bridge = other.cloneSymbolImpl(owner) - .setPos(owner.pos) - .setFlag(member.flags | BRIDGE) - .resetFlag(ACCESSOR | DEFERRED | LAZY | lateDEFERRED) + val newFlags = (member.flags | BRIDGE) & ~(ACCESSOR | DEFERRED | LAZY | lateDEFERRED) + val bridge = other.cloneSymbolImpl(owner, newFlags) setPos owner.pos // the parameter symbols need to have the new owner bridge.setInfo(otpe.cloneInfo(bridge)) bridgeTarget(bridge) = member diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 71c0de10ff..354b8caaa3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1390,10 +1390,9 @@ trait Namers extends MethodSynthesis { ) if (sym hasAnnotation NativeAttr) sym resetFlag DEFERRED - else if (!symbolAllowsDeferred && ownerRequiresConcrete) { + else if (!symbolAllowsDeferred && ownerRequiresConcrete) fail("only classes can have declared but undefined members" + abstractVarMessage(sym)) - sym resetFlag DEFERRED - } + checkWithDeferred(PRIVATE) checkWithDeferred(FINAL) } diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 42a60666de..78b3446157 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -171,8 +171,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R def varargBridge(member: Symbol, bridgetpe: Type): Tree = { log("Generating varargs bridge for " + member.fullLocationString + " of type " + bridgetpe) - val bridge = member.cloneSymbolImpl(clazz) - .setPos(clazz.pos).setFlag(member.flags | VBRIDGE) + val bridge = member.cloneSymbolImpl(clazz, member.flags | VBRIDGE) setPos clazz.pos bridge.setInfo(bridgetpe.cloneInfo(bridge)) clazz.info.decls enter bridge diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 9bb8b1ea8b..243d922732 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2542,7 +2542,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { val pattp = typer1.infer.inferTypedPattern(tree.pos, unappFormal, arg.tpe) // turn any unresolved type variables in freevars into existential skolems - val skolems = freeVars map (fv => newExistentialSkolem(fv, unapplyContext.owner, fv)) + val skolems = freeVars map (fv => unapplyContext.owner.newExistentialSkolem(fv, fv)) arg.tpe = pattp.substSym(freeVars, skolems) argDummy setInfo arg.tpe } |