summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2010-02-26 18:31:35 +0000
committerMartin Odersky <odersky@gmail.com>2010-02-26 18:31:35 +0000
commit462e27a358fc466d51aaeec28c994c6667d320eb (patch)
tree9d17b193c5062949116e88f0ca9ec61d1aa2056d /src
parent2b1513b35e3172a9045946f2621167a7310a1855 (diff)
downloadscala-462e27a358fc466d51aaeec28c994c6667d320eb.tar.gz
scala-462e27a358fc466d51aaeec28c994c6667d320eb.tar.bz2
scala-462e27a358fc466d51aaeec28c994c6667d320eb.zip
closes #3082, review by rytz
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala35
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
-rw-r--r--src/library/scala/collection/SeqLike.scala4
-rw-r--r--src/library/scala/util/logging/ConsoleLogger.scala2
6 files changed, 36 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 1ab0632e50..c4407e1f0b 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -758,6 +758,8 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
/** Set initial info. */
def setInfo(info: Type): this.type = { info_=(info); this }
+ def setInfoOwnerAdjusted(info: Type): this.type = setInfo(info.atOwner(this))
+
/** Set new info valid from start of this phase. */
final def updateInfo(info: Type): Symbol = {
assert(phaseId(infos.validFrom) <= phase.id)
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 94600f9c56..d4281c169e 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -225,6 +225,7 @@ trait Types extends reflect.generic.Types { self: SymbolTable =>
override def normalize = maybeRewrap(underlying.normalize)
override def dealias = maybeRewrap(underlying.dealias)
override def cloneInfo(owner: Symbol) = maybeRewrap(underlying.cloneInfo(owner))
+ override def atOwner(owner: Symbol) = maybeRewrap(underlying.atOwner(owner))
override def prefixString = underlying.prefixString
override def isComplete = underlying.isComplete
override def complete(sym: Symbol) = underlying.complete(sym)
@@ -718,6 +719,10 @@ trait Types extends reflect.generic.Types { self: SymbolTable =>
*/
def cloneInfo(owner: Symbol) = this
+ /** Make sure this type is correct as the info of given owner; clone it if not.
+ */
+ def atOwner(owner: Symbol) = this
+
protected def objectPrefix = "object "
protected def packagePrefix = "package "
@@ -1886,6 +1891,12 @@ A type's typeSymbol should never be inspected directly.
copyMethodType(this, vparams, resultType.substSym(params, vparams).cloneInfo(owner))
}
+ override def atOwner(owner: Symbol) =
+ if ((params exists (_.owner != owner)) || (resultType.atOwner(owner) ne resultType))
+ cloneInfo(owner)
+ else
+ this
+
override def kind = "MethodType"
}
@@ -1944,6 +1955,12 @@ A type's typeSymbol should never be inspected directly.
PolyType(tparams, resultType.substSym(typeParams, tparams).cloneInfo(owner))
}
+ override def atOwner(owner: Symbol) =
+ if ((typeParams exists (_.owner != owner)) || (resultType.atOwner(owner) ne resultType))
+ cloneInfo(owner)
+ else
+ this
+
override def kind = "PolyType"
}
@@ -2028,6 +2045,9 @@ A type's typeSymbol should never be inspected directly.
ExistentialType(tparams, underlying.substSym(quantified, tparams))
}
+ override def atOwner(owner: Symbol) =
+ if (quantified exists (_.owner != owner)) cloneInfo(owner) else this
+
override def kind = "ExistentialType"
def withTypeVars(op: Type => Boolean): Boolean = withTypeVars(op, AnyDepth)
@@ -4781,10 +4801,9 @@ A type's typeSymbol should never be inspected directly.
case List() => NothingClass.tpe
case List(t) => t
case ts @ PolyType(tparams, _) :: _ =>
- PolyType(
- (tparams, matchingBounds(ts, tparams).transpose).zipped map
- ((tparam, bounds) => tparam.cloneSymbol.setInfo(glb(bounds, depth))),
- lub0(matchingInstTypes(ts, tparams)))
+ val tparams1 = (tparams, matchingBounds(ts, tparams).transpose).zipped map
+ ((tparam, bounds) => tparam.cloneSymbol.setInfo(glb(bounds, depth)))
+ PolyType(tparams1, lub0(matchingInstTypes(ts, tparams1)))
case ts @ MethodType(params, _) :: rest =>
MethodType(params, lub0(matchingRestypes(ts, params map (_.tpe))))
case ts @ TypeBounds(_, _) :: rest =>
@@ -4812,14 +4831,14 @@ A type's typeSymbol should never be inspected directly.
val symtypes =
(narrowts, syms).zipped map ((t, sym) => t.memberInfo(sym).substThis(t.typeSymbol, lubThisType))
if (proto.isTerm) // possible problem: owner of info is still the old one, instead of new refinement class
- proto.cloneSymbol(lubRefined.typeSymbol).setInfo(lub(symtypes, decr(depth)))
+ proto.cloneSymbol(lubRefined.typeSymbol).setInfoOwnerAdjusted(lub(symtypes, decr(depth)))
else if (symtypes.tail forall (symtypes.head =:=))
- proto.cloneSymbol(lubRefined.typeSymbol).setInfo(symtypes.head)
+ proto.cloneSymbol(lubRefined.typeSymbol).setInfoOwnerAdjusted(symtypes.head)
else {
def lubBounds(bnds: List[TypeBounds]): TypeBounds =
TypeBounds(glb(bnds map (_.lo), decr(depth)), lub(bnds map (_.hi), decr(depth)))
lubRefined.typeSymbol.newAbstractType(proto.pos, proto.name)
- .setInfo(lubBounds(symtypes map (_.bounds)))
+ .setInfoOwnerAdjusted(lubBounds(symtypes map (_.bounds)))
}
}
}
@@ -4918,7 +4937,7 @@ A type's typeSymbol should never be inspected directly.
) yield alt
val symtypes = syms map glbThisType.memberInfo
assert(!symtypes.isEmpty)
- proto.cloneSymbol(glbRefined.typeSymbol).setInfo(
+ proto.cloneSymbol(glbRefined.typeSymbol).setInfoOwnerAdjusted(
if (proto.isTerm) glb(symtypes, decr(depth))
else {
def isTypeBound(tp: Type) = tp match {
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
index 02f0adc8a1..ba45165d52 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
@@ -68,7 +68,7 @@ abstract class Pickler extends SubComponent {
private val index = new LinkedHashMap[AnyRef, Int]
// collect higher-order type params
- private var locals: Set[Symbol] = Set()
+ //private var locals: Set[Symbol] = Set()
// private var boundSyms: List[Symbol] = Nil
@@ -92,7 +92,7 @@ abstract class Pickler extends SubComponent {
(isRootSym(sym) ||
sym.isRefinementClass ||
sym.isAbstractType && sym.hasFlag(EXISTENTIAL) || // existential param
- (locals contains sym) || // higher-order type param
+ (sym hasFlag PARAM) ||
isLocal(sym.owner))
private def staticAnnotations(annots: List[AnnotationInfo]) =
@@ -193,9 +193,11 @@ abstract class Pickler extends SubComponent {
case MethodType(params, restpe) =>
putType(restpe); putSymbols(params)
case PolyType(tparams, restpe) =>
+ /** no longer needed since all params are now local
tparams foreach { tparam =>
if (!isLocal(tparam)) locals += tparam // similar to existential types, these tparams are local
}
+ */
putType(restpe); putSymbols(tparams)
case ExistentialType(tparams, restpe) =>
// val savedBoundSyms = boundSyms // boundSyms are known to be local based on the EXISTENTIAL flag (see isLocal)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 380a0112f6..504e940848 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1896,7 +1896,7 @@ trait Typers { self: Analyzer =>
val sym2 = namer.enterInScope(
context.owner.newLabel(ldef.pos, ldef.name) setInfo MethodType(List(), restpe))
//val subst = new TreeSymSubstituter(List(ldef.symbol), List(sym2))
- val rhs2 = typed(ldef.rhs/*subst(ldef.rhs)*/, restpe)
+ val rhs2 = typed(ldef.rhs, restpe)
ldef.params foreach (param => param.tpe = param.symbol.tpe)
treeCopy.LabelDef(ldef, ldef.name, ldef.params, rhs2) setSymbol sym2 setType restpe
}
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala
index d06dd832f5..b1c9316f49 100644
--- a/src/library/scala/collection/SeqLike.scala
+++ b/src/library/scala/collection/SeqLike.scala
@@ -630,7 +630,7 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self =>
* @tparam B the element type of the returned $coll.
* @tparam That $thatinfo
* @param bf $bfinfo
- * @return a new collection of type `That` consisting of all elements of this $coll
+ * @return a new $coll consisting of all elements of this $coll
* except that `replaced` elements starting from `from` are replaced
* by `patch`.
* @usecase def patch(from: Int, that: Seq[A], replaced: Int): $Coll[A]
@@ -653,7 +653,7 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self =>
* @tparam B the element type of the returned $coll.
* @tparam That $thatinfo
* @param bf $bfinfo
- * @return a new collection of type `That` which is a copy of this $coll with the element at position `index` replaced by `elem`.
+ * @return a new $coll` which is a copy of this $coll with the element at position `index` replaced by `elem`.
* @usecase def updated(index: Int, elem: A): $Coll[A]
* @return a copy of this $coll with the element at position `index` replaced by `elem`.
*/
diff --git a/src/library/scala/util/logging/ConsoleLogger.scala b/src/library/scala/util/logging/ConsoleLogger.scala
index d4ef268e37..ec4148abc9 100644
--- a/src/library/scala/util/logging/ConsoleLogger.scala
+++ b/src/library/scala/util/logging/ConsoleLogger.scala
@@ -21,8 +21,6 @@ package scala.util.logging
trait ConsoleLogger extends Logged {
/** logs argument to Console using <code>Console.println</code>
- *
- * @param msg ...
*/
override def log(msg: String): Unit = Console.println(msg)
}