From 1b7745e5f9c0e251436b33247133f3810838cf12 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 30 Jan 2016 05:12:47 +0100 Subject: Also consider type aliases when checking for realizability Fixes #50. --- src/dotty/tools/dotc/core/Types.scala | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/dotty/tools/dotc/core/Types.scala') diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index db0831ba0..7e8a11e5b 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -139,7 +139,7 @@ object Types { case _ => false } isConcrete(tp) && - tp.abstractTypeMembers.forall { m => + tp.nonClassTypeMembers.forall { m => val bounds = m.info.bounds bounds.lo <:< bounds.hi } || @@ -592,6 +592,12 @@ object Types { (name, buf) => buf += member(name).asSingleDenotation) } + /** The set of abstract type members of this type. */ + final def nonClassTypeMembers(implicit ctx: Context): Seq[SingleDenotation] = track("nonClassTypeMembers") { + memberDenots(nonClassTypeNameFilter, + (name, buf) => buf += member(name).asSingleDenotation) + } + /** The set of type members of this type */ final def typeMembers(implicit ctx: Context): Seq[SingleDenotation] = track("typeMembers") { memberDenots(typeNameFilter, @@ -3387,6 +3393,15 @@ object Types { } } + /** A filter for names of abstract types of a given type */ + object nonClassTypeNameFilter extends NameFilter { + def apply(pre: Type, name: Name)(implicit ctx: Context): Boolean = + name.isTypeName && { + val mbr = pre.member(name) + mbr.symbol.isType && !mbr.symbol.isClass + } + } + /** A filter for names of deferred term definitions of a given type */ object abstractTermNameFilter extends NameFilter { def apply(pre: Type, name: Name)(implicit ctx: Context): Boolean = -- cgit v1.2.3