From b56a6d699c9003e8412955fe16159351578cf92b Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 13 Aug 2003 10:53:30 +0000 Subject: *** empty log message *** --- sources/scalac/ast/parser/Parser.java | 27 ++----------------------- sources/scalac/transformer/LambdaLift.java | 23 +++++++++++++-------- sources/scalac/transformer/LambdaLiftPhase.java | 6 ------ 3 files changed, 17 insertions(+), 39 deletions(-) (limited to 'sources') diff --git a/sources/scalac/ast/parser/Parser.java b/sources/scalac/ast/parser/Parser.java index 55405821ef..c58c8af46e 100644 --- a/sources/scalac/ast/parser/Parser.java +++ b/sources/scalac/ast/parser/Parser.java @@ -324,31 +324,8 @@ public class Parser implements Tokens { new Tree[]{finalizer}); return t; } -/* - Tree makeWhile(int pos, Tree cond, Tree body) { - return - make.Apply( - pos, - make.Apply( - pos, ScalaRunTimeDot(pos, Names.While), new Tree[]{cond}), - new Tree[]{body}); - } - - Tree makeDoWhile(int pos, Tree body, Tree cond) { - return - make.Apply( - pos, - make.Select( - pos, - make.Apply( - pos, - ScalaRunTimeDot(pos, Names.Do), - new Tree[]{body}), - Names.While), - new Tree[]{cond}); - } -*/ - Tree makeWhile(int pos, Name lname, Tree cond, Tree body) { + + Tree makeWhile(int pos, Name lname, Tree cond, Tree body) { Tree continu = make.Apply( pos, make.Ident(pos, lname), Tree.EMPTY_ARRAY); Tree rhs = make.If( 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) { -- cgit v1.2.3