From f7910005038c188e573e8d1a42ff3e31c69c90c1 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 7 May 2014 18:26:37 +0200 Subject: Better printing of anonymous classes. Used to be just $anon, now is `Ps { ... }`, where `Ps` are the instantiated parents of the anonymous class. --- 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 36b546230..89facfee5 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -2002,12 +2002,23 @@ object Types { // cached because baseType needs parents private var parentsCache: List[TypeRef] = null + /** The parent type refs as seen from the given prefix */ override def parents(implicit ctx: Context): List[TypeRef] = { if (parentsCache == null) parentsCache = cls.classParents.mapConserve(rebase(_).asInstanceOf[TypeRef]) parentsCache } + /** The parent types with all type arguments */ + def instantiatedParents(implicit ctx: Context): List[Type] = + parents mapConserve { pref => + ((pref: Type) /: pref.classSymbol.typeParams) { (parent, tparam) => + val targSym = decls.lookup(tparam.name) + if (targSym.exists) RefinedType(parent, targSym.name, targSym.info) + else parent + } + } + def derivedClassInfo(prefix: Type)(implicit ctx: Context) = if (prefix eq this.prefix) this else ClassInfo(prefix, cls, classParents, decls, selfInfo) -- cgit v1.2.3