From 15bc45cd76445d5d3e8566492fc54b7e4b8f22e3 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 24 Dec 2013 09:43:33 +0100 Subject: Refining checkClassTypeWithStablePrefix Needs to unwrap parameters. While we are at it, breaking out common functionality in underlyingClassRef. --- src/dotty/tools/dotc/core/Types.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) (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 93db5d624..64fa4d3ec 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -596,6 +596,17 @@ object Types { def underlyingIfRepeated(implicit ctx: Context): Type = this.translateParameterized(defn.RepeatedParamClass, defn.SeqClass) + /** If this is a (possibly aliased, annotated, and parameterized) reference to + * a class, the class type ref, otherwise NoType. + */ + def underlyingClassRef(implicit ctx: Context): Type = dealias match { + case tp: TypeRef if tp.symbol.isClass => tp + case tp: TypeVar => tp.underlying.underlyingClassRef + case tp: AnnotatedType => tp.underlying.underlyingClassRef + case tp: RefinedType => tp.underlying.underlyingClassRef + case _ => NoType + } + /** A prefix-less termRef to a new skolem symbol that has the given type as info */ def narrow(implicit ctx: Context): TermRef = TermRef(NoPrefix, ctx.newSkolem(this)) -- cgit v1.2.3