summaryrefslogtreecommitdiff
path: root/sources/scalac/symtab/Symbol.java
diff options
context:
space:
mode:
Diffstat (limited to 'sources/scalac/symtab/Symbol.java')
-rw-r--r--sources/scalac/symtab/Symbol.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java
index f2e387c67b..eeb4d6e647 100644
--- a/sources/scalac/symtab/Symbol.java
+++ b/sources/scalac/symtab/Symbol.java
@@ -141,6 +141,12 @@ public abstract class Symbol implements Modifiers, Kinds {
return this;
}
+ /** Set the low bound of this type variable
+ */
+ public Symbol setLoBound(Type lobound) {
+ throw new ApplicationError("setLoBound inapplicable for " + this);
+ }
+
// Symbol classification ----------------------------------------------------
/** Does this symbol denote a type? */
@@ -341,6 +347,14 @@ public abstract class Symbol implements Modifiers, Kinds {
}
}
+ /** The variance of this symbol as an integer
+ */
+ public int variance() {
+ if ((flags & COVARIANT) != 0) return 1;
+ else if ((flags & CONTRAVARIANT) != 0) return -1;
+ else return 0;
+ }
+
// Symbol names ----------------------------------------------------------------
/** Get the fully qualified name of this Symbol
@@ -592,6 +606,12 @@ public abstract class Symbol implements Modifiers, Kinds {
throw new ApplicationError("typeConstructor inapplicable for " + this);
}
+ /** The low bound of this type variable
+ */
+ public Type loBound() {
+ throw new ApplicationError("loBound inapplicable for " + this);
+ }
+
/** Get this.type corresponding to this symbol
*/
public Type thisType() {
@@ -1107,6 +1127,7 @@ public class TypeSymbol extends Symbol {
private void computeClosure() {
assert closures.closure != BAD_CLOSURE : this;
closures.closure = BAD_CLOSURE; // to catch cycles.
+ // todo: why can't we do: inclClosure(SymSet.EMPTY, this) ?
SymSet closureClassSet = inclClosureBases(SymSet.EMPTY, this);
Symbol[] closureClasses = new Symbol[closureClassSet.size() + 1];
closureClasses[0] = this;
@@ -1116,6 +1137,7 @@ public class TypeSymbol extends Symbol {
//System.out.println(ArrayApply.toString(closures.closure));//DEBUG
adjustType(type());
//System.out.println("closure(" + this + ") at " + Global.instance.currentPhase.name() + " = " + ArrayApply.toString(closures.closure));//DEBUG
+
}
//where
@@ -1151,6 +1173,36 @@ public class TypeSymbol extends Symbol {
}
}
+public class AbsTypeSymbol extends TypeSymbol {
+
+ private Type lobound = null;
+
+ /** Constructor */
+ public AbsTypeSymbol(int pos, Name name, Symbol owner, int flags) {
+ super(TYPE, pos, name, owner, flags);
+ }
+
+ /** Return a fresh symbol with the same fields as this one.
+ */
+ public Symbol cloneSymbol() {
+ if (Global.instance.debug) System.out.println("cloning " + this + this.locationString() + " in phase " + Global.instance.currentPhase.name());
+ TypeSymbol other = new AbsTypeSymbol(pos, name, owner(), flags);
+ other.setInfo(info());
+ other.setLoBound(loBound());
+ return other;
+ }
+
+ public Type loBound() {
+ initialize();
+ return lobound == null ? Global.instance.definitions.ALL_TYPE : lobound;
+ }
+
+ public Symbol setLoBound(Type lobound) {
+ this.lobound = lobound;
+ return this;
+ }
+}
+
/** A class for class symbols. It has JavaClassSymbol as a subclass.
*/
public class ClassSymbol extends TypeSymbol {
@@ -1377,6 +1429,10 @@ public final class ErrorSymbol extends Symbol {
return this;
}
+ public Type loBound() {
+ return Type.ErrorType;
+ }
+
public void reset(Type completer) {
}
}