diff options
author | paltherr <paltherr@epfl.ch> | 2003-07-22 12:26:55 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-07-22 12:26:55 +0000 |
commit | 22f3db43a770b8997788bd6c3bae240b47c1813b (patch) | |
tree | 01a75ba09c202cd54416d944b3a99db9e6b51ef4 /sources | |
parent | 4ff4623f2ee14d974237d5524c72163f6cb0992e (diff) | |
download | scala-22f3db43a770b8997788bd6c3bae240b47c1813b.tar.gz scala-22f3db43a770b8997788bd6c3bae240b47c1813b.tar.bz2 scala-22f3db43a770b8997788bd6c3bae240b47c1813b.zip |
- Added method bound
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scalac/symtab/Type.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java index 262d07ccd6..7397eb3b53 100644 --- a/sources/scalac/symtab/Type.java +++ b/sources/scalac/symtab/Type.java @@ -238,6 +238,26 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { return syms; } + /** The upper bound of this type. Returns always a TypeRef whose + * symbol is a class. + */ + public Type bound() { + switch (this) { + case TypeRef(Type pre, Symbol sym, _): + if (sym.kind == ALIAS) return unalias().bound(); + if (sym.kind == TYPE) return pre.memberInfo(sym).bound(); + assert sym.isClass() : Debug.show(sym) + " -- " + this; + return this; + case ThisType(_): + case SingleType(_, _): + return singleDeref().bound(); + case TypeVar(_, _): + return unalias().bound(); + default: + throw Debug.abort("illegal case", this); + } + } + /** If this type is a thistype or singleton type, its type, * otherwise the type itself. */ |