summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sources/scalac/symtab/Symbol.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java
index 6a50761c02..b7d228d001 100644
--- a/sources/scalac/symtab/Symbol.java
+++ b/sources/scalac/symtab/Symbol.java
@@ -868,6 +868,24 @@ public abstract class Symbol implements Modifiers, Kinds {
return name;
}
+// Symbol origin --------------------------------------------------------------
+
+ /** Returns the origin of this symbol. */
+ public SymbolOrigin getOrigin() {
+ if (isModule())
+ return moduleClass().getOrigin();
+ if (isConstructor())
+ return constructorClass().getOrigin();
+ if (isCaseFactory())
+ return type().resultType().symbol().getOrigin();
+ return owner().getOrigin();
+ }
+
+ /** Sets the origin of this symbol. */
+ public void setOrigin(SymbolOrigin origin) {
+ throw Debug.abort("not a class", this);
+ }
+
// Acess to related symbols -----------------------------------------------------
/** Get type parameters */
@@ -2079,6 +2097,9 @@ final class AbsTypeSymbol extends TypeSymbol {
/** A class for class symbols. */
public class ClassSymbol extends TypeSymbol {
+ /** The origin of this symbol */
+ private SymbolOrigin origin;
+
/** The given type of self, or NoType, if no explicit type was given.
*/
private Symbol thisSym = this;
@@ -2135,6 +2156,16 @@ public class ClassSymbol extends TypeSymbol {
return newTerm(pos, SYNTHETIC, Names.this_, IS_THISTYPE);
}
+ /** Returns the origin of this symbol. */
+ public SymbolOrigin getOrigin() {
+ return origin != null ? origin : super.getOrigin();
+ }
+
+ /** Sets the origin of this symbol. */
+ public void setOrigin(SymbolOrigin origin) {
+ this.origin = origin;
+ }
+
public Type thisType() {
Global global = Global.instance;
if (global.currentPhase.id > global.PHASE.ERASURE.id()) return type();
@@ -2316,6 +2347,11 @@ final class NoSymbol extends Symbol {
super.setInfo(Type.NoType);
}
+ /** Returns the origin of this symbol. */
+ public SymbolOrigin getOrigin() {
+ return SymbolOrigin.Unknown;
+ }
+
/** Set type */
public Symbol setInfo(Type info) {
assert info == Type.NoType : info;