aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-04 23:06:45 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-04 23:06:55 +0100
commit35eeb8e8f17735bee5722954338836b10cfbb1e8 (patch)
tree332cdecd32f1fe2ac32db1684d43189fbae3494a /src/dotty/tools/dotc/core/Types.scala
parent0aa4d2ce10dcf872c16ed4a5ecb7cd6a2b8c9b30 (diff)
downloaddotty-35eeb8e8f17735bee5722954338836b10cfbb1e8.tar.gz
dotty-35eeb8e8f17735bee5722954338836b10cfbb1e8.tar.bz2
dotty-35eeb8e8f17735bee5722954338836b10cfbb1e8.zip
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.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala10
1 files changed, 6 insertions, 4 deletions
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)
}