Skip to content

Commit 68085fc

Browse files
committed
Move and refine flexible type cases
1 parent a72552b commit 68085fc

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,14 +562,11 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
562562
val underlying1 = recur(tp.underlying)
563563
if underlying1 ne tp.underlying then underlying1 else tp
564564
case CapturingType(parent, refs) =>
565-
val parent1 = recur(parent)
566-
if parent1 ne parent then tp.derivedCapturingType(parent1, refs) else tp
565+
tp.derivedCapturingType(recur(parent), refs)
567566
case tp: FlexibleType =>
568-
val hi = recur(tp.hi)
569-
if hi ne tp.hi then tp.derivedFlexibleType(hi) else tp
567+
tp.derivedFlexibleType(recur(tp.hi))
570568
case tp: AnnotatedType =>
571-
val parent1 = recur(tp.parent)
572-
if parent1 ne tp.parent then tp.derivedAnnotatedType(parent1, tp.annot) else tp
569+
tp.derivedAnnotatedType(recur(tp.parent), tp.annot)
573570
case _ =>
574571
val tp1 = tp.dealiasKeepAnnots
575572
if tp1 ne tp then

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,10 +1619,11 @@ object Types extends TypeUtils {
16191619

16201620
/** If this is a repeated type, its element type, otherwise the type itself */
16211621
def repeatedToSingle(using Context): Type = this match {
1622+
case tp @ ExprType(tp1) => tp.derivedExprType(tp1.repeatedToSingle)
16221623
case tp: FlexibleType =>
1624+
// The flexible type is handled here because the varargs from Java can be nullable.
16231625
val underlyingSingle = tp.underlying.repeatedToSingle
16241626
if underlyingSingle ne tp.underlying then underlyingSingle else tp
1625-
case tp @ ExprType(tp1) => tp.derivedExprType(tp1.repeatedToSingle)
16261627
case _ => if (isRepeatedParam) this.argTypesHi.head else this
16271628
}
16281629

0 commit comments

Comments
 (0)