aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala11
1 files changed, 11 insertions, 0 deletions
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))