diff options
Diffstat (limited to 'sources/scalac/transformer')
-rw-r--r-- | sources/scalac/transformer/LambdaLift.java | 23 | ||||
-rw-r--r-- | sources/scalac/transformer/LambdaLiftPhase.java | 6 |
2 files changed, 15 insertions, 14 deletions
diff --git a/sources/scalac/transformer/LambdaLift.java b/sources/scalac/transformer/LambdaLift.java index 099b26a46d..9651f928dd 100644 --- a/sources/scalac/transformer/LambdaLift.java +++ b/sources/scalac/transformer/LambdaLift.java @@ -488,18 +488,24 @@ public class LambdaLift extends OwnerTransformer ((ClassDef) tree).mods |= LIFTED; Symbol sym = tree.symbol(); assert sym.isLocal() : sym; - liftSymbol(sym, ftvsParams(sym.primaryConstructor()), fvsParams(sym.primaryConstructor())); + Symbol constr = sym.primaryConstructor(); + liftSymbol( + sym, get(free.ftvs, constr).toArray(), + ftvsParams(constr), fvsParams(constr)); break; case DefDef(_, _, _, _, _, _): ((DefDef) tree).mods |= LIFTED; Symbol sym = tree.symbol(); assert sym.isLocal() : sym; - liftSymbol(sym, ftvsParams(sym), fvsParams(sym)); + liftSymbol( + sym, get(free.ftvs, sym).toArray(), + ftvsParams(sym), fvsParams(sym)); } } - void liftSymbol(Symbol sym, Symbol[] newtparams, Symbol[] newparams) { + void liftSymbol(Symbol sym, Symbol[] oldtparams, + Symbol[] newtparams, Symbol[] newparams) { Symbol enclClass = sym.owner().enclClass(); if (!sym.isPrimaryConstructor()) sym.setOwner(enclClass); if (!sym.isConstructor()) enclClass.members().enter(sym); @@ -507,28 +513,29 @@ public class LambdaLift extends OwnerTransformer if (newtparams.length != 0 || newparams.length != 0) { sym.updateInfo( addParams( - addTypeParams(sym.infoAt(descr.nextPhase), newtparams), + addTypeParams( + sym.infoAt(descr.nextPhase), oldtparams, newtparams), newparams)); if (global.debug) global.log(sym + " has now type " + sym.typeAt(descr.nextPhase)); } } else if (sym.kind == CLASS) { - liftSymbol(sym.primaryConstructor(), newtparams, newparams); + liftSymbol(sym.primaryConstructor(), oldtparams, newtparams, newparams); } else { throw new ApplicationError(); } } - Type addTypeParams(Type tp, Symbol[] newtparams) { + Type addTypeParams(Type tp, Symbol[] oldtparams, Symbol[] newtparams) { if (newtparams.length == 0) return tp; switch (tp) { case MethodType(_, _): - return Type.PolyType(newtparams, tp); + return Type.PolyType(newtparams, tp.subst(oldtparams, newtparams)); case PolyType(Symbol[] tparams, Type restpe): Symbol[] tparams1 = new Symbol[tparams.length + newtparams.length]; System.arraycopy(tparams, 0, tparams1, 0, tparams.length); System.arraycopy(newtparams, 0, tparams1, tparams.length, newtparams.length); - return Type.PolyType(tparams1, restpe); + return Type.PolyType(tparams1, restpe.subst(oldtparams, newtparams)); default: throw new ApplicationError("illegal type: " + tp); } diff --git a/sources/scalac/transformer/LambdaLiftPhase.java b/sources/scalac/transformer/LambdaLiftPhase.java index 3406fb2236..f6f986e626 100644 --- a/sources/scalac/transformer/LambdaLiftPhase.java +++ b/sources/scalac/transformer/LambdaLiftPhase.java @@ -98,12 +98,6 @@ public class LambdaLiftPhase extends PhaseDescriptor implements Kinds, Modifiers case ThisType(_): if (sym.kind == CLASS && sym.primaryConstructor().isUpdated(nextPhase)) { - // !!! For some Java classes, - // Symbol.constructor() returns an Overloaded - // symbol. This is wrong as constructor() - // should return the primary constructor. Once - // this problem is solved, the following - // switch can be removed. Type constrtype = sym.primaryConstructor().infoAt(nextPhase); Symbol[] tparams; switch (constrtype) { |