From 35eeb8e8f17735bee5722954338836b10cfbb1e8 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 4 Jan 2014 23:06:45 +0100 Subject: Changes to propagation of wildcardtypes 1) Selecting from a wildcardtype now gives a wildcard type. Wildcard types are no longer legal as prefixes of NamedTypes. 2) Bound of type variables are proagated into wildcard type approximations. --- src/dotty/tools/dotc/core/Types.scala | 10 ++++++---- 1 file changed, 6 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 8fe813e4d..92f65c1fe 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -628,6 +628,8 @@ object Types { case TypeBounds(lo, hi) if lo eq hi => hi case _ => NoType } + case pre: WildcardType => + WildcardType case _ => NoType } @@ -1044,8 +1046,7 @@ object Types { val name: Name assert(prefix.isValueType || - (prefix eq NoPrefix) || - prefix.isInstanceOf[WildcardType], s"bad prefix in $prefix.$name") + (prefix eq NoPrefix), s"bad prefix in $prefix.$name") private[this] var lastDenotationOrSym: AnyRef = null @@ -1145,7 +1146,7 @@ object Types { def derivedSelect(prefix: Type)(implicit ctx: Context): Type = if (prefix eq this.prefix) this else { - val res = lookupRefined(this, name) + val res = lookupRefined(prefix, name) if (res.exists) res else newLikeThis(prefix) } @@ -2196,7 +2197,8 @@ object Types { case MethodParam(mt, pnum) => WildcardType(TypeBounds.upper(apply(mt.paramTypes(pnum)))) case tp: TypeVar => - apply(tp.underlying) + val inst = tp.instanceOpt + apply(inst orElse WildcardType(ctx.typerState.constraint.bounds(tp.origin))) case _ => mapOver(tp) } -- cgit v1.2.3