@@ -195,7 +195,7 @@ class TypeComparer(initctx: Context) extends DotClass {
195
195
val saved = constraint
196
196
val savedSuccessCount = successCount
197
197
val savedTotalCount = totalCount
198
- if (Stats .monitored) Stats .record(s " isSubType ${tp1.getClass } <:< ${tp2.getClass }" )
198
+ if (Stats .monitored) Stats .record(s " isSubType ${tp1.show } <:< ${tp2.show }" )
199
199
try {
200
200
recCount += 1
201
201
/* !!! DEBUG
@@ -281,23 +281,14 @@ class TypeComparer(initctx: Context) extends DotClass {
281
281
) else
282
282
tp1.name == tp2.name && isSubType(tp1.prefix, tp2.prefix)
283
283
) || secondTryNamed(tp1, tp2)
284
+ case ThisType (cls) if cls eq tp2.symbol.moduleClass =>
285
+ isSubType(cls.owner.thisType, tp2.prefix)
284
286
case _ =>
285
287
secondTry(tp1, tp2)
286
288
}
287
289
compareNamed
288
290
case tp2 : ProtoType =>
289
291
isMatchedByProto(tp2, tp1)
290
- case tp2 @ ThisType (cls) =>
291
- def compareThis : Boolean = {
292
- if (cls is ModuleClass )
293
- tp1 match {
294
- case tp1 : TermRef =>
295
- if (tp1.symbol.moduleClass == cls) return tp1.prefix <:< cls.owner.thisType
296
- case _ =>
297
- }
298
- secondTry(tp1, tp2)
299
- }
300
- compareThis
301
292
case tp2 : PolyParam =>
302
293
def comparePolyParam = {
303
294
tp2 == tp1 ||
@@ -330,20 +321,14 @@ class TypeComparer(initctx: Context) extends DotClass {
330
321
331
322
def secondTry (tp1 : Type , tp2 : Type ): Boolean = tp1 match {
332
323
case tp1 : NamedType =>
333
- secondTryNamed(tp1, tp2)
324
+ tp2 match {
325
+ case ThisType (cls) if cls eq tp1.symbol.moduleClass =>
326
+ isSubType(tp1.prefix, cls.owner.thisType)
327
+ case _ =>
328
+ secondTryNamed(tp1, tp2)
329
+ }
334
330
case OrType (tp11, tp12) =>
335
331
isSubType(tp11, tp2) && isSubType(tp12, tp2)
336
- case tp1 @ ThisType (cls) =>
337
- def compareThis : Boolean = {
338
- if (cls is ModuleClass )
339
- tp2 match {
340
- case tp2 : TermRef =>
341
- if (tp2.symbol.moduleClass == cls) return cls.owner.thisType <:< tp2.prefix
342
- case _ =>
343
- }
344
- thirdTry(tp1, tp2)
345
- }
346
- compareThis
347
332
case tp1 : PolyParam =>
348
333
def comparePolyParam = {
349
334
tp1 == tp2 ||
@@ -622,7 +607,7 @@ class TypeComparer(initctx: Context) extends DotClass {
622
607
(hkArgs.length == tparams.length) && {
623
608
val base = tp1.narrow
624
609
(tparams, hkArgs).zipped.forall { (tparam, hkArg) =>
625
- base.memberInfo(tparam) <:< hkArg.bounds // TODO: base.memberInfo needed?
610
+ isSubType( base.memberInfo(tparam), hkArg.bounds) // TODO: base.memberInfo needed?
626
611
} &&
627
612
(tparams, tp2.typeSymbol.typeParams).zipped.forall { (tparam, tparam2) =>
628
613
tparam.variance == tparam2.variance
@@ -631,7 +616,7 @@ class TypeComparer(initctx: Context) extends DotClass {
631
616
}
632
617
633
618
def trySetType (tr : NamedType , bounds : TypeBounds ): Boolean =
634
- (bounds.lo <:< bounds.hi) &&
619
+ isSubType (bounds.lo, bounds.hi) &&
635
620
{ tr.symbol.changeGADTInfo(bounds); true }
636
621
637
622
/** A function implementing `tp1` matches `tp2`. */
@@ -1050,7 +1035,7 @@ class TypeComparer(initctx: Context) extends DotClass {
1050
1035
case tp1 : ClassInfo =>
1051
1036
tp2 match {
1052
1037
case tp2 : ClassInfo =>
1053
- (tp1.prefix <:< tp2.prefix) || (tp1.cls.owner derivesFrom tp2.cls.owner)
1038
+ isSubType (tp1.prefix, tp2.prefix) || (tp1.cls.owner derivesFrom tp2.cls.owner)
1054
1039
case _ =>
1055
1040
false
1056
1041
}
@@ -1066,7 +1051,7 @@ class TypeComparer(initctx: Context) extends DotClass {
1066
1051
tp2 match {
1067
1052
case tp2 : MethodType =>
1068
1053
def asGoodParams (formals1 : List [Type ], formals2 : List [Type ]) =
1069
- (formals2 corresponds formals1)(_ <:< _ )
1054
+ (formals2 corresponds formals1)(isSubType )
1070
1055
asGoodParams(tp1.paramTypes, tp2.paramTypes) &&
1071
1056
(! asGoodParams(tp2.paramTypes, tp1.paramTypes) ||
1072
1057
isAsGood(tp1.resultType, tp2.resultType))
0 commit comments