diff options
author | paltherr <paltherr@epfl.ch> | 2004-03-06 14:00:31 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2004-03-06 14:00:31 +0000 |
commit | 4d14aa915e2022b044eb4a4cd329b992e24c7baa (patch) | |
tree | 01356898dff53ed8fa581c7cb9408434cda68332 /sources/scalac/symtab | |
parent | 22f8b2e70dcd1dce006e6baee5be67b3e76b8020 (diff) | |
download | scala-4d14aa915e2022b044eb4a4cd329b992e24c7baa.tar.gz scala-4d14aa915e2022b044eb4a4cd329b992e24c7baa.tar.bz2 scala-4d14aa915e2022b044eb4a4cd329b992e24c7baa.zip |
- Added methods isStaticOwner, staticType and s...
- Added methods isStaticOwner, staticType and staticPrefix
Diffstat (limited to 'sources/scalac/symtab')
-rw-r--r-- | sources/scalac/symtab/Symbol.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index 86152ca1b4..65fe1882b9 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -298,6 +298,13 @@ public abstract class Symbol implements Modifiers, Kinds { return owner.isPackage() || (owner.isJava() && owner.isModuleClass()); } + /** Does this symbol denote a class that defines static symbols? */ + public final boolean isStaticOwner() { + return isRoot() || (isStatic() && isModuleClass() + // !!! remove later? translation does not work (yet?) + && isJava()); + } + /** Is this symbol final? */ public final boolean isFinal() { @@ -985,6 +992,36 @@ public abstract class Symbol implements Modifiers, Kinds { return type(syms); } + /** Get static type. */ + public final Type staticType() { + return staticType(Type.EMPTY_ARRAY); + } + /** Get static type with given type argument. */ + public final Type staticType(Type arg0) { + return staticType(new Type[]{arg0}); + } + /** Get static type with given type arguments. */ + public final Type staticType(Type arg0, Type arg1) { + return staticType(new Type[]{arg0, arg1}); + } + /** Get static type with given type arguments. */ + public final Type staticType(Type[] args) { + Type prefix = owner.staticPrefix(); + if (isType()) return Type.typeRef(prefix, this, args); + assert args.length == 0: Debug.show(this, " - ", args); + return prefix.memberType(this); + } + + /** Get static prefix. */ + public final Type staticPrefix() { + assert isStaticOwner(): Debug.show(this); + Global global = Global.instance; + if (global.PHASE.EXPLICITOUTER.id() < global.currentPhase.id) + return Type.NoPrefix; + if (isRoot()) return thisType(); + return Type.singleType(owner.staticPrefix(), module()); + } + /** The type constructor of a symbol is: * For a type symbol, the type corresponding to the symbol itself, excluding * parameters. |