From bb6372b1c9958dcd6c60d3e7802ea587f3f2f644 Mon Sep 17 00:00:00 2001 From: paltherr Date: Mon, 8 Sep 2003 00:50:35 +0000 Subject: - Added more general getSubst methods in Type - Added do nothing methods in Type.UdpdateSubstSymMap --- sources/scalac/symtab/Type.java | 21 ++++++++++++++++++--- sources/scalac/transformer/LambdaLift.java | 4 ++-- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'sources') 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); } -- cgit v1.2.3