Skip to content

Commit 6b7ecd5

Browse files
committed
refactor to simplify definition of FlexibleType
1 parent beeef41 commit 6b7ecd5

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

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

+5-12
Original file line numberDiff line numberDiff line change
@@ -3361,19 +3361,12 @@ object Types {
33613361

33623362
// --- FlexibleType -----------------------------------------------------------------
33633363

3364-
case class FlexibleType(tp: Type) extends CachedGroundType with ValueType {
3365-
def hi(using Context) = {
3366-
this.tp
3367-
}
3368-
def lo(using Context) = {
3369-
OrNull(this.tp)
3370-
}
3371-
override def show(using Context) = "FlexibleType("+tp.show+")"
3372-
def underlying(using Context) : Type = this.tp
3364+
case class FlexibleType(underlying: Type) extends CachedGroundType with ValueType {
3365+
def lo(using Context): Type = OrNull(underlying)
3366+
override def show(using Context) = i"FlexibleType($underlying)"
33733367
def derivedFlexibleType(under: Type)(using Context): Type =
3374-
if this.tp eq under then this else FlexibleType(under)
3375-
override def computeHash(bs: Binders): Int = doHash(bs, tp)
3376-
override def toString = "FlexibleType(%s)".format(tp)
3368+
if this.underlying eq under then this else FlexibleType(under)
3369+
override def computeHash(bs: Binders): Int = doHash(bs, underlying)
33773370
override final def baseClasses(using Context): List[ClassSymbol] = underlying.baseClasses
33783371
}
33793372

0 commit comments

Comments
 (0)