aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeComparer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-06-30 14:27:43 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-11 13:35:07 +0200
commit32c0135b59fe02a70ed0b1a693251a0028d479c8 (patch)
tree289c07464da953f9709bf69a1e9658d430575e71 /src/dotty/tools/dotc/core/TypeComparer.scala
parentb6a8bc77fe3af4f6f722fdbaed8a0f7c8c6774ac (diff)
downloaddotty-32c0135b59fe02a70ed0b1a693251a0028d479c8.tar.gz
dotty-32c0135b59fe02a70ed0b1a693251a0028d479c8.tar.bz2
dotty-32c0135b59fe02a70ed0b1a693251a0028d479c8.zip
Refactorings of GenericTypes and underlying/upperbound
1. Make genericType a trait instead of a class. 2. Make TypeLambda a type proxy 3. Split underlying in TypeProxy into underlying and superType 4. Cleanups in many other places
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeComparer.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index bb9124fda..34fe8629e 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -677,7 +677,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
canConstrain(param1) && canInstantiate ||
isSubType(bounds(param1).hi.applyIfParameterized(args1), tp2)
case tycon1: TypeProxy =>
- isSubType(tycon1.underlying.bounds.hi.applyIfParameterized(args1), tp2)
+ isSubType(tycon1.superType.applyIfParameterized(args1), tp2)
case _ =>
false
}
@@ -1218,20 +1218,17 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
else original(tp1, tp2.appliedTo(tp2.typeParams.map(_.paramBoundsAsSeenFrom(tp2))))
else if (tparams2.isEmpty)
original(tp1.appliedTo(tp1.typeParams.map(_.paramBoundsAsSeenFrom(tp1))), tp2)
- else {
- val numArgs = tparams1.length
- def argRefs(tl: GenericType) = List.range(0, numArgs).map(PolyParam(tl, _))
+ else
TypeLambda(
- paramNames = tpnme.syntheticLambdaParamNames(numArgs),
+ paramNames = tpnme.syntheticLambdaParamNames(tparams1.length),
variances = (tparams1, tparams2).zipped.map((tparam1, tparam2) =>
(tparam1.paramVariance + tparam2.paramVariance) / 2))(
paramBoundsExp = tl => (tparams1, tparams2).zipped.map((tparam1, tparam2) =>
tl.lifted(tparams1, tparam1.paramBoundsAsSeenFrom(tp1)).bounds &
tl.lifted(tparams2, tparam2.paramBoundsAsSeenFrom(tp2)).bounds),
resultTypeExp = tl =>
- original(tl.lifted(tparams1, tp1).appliedTo(argRefs(tl)),
- tl.lifted(tparams2, tp2).appliedTo(argRefs(tl))))
- }
+ original(tl.lifted(tparams1, tp1).appliedTo(tl.paramRefs),
+ tl.lifted(tparams2, tp2).appliedTo(tl.paramRefs)))
}
/** Try to distribute `&` inside type, detect and handle conflicts