Skip to content

Commit 0929386

Browse files
olhotaknoti0na1
authored andcommitted
refactor to simplify definition of FlexibleType
1 parent 6bcd6db commit 0929386

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
@@ -3402,19 +3402,12 @@ object Types {
34023402

34033403
// --- FlexibleType -----------------------------------------------------------------
34043404

3405-
case class FlexibleType(tp: Type) extends CachedGroundType with ValueType {
3406-
def hi(using Context) = {
3407-
this.tp
3408-
}
3409-
def lo(using Context) = {
3410-
OrNull(this.tp)
3411-
}
3412-
override def show(using Context) = "FlexibleType("+tp.show+")"
3413-
def underlying(using Context) : Type = this.tp
3405+
case class FlexibleType(underlying: Type) extends CachedGroundType with ValueType {
3406+
def lo(using Context): Type = OrNull(underlying)
3407+
override def show(using Context) = i"FlexibleType($underlying)"
34143408
def derivedFlexibleType(under: Type)(using Context): Type =
3415-
if this.tp eq under then this else FlexibleType(under)
3416-
override def computeHash(bs: Binders): Int = doHash(bs, tp)
3417-
override def toString = "FlexibleType(%s)".format(tp)
3409+
if this.underlying eq under then this else FlexibleType(under)
3410+
override def computeHash(bs: Binders): Int = doHash(bs, underlying)
34183411
override final def baseClasses(using Context): List[ClassSymbol] = underlying.baseClasses
34193412
}
34203413

0 commit comments

Comments
 (0)