Skip to content

Commit 28c93a7

Browse files
olhotaknoti0na1
authored andcommitted
refactor to simplify definition of FlexibleType
1 parent 4b8319a commit 28c93a7

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3408,19 +3408,12 @@ object Types {
34083408

34093409
// --- FlexibleType -----------------------------------------------------------------
34103410

3411-
case class FlexibleType(tp: Type) extends CachedGroundType with ValueType {
3412-
def hi(using Context) = {
3413-
this.tp
3414-
}
3415-
def lo(using Context) = {
3416-
OrNull(this.tp)
3417-
}
3418-
override def show(using Context) = "FlexibleType("+tp.show+")"
3419-
def underlying(using Context) : Type = this.tp
3411+
case class FlexibleType(underlying: Type) extends CachedGroundType with ValueType {
3412+
def lo(using Context): Type = OrNull(underlying)
3413+
override def show(using Context) = i"FlexibleType($underlying)"
34203414
def derivedFlexibleType(under: Type)(using Context): Type =
3421-
if this.tp eq under then this else FlexibleType(under)
3422-
override def computeHash(bs: Binders): Int = doHash(bs, tp)
3423-
override def toString = "FlexibleType(%s)".format(tp)
3415+
if this.underlying eq under then this else FlexibleType(under)
3416+
override def computeHash(bs: Binders): Int = doHash(bs, underlying)
34243417
override final def baseClasses(using Context): List[ClassSymbol] = underlying.baseClasses
34253418
}
34263419

0 commit comments

Comments
 (0)