diff options
Diffstat (limited to 'sources/scalac/symtab/Type.java')
-rw-r--r-- | sources/scalac/symtab/Type.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java index 7dcf109456..7b27647e22 100644 --- a/sources/scalac/symtab/Type.java +++ b/sources/scalac/symtab/Type.java @@ -53,6 +53,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { */ public case TypeRef(Type pre, Symbol sym, Type[] args) { assert pre.isLegalPrefix() || pre == ErrorType : pre + "#" + sym; + assert sym.kind == ERROR || sym.isType() : pre + "#" + sym; } /** parts_1 with ... with parts_n { members } @@ -159,7 +160,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { Position.NOPOS, Names.COMPOUND_NAME.toTypeName(), Symbol.NONE, SYNTHETIC | ABSTRACTCLASS); res.tsym.setInfo(res); - res.tsym.constructor().setInfo( + res.tsym.primaryConstructor().setInfo( Type.MethodType(Symbol.EMPTY_ARRAY, Type.NoType)); return res; } @@ -419,7 +420,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { if (sym.kind == ALIAS) return unalias().parents(); else if (sym.kind == CLASS) { - assert sym.typeParams().length == args.length : sym + " " + ArrayApply.toString(args);//debug + assert sym.typeParams().length == args.length : sym + " " + ArrayApply.toString(args) + " " + sym.primaryConstructor().info();//debug return subst(asSeenFrom(sym.info().parents(), pre, sym.owner()), sym.typeParams(), args); } else @@ -508,7 +509,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { /** If this type is overloaded, its alternative types, * otherwise an array consisting of this type itself. */ - public Type[] alternatives() { + public Type[] alternativeTypes() { switch (this) { case OverloadedType(_, Type[] alttypes): return alttypes; @@ -517,6 +518,18 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { } } + /** If this type is overloaded, its alternative symbols, + * otherwise an empty array. + */ + public Symbol[] alternativeSymbols() { + switch (this) { + case OverloadedType(Symbol[] alts, _): + return alts; + default: + return Symbol.EMPTY_ARRAY; + } + } + /** If type is a this type of a module class, transform to singletype of * module. */ @@ -2440,7 +2453,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { else return sym.typeConstructor(); } - default: throw new ApplicationError(); + default: throw new ApplicationError(sym + " has wrong kind: " + sym.kind); } case CompoundType(Type[] parents, _): if (parents.length > 0) return parents[0].erasure(); |