From 2300aac76adab6945ca2d2e3cb15320621a76150 Mon Sep 17 00:00:00 2001 From: schinz Date: Mon, 19 May 2003 11:09:34 +0000 Subject: - (final) bug fix: use the symbol of the class ... - (final) bug fix: use the symbol of the class for ThisTypes which appear its body. --- sources/scalac/transformer/AddInterfaces.java | 11 ++++++----- sources/scalac/transformer/AddInterfacesPhase.java | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) (limited to 'sources/scalac') 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): -- cgit v1.2.3