summaryrefslogtreecommitdiff
path: root/sources/scalac
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-07-15 15:17:55 +0000
committerpaltherr <paltherr@epfl.ch>2003-07-15 15:17:55 +0000
commitb82944e86b633ec91b435b647d6db7a66107c924 (patch)
tree449d545a99c4c123b23a752162953ac356170cac /sources/scalac
parent40eddc459e87ff08d484be9b981fb93c903be265 (diff)
downloadscala-b82944e86b633ec91b435b647d6db7a66107c924.tar.gz
scala-b82944e86b633ec91b435b647d6db7a66107c924.tar.bz2
scala-b82944e86b633ec91b435b647d6db7a66107c924.zip
- Added a missing isMethod test on LambdaLiftPh...
- Added a missing isMethod test on LambdaLiftPhase.proxy - Added some assertion checks to Type.typeParams and Type.valueParams - Patched ClassSymbol.typeParams and LambdaLiftPhase.TransformTypeMap.apply to hide bug of method Symbol.constructor (see comment is those two methods).
Diffstat (limited to 'sources/scalac')
-rw-r--r--sources/scalac/symtab/Symbol.java12
-rw-r--r--sources/scalac/symtab/Type.java12
-rw-r--r--sources/scalac/transformer/LambdaLiftPhase.java36
3 files changed, 46 insertions, 14 deletions
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java
index 62b6f1200a..a67669075a 100644
--- a/sources/scalac/symtab/Symbol.java
+++ b/sources/scalac/symtab/Symbol.java
@@ -1357,7 +1357,17 @@ public class ClassSymbol extends TypeSymbol {
/** Get type parameters */
public Symbol[] typeParams() {
- return constructor.info().typeParams();
+ // !!! For some Java classes, 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 = constructor.info();
+ switch (constrtype) {
+ case OverloadedType(_, _):
+ return Symbol.EMPTY_ARRAY;
+ default:
+ return constrtype.typeParams();
+ }
}
public Symbol[] valueParams() {
diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java
index 61cd77c300..86dbb3a805 100644
--- a/sources/scalac/symtab/Type.java
+++ b/sources/scalac/symtab/Type.java
@@ -418,8 +418,10 @@ public class Type implements Modifiers, Kinds, TypeTags {
switch (this) {
case PolyType(Symbol[] tparams, _):
return tparams;
- default:
+ case MethodType(Symbol[] vparams, _):
return Symbol.EMPTY_ARRAY;
+ default:
+ throw Debug.abort("illegal case", this);
}
}
@@ -427,13 +429,17 @@ public class Type implements Modifiers, Kinds, TypeTags {
* applicable.
*/
public Symbol[] valueParams() {
+ return valueParams(false);
+ }
+ private Symbol[] valueParams(boolean ok) {
switch (this) {
case PolyType(_, Type result):
- return result.valueParams();
+ return result.valueParams(true);
case MethodType(Symbol[] vparams, _):
return vparams;
default:
- return Symbol.EMPTY_ARRAY;
+ if (ok) return Symbol.EMPTY_ARRAY;
+ throw Debug.abort("illegal case", this);
}
}
diff --git a/sources/scalac/transformer/LambdaLiftPhase.java b/sources/scalac/transformer/LambdaLiftPhase.java
index 050cc95515..563710cb51 100644
--- a/sources/scalac/transformer/LambdaLiftPhase.java
+++ b/sources/scalac/transformer/LambdaLiftPhase.java
@@ -86,8 +86,22 @@ public class LambdaLiftPhase extends PhaseDescriptor implements Kinds, Modifiers
switch (pre) {
case ThisType(_):
if (sym.kind == CLASS && sym.constructor().isUpdated(nextPhase)) {
- Symbol[] tparams =
- sym.constructor().infoAt(nextPhase).typeParams();
+ // !!! 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.constructor().infoAt(nextPhase);
+ Symbol[] tparams;
+ switch (constrtype) {
+ case OverloadedType(_, _):
+ tparams = Symbol.EMPTY_ARRAY;
+ break;
+ default:
+ tparams = constrtype.typeParams();
+ break;
+ }
int i = tparams.length;
while (i > 0 && (tparams[i-1].flags & SYNTHETIC) != 0)
i--;
@@ -140,14 +154,16 @@ public class LambdaLiftPhase extends PhaseDescriptor implements Kinds, Modifiers
global.log("looking in " + LambdaLift.asFunction(o) + " " +
ArrayApply.toString(o.typeParams()));
Symbol fowner = LambdaLift.asFunction(o);
- if (fv.owner() == fowner) return fv;
- Type ft = (fowner.isUpdated(nextPhase)) ? fowner.typeAt(nextPhase)
- : fowner.type();
- Symbol[] ownerparams = fv.isType() ? ft.typeParams()
- : ft.firstParams();
- for (int i = 0; i < ownerparams.length; i++) {
- if (ownerparams[i].name == fv.name)
- return ownerparams[i];
+ if (fowner.isMethod()) {
+ if (fv.owner() == fowner) return fv;
+ Type ft = (fowner.isUpdated(nextPhase)) ? fowner.typeAt(nextPhase)
+ : fowner.type();
+ Symbol[] ownerparams = fv.isType() ? ft.typeParams()
+ : ft.firstParams();
+ for (int i = 0; i < ownerparams.length; i++) {
+ if (ownerparams[i].name == fv.name)
+ return ownerparams[i];
+ }
}
assert o.owner() != o;
o = o.owner();