From 7f08642a0a44a90da287e176f3a820e328ce6d3d Mon Sep 17 00:00:00 2001 From: schinz Date: Wed, 14 May 2003 13:04:13 +0000 Subject: - added valueParams method --- sources/scalac/symtab/Symbol.java | 25 ++++++++++++++++++++++++- sources/scalac/symtab/Type.java | 17 +++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) (limited to 'sources/scalac/symtab') diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index 181edac352..3bb3f76e87 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -243,7 +243,7 @@ public abstract class Symbol implements Modifiers, Kinds { return kind == CLASS && (flags & MODUL) != 0; } - /** Does this symbol denote a module? */ + /** Does this symbol denote a class? */ public final boolean isClass() { return kind == CLASS; } @@ -395,6 +395,11 @@ public abstract class Symbol implements Modifiers, Kinds { return EMPTY_ARRAY; } + /** Get value parameters */ + public Symbol[] valueParams() { + return EMPTY_ARRAY; + } + /** Get primary constructor of class */ public Symbol constructor() { return NONE; @@ -957,6 +962,10 @@ public class TermSymbol extends Symbol { return type().typeParams(); } + public Symbol[] valueParams() { + return type().valueParams(); + } + public Symbol primaryConstructorClass() { return isConstructor() && clazz != null ? clazz : this; } @@ -1000,6 +1009,11 @@ public class TypeSymbol extends Symbol { return tycon; } + public Symbol setOwner(Symbol owner) { + tycon = null; + return super.setOwner(owner); + } + /** Get type */ public Type type() { return typeConstructor(); @@ -1258,6 +1272,10 @@ public class ClassSymbol extends TypeSymbol { return constructor.info().typeParams(); } + public Symbol[] valueParams() { + return constructor.info().valueParams(); + } + /** Get type */ public Type type() { if (template == null || template.typeArgs().length != typeParams().length) { @@ -1267,6 +1285,11 @@ public class ClassSymbol extends TypeSymbol { return template; } + public Symbol setOwner(Symbol owner) { + template = null; + return super.setOwner(owner); + } + public Type thisType() { return thistp; } diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java index f201027d75..110a0f80bc 100644 --- a/sources/scalac/symtab/Type.java +++ b/sources/scalac/symtab/Type.java @@ -369,6 +369,23 @@ public class Type implements Modifiers, Kinds, TypeTags { return Symbol.EMPTY_ARRAY; } + /** Get value parameters of method or EMPTY_ARRAY if not + * applicable. + */ + public Symbol[] valueParams() { + switch (this) { + case PolyType(_, Type result): + return result.valueParams(); + case MethodType(Symbol[] vparams, _): + return vparams; + case TypeRef(_, Symbol sym, _): + if (sym.kind == CLASS) return sym.valueParams(); + else return sym.info().valueParams(); + default: + return Symbol.EMPTY_ARRAY; + } + } + /** If this type is a (possibly polymorphic) method type, its result type * after applying all method argument sections, * otherwise the type itself. -- cgit v1.2.3