summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2003-08-13 10:53:30 +0000
committerMartin Odersky <odersky@gmail.com>2003-08-13 10:53:30 +0000
commitb56a6d699c9003e8412955fe16159351578cf92b (patch)
treeab307d835a9502c40570939537cc5cc6901d5ca3 /sources
parent1bbbb4c44fc0ea2fd36d18b579474efb7641fd09 (diff)
downloadscala-b56a6d699c9003e8412955fe16159351578cf92b.tar.gz
scala-b56a6d699c9003e8412955fe16159351578cf92b.tar.bz2
scala-b56a6d699c9003e8412955fe16159351578cf92b.zip
*** empty log message ***
Diffstat (limited to 'sources')
-rw-r--r--sources/scalac/ast/parser/Parser.java27
-rw-r--r--sources/scalac/transformer/LambdaLift.java23
-rw-r--r--sources/scalac/transformer/LambdaLiftPhase.java6
3 files changed, 17 insertions, 39 deletions
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) {