From 6a7e466fa2ff5d6d01a25bed0c685188c9a84a63 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 29 Jun 2016 19:41:36 +0200 Subject: Avoid accidental creation of hk types - Swap subtype tests Previous order could create constraints where hk type parameters got a * bound. (this is now caught in an assert). - Make underlyingClassRef work for hk types under new scheme. - Ensure that toAvoid does not creat hk from * types - Let getClass return a * type We will be pickier than before. An unapplied type such as `java.lang.Class` will always be an hk type. Hence, the type of getClass has to be appleid to [_] to make it a * type. --- src/dotty/tools/dotc/core/Types.scala | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (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 2fa4f94c1..ab5c795e3 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -875,13 +875,16 @@ object Types { if (tp.symbol.isClass) tp else if (tp.symbol.isAliasType) tp.underlying.underlyingClassRef(refinementOK) else NoType - case tp: AnnotatedType => tp.underlying.underlyingClassRef(refinementOK) + case tp: AnnotatedType => + tp.underlying.underlyingClassRef(refinementOK) case tp: RefinedType => def isParamName = tp.classSymbol.typeParams.exists(_.name == tp.refinedName) - if (refinementOK || isParamName) tp.underlying.underlyingClassRef(refinementOK) + if (refinementOK || tp.isTypeParam || isParamName) tp.underlying.underlyingClassRef(refinementOK) else NoType - case tp: RecType if refinementOK => tp.parent - case _ => NoType + case tp: RecType => + tp.underlying.underlyingClassRef(refinementOK) + case _ => + NoType } /** The iterator of underlying types as long as type is a TypeProxy. -- cgit v1.2.3