aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-06-06 19:18:45 +0200
committerMartin Odersky <odersky@gmail.com>2013-06-06 19:18:45 +0200
commit5651846489834ed69cbb2dab88bc628cf6234dc9 (patch)
tree6876f0bba0da934565bf0906d330618c4ed9e294
parent898fe8a499c97fa62840e2c79755fc729015a442 (diff)
downloaddotty-5651846489834ed69cbb2dab88bc628cf6234dc9.tar.gz
dotty-5651846489834ed69cbb2dab88bc628cf6234dc9.tar.bz2
dotty-5651846489834ed69cbb2dab88bc628cf6234dc9.zip
Changed meaning of typeParams
Type parameters are now counted only if they are not refined. I.e. previously given class Map[K, V], K and V would be type parameters of Map { K = Int }, but now only V would be. Also, added a new kind of name filter that gets all type members.
-rw-r--r--src/dotty/tools/dotc/core/Types.scala22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 3a25fe889..9c33fdca9 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -226,7 +226,8 @@ object Types {
/** The type parameters of this type are:
* For a ClassInfo type, the type parameters of its class.
* For a typeref referring to a class, the type parameters of the class.
- * Inherited by type proxies.
+ * For a refinement type, the type parameters of its parent, unless there's a
+ * refinement with the same name. Inherited by all other type proxies.
* Empty list for all other types.
*/
final def typeParams(implicit ctx: Context): List[TypeSymbol] = this match {
@@ -237,6 +238,8 @@ object Types {
if (tsym.isClass) tsym.typeParams
else if (tsym.isAliasType) tp.underlying.typeParams
else Nil
+ case tp: RefinedType =>
+ tp.parent.typeParams filterNot (_.name == tp.refinedName)
case tp: TypeProxy =>
tp.underlying.typeParams
case _ =>
@@ -362,22 +365,23 @@ object Types {
/** The set of abstract term members of this type. */
final def abstractTermMembers(implicit ctx: Context): Set[SingleDenotation] =
- memberNames(abstractTermNameFilter)
- .flatMap(member(_).altsWith(_ is Deferred))
+ memberNames(abstractTermNameFilter).flatMap(member(_).altsWith(_ is Deferred))
/** The set of abstract type members of this type. */
final def abstractTypeMembers(implicit ctx: Context): Set[SingleDenotation] =
- memberNames(abstractTypeNameFilter)
- .map(member(_).asInstanceOf[SingleDenotation])
+ memberNames(abstractTypeNameFilter).map(member(_).asInstanceOf[SingleDenotation])
/** The set of abstract members of this type. */
final def abstractMembers(implicit ctx: Context): Set[SingleDenotation] =
abstractTermMembers | abstractTypeMembers
+ /** The set of type members of this type */
+ final def typeMembers(implicit ctx: Context): Set[SingleDenotation] =
+ memberNames(typeNameFilter).map(member(_).asInstanceOf[SingleDenotation])
+
/** The info of `sym`, seen as a member of this type. */
- final def memberInfo(sym: Symbol)(implicit ctx: Context): Type = {
+ final def memberInfo(sym: Symbol)(implicit ctx: Context): Type =
sym.info.asSeenFrom(this, sym.owner)
- }
/** This type seen as if it were the type of a member of prefix type `pre`
* declared in class `cls`.
@@ -1757,6 +1761,10 @@ object Types {
name.isTermName && (pre member name).hasAltWith(_ is Deferred)
}
+ object typeNameFilter extends NameFilter {
+ def apply(pre: Type, name: Name)(implicit ctx: Context): Boolean = name.isTypeName
+ }
+
object takeAllFilter extends NameFilter {
def apply(pre: Type, name: Name)(implicit ctx: Context): Boolean = true
}