summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2004-06-03 13:35:51 +0000
committerMartin Odersky <odersky@gmail.com>2004-06-03 13:35:51 +0000
commitf36b4fc60726159c2d10c4d01d6dca044964c4c5 (patch)
treedff9fe8d96f4c1b8dd78f965edd39a9dee1f286e /sources
parent805cd03fcde21939bbca9aebc9d28b82f346848b (diff)
downloadscala-f36b4fc60726159c2d10c4d01d6dca044964c4c5.tar.gz
scala-f36b4fc60726159c2d10c4d01d6dca044964c4c5.tar.bz2
scala-f36b4fc60726159c2d10c4d01d6dca044964c4c5.zip
*** empty log message ***
Diffstat (limited to 'sources')
-rw-r--r--sources/scalac/symtab/Symbol.java53
1 files changed, 34 insertions, 19 deletions
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java
index 45c3b05548..965e844320 100644
--- a/sources/scalac/symtab/Symbol.java
+++ b/sources/scalac/symtab/Symbol.java
@@ -1233,20 +1233,38 @@ public abstract class Symbol implements Modifiers, Kinds {
return info;
case OverloadedType(Symbol[] alts, Type[] alttypes):
global.currentPhase = phase.next;
+ int n = 0;
+ boolean altChanged = false;
for (int i = 0; i < alts.length; i++) {
Type type = alts[i].info();
- if (type != alttypes[i]) {
- Type[] types = new Type[alttypes.length];
- for (int j = 0; j < i; j++) types[j] = alttypes[j];
- alttypes[i] = type;
- for (; i < alts.length; i++)
- types[i] = alts[i].info();
- global.currentPhase = current;
- return Type.OverloadedType(alts, types);
- }
- }
- global.currentPhase = current;
- return info;
+ if (alts[i].owner() == owner()) n++;
+ if (alts[i].info() != alttypes[i]) altChanged = true;
+ }
+ Type result;
+ if (n < alts.length) {
+ Symbol[] symbols = new Symbol[n];
+ Type[] types = new Type[n];
+ int j = 0;
+ for (int i = 0; i < alts.length; i++) {
+ if (alts[i].owner() == owner()) {
+ symbols[j] = alts[i];
+ types[j] = alts[i].info();
+ j++;
+ } else
+ if (Global.instance.debug) Global.instance.log("removing inherited alternatve " + alts[i] + ":" + alttypes[i]);//debug
+ }
+ result = Type.OverloadedType(symbols, types);
+ } else if (altChanged) {
+ Type[] types = new Type[alttypes.length];
+ for (int i = 0; i < alts.length; i++) {
+ types[i] = alts[i].info();
+ }
+ result = Type.OverloadedType(alts, types);
+ } else {
+ result = info;
+ }
+ global.currentPhase = current;
+ return result;
default:
global.currentPhase = phase;
info = phase.transformInfo(this, info);
@@ -1645,7 +1663,7 @@ public abstract class Symbol implements Modifiers, Kinds {
}
public void addInheritedOverloaded(Type owntype) {
- if (false && owner().kind == CLASS && !isConstructor() && owner().lookup(name) == this) {
+ if (owner().kind == CLASS && !isConstructor() && owner().lookup(name) == this) {
// it's a class member which is not an overloaded alternative
Symbol sym = Type.lookupNonPrivate(owner().parents(), name);
if (sym.kind == VAL) {
@@ -1664,15 +1682,13 @@ public abstract class Symbol implements Modifiers, Kinds {
private void addInheritedOverloaded(Type owntype, Symbol sym, Type symtype) {
if (!owntype.overrides(symtype)) {
- System.out.println(owner() + " inherits overloaded: " + sym + ":" + symtype + sym.locationString());//debug
+ if (Global.instance.debug) Global.instance.log(owner() + " inherits overloaded: " + sym + ":" + symtype + sym.locationString());//debug
owner().members().lookupEntry(name).setSymbol(overloadWith(sym));
//System.out.println("type is now: " + owner().members().lookup(name).type());
}
}
public Type removeInheritedOverloaded(Type owntype) {
- //assert name != Names.toString ||
- // Global.instance.currentPhase.id != Global.instance.PHASE.UNCURRY.id();
switch (owntype) {
case OverloadedType(Symbol[] alts, Type[] alttypes):
int n = 0;
@@ -1687,9 +1703,8 @@ public abstract class Symbol implements Modifiers, Kinds {
alts1[j] = alts[i];
alttypes1[j] = alttypes[i];
j++;
- } else {
- System.out.println("removing inherited alternatve " + alts[i] + ":" + alttypes[i]);//debug
- }
+ } else
+ if (Global.instance.debug) Global.instance.log("removing inherited alternatve " + alts[i] + ":" + alttypes[i]);//debug
}
return Type.OverloadedType(alts1, alttypes1);
} else {