Skip to content

Commit 442581d

Browse files
committed
Fix #3250: Make HKLambda a cached type
This is a partial revert from #3239. #3239 made both HKLambdas and PolyTypes uncached. It turns out that this breaks things if we do it for HKLambdas. I have not yet figured out why, however. The test case in #3250 is a bit too large to be able to tell.
1 parent d52f98c commit 442581d

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,7 +2599,32 @@ object Types {
25992599
final override def toString = s"$prefixString($paramNames, $paramInfos, $resType)"
26002600
}
26012601

2602-
trait HKLambda extends LambdaType
2602+
abstract class HKLambda extends CachedProxyType with LambdaType {
2603+
final override def underlying(implicit ctx: Context) = resType
2604+
2605+
final override def computeHash = doHash(paramNames, resType, paramInfos)
2606+
2607+
final override def equals(that: Any) = that match {
2608+
case that: HKLambda =>
2609+
paramNames == that.paramNames &&
2610+
paramInfos == that.paramInfos &&
2611+
resType == that.resType &&
2612+
companion.eq(that.companion)
2613+
case _ =>
2614+
false
2615+
}
2616+
2617+
final override def eql(that: Type) = that match {
2618+
case that: HKLambda =>
2619+
paramNames.equals(that.paramNames) &&
2620+
paramInfos.equals(that.paramInfos) &&
2621+
resType.equals(that.resType) &&
2622+
companion.eq(that.companion)
2623+
case _ =>
2624+
false
2625+
}
2626+
}
2627+
26032628
trait MethodOrPoly extends LambdaType with MethodicType
26042629

26052630
trait TermLambda extends LambdaType { thisLambdaType =>
@@ -2909,7 +2934,7 @@ object Types {
29092934
*/
29102935
class HKTypeLambda(val paramNames: List[TypeName])(
29112936
paramInfosExp: HKTypeLambda => List[TypeBounds], resultTypeExp: HKTypeLambda => Type)
2912-
extends UncachedProxyType with HKLambda with TypeLambda {
2937+
extends HKLambda with TypeLambda {
29132938
type This = HKTypeLambda
29142939
def companion = HKTypeLambda
29152940

@@ -2919,8 +2944,6 @@ object Types {
29192944
assert(resType.isInstanceOf[TermType], this)
29202945
assert(paramNames.nonEmpty)
29212946

2922-
final override def underlying(implicit ctx: Context) = resType
2923-
29242947
protected def prefixString = "HKTypeLambda"
29252948
}
29262949

0 commit comments

Comments
 (0)