summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-03-09 14:52:18 +0000
committerMartin Odersky <odersky@gmail.com>2009-03-09 14:52:18 +0000
commitf3b5aed2b9e3da5a26e176c30abc2dd5c8c933ec (patch)
treef3e499070e035304e774fd8005f2be61f4e7cb97 /src
parentc5e4288affd10584fa28f21e58724a4490380b30 (diff)
downloadscala-f3b5aed2b9e3da5a26e176c30abc2dd5c8c933ec.tar.gz
scala-f3b5aed2b9e3da5a26e176c30abc2dd5c8c933ec.tar.bz2
scala-f3b5aed2b9e3da5a26e176c30abc2dd5c8c933ec.zip
made unsafeTypeParams transform infos less eage...
made unsafeTypeParams transform infos less eagerly. Fixed private[this] variance hole.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/Phase.scala1
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolTable.scala10
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala11
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala2
6 files changed, 22 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/Phase.scala b/src/compiler/scala/tools/nsc/Phase.scala
index aa07e50c4b..89b4e1c670 100644
--- a/src/compiler/scala/tools/nsc/Phase.scala
+++ b/src/compiler/scala/tools/nsc/Phase.scala
@@ -36,6 +36,7 @@ abstract class Phase(val prev: Phase) {
def devirtualized: Boolean = false
def erasedTypes: Boolean = false
def flatClasses: Boolean = false
+ def keepsTypeParams = false
def run: Unit
override def toString() = name
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
index f3bda9fb9c..efee88f195 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
@@ -219,7 +219,9 @@ abstract class SymbolLoaders {
if (membersModule.isModule) {
for (member <- membersModule.info.decls.elements) {
// todo: handle overlapping definitions in some way: mark as errors
- // or treat as abstractions.
+ // or treat as abstractions. For now the symbol in the package module takes precedence.
+ for (existing <- root.info.decl(member.name).alternatives)
+ root.info.decls.unlink(existing)
root.info.decls.enter(member)
}
}
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
index 6bfdcbff9b..c735bb246c 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
@@ -102,10 +102,12 @@ abstract class SymbolTable extends Names
/** Perform given operation at given phase */
final def atPhase[T](ph: Phase)(op: => T): T = {
val current = phase
- phase = ph
- val result = op
- phase = current
- result
+ try {
+ phase = ph
+ op
+ } finally {
+ phase = current
+ }
}
/** The set of all installed infotransformers */
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index be5f0defd4..391dd69059 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -756,7 +756,16 @@ trait Symbols {
* type parameters later.
*/
def unsafeTypeParams: List[Symbol] =
- if (isMonomorphicType) List() else rawInfo.typeParams
+ if (isMonomorphicType) List()
+ else {
+ val current = phase
+ try {
+ while (phase.keepsTypeParams) phase = phase.prev
+ rawInfo.typeParams
+ } finally {
+ phase = current
+ }
+ }
/** The type parameters of this symbol.
* assumption: if a type starts out as monomorphic, it will not acquire
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 3e3e38543d..3da9394b26 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -3796,7 +3796,7 @@ A type's typeSymbol should never be inspected directly.
val info1 = tp1.memberInfo(sym1)
val info2 = tp2.memberInfo(sym2).substThis(tp2.typeSymbol, tp1)
//System.out.println("specializes "+tp1+"."+sym1+":"+info1+sym1.locationString+" AND "+tp2+"."+sym2+":"+info2)//DEBUG
- sym2.isTerm && (info1 <:< info2) ||
+ sym2.isTerm && (info1 <:< info2) /*&& (!sym2.isStable || sym1.isStable) */ ||
sym2.isAbstractType && info2.bounds.containsType(tp1.memberType(sym1)) ||
sym2.isAliasType && tp2.memberType(sym2).substThis(tp2.typeSymbol, tp1) =:= tp1.memberType(sym1) //@MAT ok
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 6ed26ad128..28fea81d03 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -433,7 +433,7 @@ abstract class RefChecks extends InfoTransform {
!(tvar.isTypeParameterOrSkolem && sym.isTypeParameterOrSkolem &&
tvar.owner == sym.owner)) state = -state;
else if (!sym.owner.isClass ||
- ((sym.isPrivateLocal || sym.isProtectedLocal) && !(escapedPrivateLocals contains sym)))
+ sym.isTerm && ((sym.isPrivateLocal || sym.isProtectedLocal) && !(escapedPrivateLocals contains sym)))
state = AnyVariance
else if (sym.isAliasType)
state = NoVariance