Skip to content

Commit 04e787a

Browse files
committed
Cache the instantiations of ErasedValueType
This way, ErasedValueType(a, b) <:< ErasedValueType(a, b) will always return true.
1 parent 7313691 commit 04e787a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/dotty/tools/dotc/core/TypeErasure.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dotc
33
package core
44

55
import Symbols._, Types._, Contexts._, Flags._, Names._, StdNames._, Decorators._, Flags.JavaDefined
6+
import Uniques.unique
67
import dotc.transform.ExplicitOuter._
78
import typer.Mode
89
import util.DotClass
@@ -51,10 +52,19 @@ object TypeErasure {
5152
false
5253
}
5354

54-
case class ErasedValueType(cls: ClassSymbol, underlying: Type) extends CachedGroundType {
55+
abstract case class ErasedValueType(cls: ClassSymbol, underlying: Type)
56+
extends CachedGroundType with ValueType {
5557
override def computeHash = doHash(cls, underlying)
5658
}
5759

60+
final class CachedErasedValueType(cls: ClassSymbol, underlying: Type) extends ErasedValueType(cls, underlying)
61+
62+
object ErasedValueType {
63+
def apply(cls: ClassSymbol, underlying: Type)(implicit ctx: Context) = {
64+
unique(new CachedErasedValueType(cls, underlying))
65+
}
66+
}
67+
5868
private def erasureIdx(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wildcardOK: Boolean) =
5969
(if (isJava) 1 else 0) +
6070
(if (isSemi) 2 else 0) +

0 commit comments

Comments
 (0)