diff options
author | paltherr <paltherr@epfl.ch> | 2003-09-08 00:50:35 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-09-08 00:50:35 +0000 |
commit | bb6372b1c9958dcd6c60d3e7802ea587f3f2f644 (patch) | |
tree | afe77e5a84721a99cb479726f08cee069419f4cf | |
parent | a9af998cdc3175c764fa0f17d276dfd96dfe1579 (diff) | |
download | scala-bb6372b1c9958dcd6c60d3e7802ea587f3f2f644.tar.gz scala-bb6372b1c9958dcd6c60d3e7802ea587f3f2f644.tar.bz2 scala-bb6372b1c9958dcd6c60d3e7802ea587f3f2f644.zip |
- Added more general getSubst methods in Type
- Added do nothing methods in Type.UdpdateSubstSymMap
-rw-r--r-- | sources/scalac/symtab/Type.java | 21 | ||||
-rw-r--r-- | sources/scalac/transformer/LambdaLift.java | 4 |
2 files changed, 20 insertions, 5 deletions
diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java index 427353bfdf..e3526f8830 100644 --- a/sources/scalac/symtab/Type.java +++ b/sources/scalac/symtab/Type.java @@ -1239,12 +1239,27 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { return super.apply(t); } } + public Symbol map(Symbol sym, boolean dontClone) { return sym; } + public Symbol[] map(Symbol[] syms, boolean dontClone) { return syms; } + public Scope map(Scope s) { return s; } + } + + /** Returns the given non-updating symbol/symbol substitution. */ + public static Map getSubst(Symbol[] from, Symbol[] to) { + return getSubst(from, to, false); + } + + /** Returns the given (updating?) symbol/symbol substitution. */ + public static Map getSubst(Symbol[] from, Symbol[] to, boolean update) { + if (from.length == 0 && to.length == 0) return IdMap; + if (update) return new UpdateSubstSymMap(from, to); + return new SubstSymMap(from, to); } - /** Returns an updating substitution map for given arguments. */ - public static Map getUpdateSubst(Symbol[] from, Symbol[] to) { + /** Returns the given non-updating symbol/type substitution. */ + public static Map getSubst(Symbol[] from, Type[] to) { if (from.length == 0 && to.length == 0) return IdMap; - return new UpdateSubstSymMap(from, to); + return new SubstTypeMap(from, to); } /** Substitute symbols `to' for occurrences of symbols `from' in this type. diff --git a/sources/scalac/transformer/LambdaLift.java b/sources/scalac/transformer/LambdaLift.java index 9e3a497c80..af1881ea7d 100644 --- a/sources/scalac/transformer/LambdaLift.java +++ b/sources/scalac/transformer/LambdaLift.java @@ -562,14 +562,14 @@ public class LambdaLift extends OwnerTransformer case MethodType(_, _): return Type.PolyType( newtparams, - Type.getUpdateSubst(oldtparams, newtparams).apply(tp)); + Type.getSubst(oldtparams, newtparams, true).apply(tp)); 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, - Type.getUpdateSubst(oldtparams, newtparams).apply(restpe)); + Type.getSubst(oldtparams, newtparams, true).apply(restpe)); default: throw new ApplicationError("illegal type: " + tp); } |