summaryrefslogtreecommitdiff
path: root/sources/scalac/symtab/SymbolCloner.java
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-01-08 18:51:33 +0000
committerpaltherr <paltherr@epfl.ch>2004-01-08 18:51:33 +0000
commitc5dcb8d01fe46c21695a12094206c24af8fe4d50 (patch)
tree30b05efa1a1b1ed484064bbe93390fea792817ac /sources/scalac/symtab/SymbolCloner.java
parent5e749cea9d9d46d98c9150d43f67fc9de6f3810a (diff)
downloadscala-c5dcb8d01fe46c21695a12094206c24af8fe4d50.tar.gz
scala-c5dcb8d01fe46c21695a12094206c24af8fe4d50.tar.bz2
scala-c5dcb8d01fe46c21695a12094206c24af8fe4d50.zip
- Removed old methods Nil and Cons in TreeGen
Diffstat (limited to 'sources/scalac/symtab/SymbolCloner.java')
-rw-r--r--sources/scalac/symtab/SymbolCloner.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/sources/scalac/symtab/SymbolCloner.java b/sources/scalac/symtab/SymbolCloner.java
index 0ddb096b6a..bdb7eb7f75 100644
--- a/sources/scalac/symtab/SymbolCloner.java
+++ b/sources/scalac/symtab/SymbolCloner.java
@@ -16,8 +16,9 @@ import scalac.util.Debug;
/**
* This class implements a symbol cloner. It automatically determines
- * the new owner of cloned symbols and keeps track of all cloned
- * symbols.
+ * the new owner of cloned symbols, clones their type and keeps track
+ * of all cloned symbols. Clone a type means clone all symbol declared
+ * in that type (for example parameters of a MethodType).
*/
public class SymbolCloner {
@@ -90,6 +91,7 @@ public class SymbolCloner {
clone.name = renamer.newName(symbol.name);
}
clones.put(symbol, clone);
+ //clone.setType(cloneType(clone.info()));
return clone;
}
@@ -100,11 +102,26 @@ public class SymbolCloner {
/** Clones the given symbols and renames them if rename is true. */
public Symbol[] cloneSymbols(Symbol[] symbols, boolean rename) {
+ if (symbols.length == 0) return Symbol.EMPTY_ARRAY;
Symbol[] clones = new Symbol[symbols.length];
for (int i = 0; i < clones.length; i++)
clones[i] = cloneSymbol(symbols[i], rename);
return clones;
}
+ /** Clones the given type. */
+ public Type cloneType(Type type) {
+ switch (type) {
+ case PolyType(Symbol[] tparams, Type result):
+ Symbol[] clones = cloneSymbols(tparams);
+ Type clone = Type.PolyType(clones, cloneType(result));
+ return Type.getSubst(tparams, clones).applyParams(clone);
+ case MethodType(Symbol[] vparams, Type result):
+ return Type.MethodType(cloneSymbols(vparams), cloneType(result));
+ default:
+ return type;
+ }
+ }
+
//########################################################################
}