summaryrefslogtreecommitdiff
path: root/sources/scalac
diff options
context:
space:
mode:
authorschinz <schinz@epfl.ch>2003-05-19 11:09:34 +0000
committerschinz <schinz@epfl.ch>2003-05-19 11:09:34 +0000
commit2300aac76adab6945ca2d2e3cb15320621a76150 (patch)
treea6ddb7cd93b328751822f596250da009a9a00a27 /sources/scalac
parent969e41ca39c84fea500d4284b7b1d56e84e2d611 (diff)
downloadscala-2300aac76adab6945ca2d2e3cb15320621a76150.tar.gz
scala-2300aac76adab6945ca2d2e3cb15320621a76150.tar.bz2
scala-2300aac76adab6945ca2d2e3cb15320621a76150.zip
- (final) bug fix: use the symbol of the class ...
- (final) bug fix: use the symbol of the class for ThisTypes which appear its body.
Diffstat (limited to 'sources/scalac')
-rw-r--r--sources/scalac/transformer/AddInterfaces.java11
-rw-r--r--sources/scalac/transformer/AddInterfacesPhase.java21
2 files changed, 22 insertions, 10 deletions
diff --git a/sources/scalac/transformer/AddInterfaces.java b/sources/scalac/transformer/AddInterfaces.java
index 6e16eeb351..b67774428a 100644
--- a/sources/scalac/transformer/AddInterfaces.java
+++ b/sources/scalac/transformer/AddInterfaces.java
@@ -86,11 +86,12 @@ class AddInterfaces extends Transformer {
if (ownerSubst != null && ownerSubst.fst == sym.owner())
sym.setOwner((Symbol)ownerSubst.snd);
- // Update symbol's type. TODO is this needed? Shouldn't
- // the type of the members be updated in transformInfo.
- // Here we should only be concerned by the type symbols
- // appearing in the tree, not in the type.
- //sym.updateInfo(typeMap.map(sym.info()));
+ // Update symbol's type. Do that only for symbols which do
+ // not belong to a class, since the type of these (i.e.
+ // class members) has been changed during cloning
+ // operation.
+ if (! (sym.owner().isClass() || thisTypeSubst == null))
+ sym.updateInfo(typeSubst.apply(sym.info()));
}
switch (tree) {
diff --git a/sources/scalac/transformer/AddInterfacesPhase.java b/sources/scalac/transformer/AddInterfacesPhase.java
index 22e7833199..38f25a4d85 100644
--- a/sources/scalac/transformer/AddInterfacesPhase.java
+++ b/sources/scalac/transformer/AddInterfacesPhase.java
@@ -190,13 +190,15 @@ public class AddInterfacesPhase extends PhaseDescriptor {
* to use these new symbols. Also applies the given substitution
* to the cloned symbols' type. */
protected Symbol deepCloneSymbol(Symbol original,
+ Symbol oldOwner,
Symbol newOwner,
SymbolSubstTypeMap map) {
+ SymbolSubstTypeMap symMap;
Symbol clone = cloneSymbol(original, newOwner);
if (clone.isMethod()) {
Symbol[] tparams = clone.typeParams();
Symbol[] newTParams = new Symbol[tparams.length];
- SymbolSubstTypeMap symMap = new SymbolSubstTypeMap(map);
+ symMap = new SymbolSubstTypeMap(map);
for (int i = 0; i < tparams.length; ++i) {
newTParams[i] = cloneSymbol(tparams[i], clone);
symMap.insertSymbol(tparams[i], newTParams[i]);
@@ -209,9 +211,12 @@ public class AddInterfacesPhase extends PhaseDescriptor {
newVParams[i].updateInfo(symMap.apply(newVParams[i].info()));
symMap.insertSymbol(vparams[i], newVParams[i]);
}
+ } else
+ symMap = map;
- clone.updateInfo(substParams(clone.info(), symMap));
- }
+ ThisTypeMap thisTypeMap = new ThisTypeMap(oldOwner, newOwner);
+ Type newTp = thisTypeMap.apply(substParams(clone.info(), symMap));
+ clone.updateInfo(newTp);
return clone;
}
@@ -287,8 +292,10 @@ public class AddInterfacesPhase extends PhaseDescriptor {
} else if (ifaceMemberSym.isProtected())
ifaceMemberSym.flags ^= Modifiers.PROTECTED;
- classMemberSym =
- deepCloneSymbol(ifaceMemberSym, classSym, paramsSubst);
+ classMemberSym = deepCloneSymbol(ifaceMemberSym,
+ ifaceSym,
+ classSym,
+ paramsSubst);
ifaceMemberSym.flags |= Modifiers.DEFERRED;
classMemberSym.updateInfo(thisTpMap.apply(classMemberSym.info()));
@@ -450,6 +457,10 @@ class ThisTypeMap extends Type.Map {
this.sym = sym; this.tp = tp;
}
+ public ThisTypeMap(Symbol oldSym, Symbol newSym) {
+ this(oldSym, new Type.ThisType(newSym));
+ }
+
public Type apply(Type t) {
switch (t) {
case ThisType(Symbol s):