Skip to content

Commit fd61afb

Browse files
committed
Refine logic for widenSingle
1 parent 612ba92 commit fd61afb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -654,17 +654,17 @@ trait ConstraintHandling {
654654
if tpw ne tp then
655655
if tpw.isTransparent() then
656656
// Now also widen singletons of soft unions. Before these were skipped
657-
// since we widenUnion on soft unions is independent of whether singletons
657+
// since widenUnion on soft unions is independent of whether singletons
658658
// are widened or not. This avoids an expensive subtype check in widenSingle,
659-
// see 19907_*.scala for test cases.
660-
tp.widenSingletons()
659+
// see i19907_*.scala for test cases.
660+
widenSingle(tp, skipSoftUnions = false)
661661
else if tpw <:< bound then tpw
662662
else tp
663663
else tp
664664
else tp.hardenUnions
665665

666-
def widenSingle(tp: Type) =
667-
val tpw = tp.widenSingletons(skipSoftUnions = widenUnions)
666+
def widenSingle(tp: Type, skipSoftUnions: Boolean) =
667+
val tpw = tp.widenSingletons(skipSoftUnions)
668668
if (tpw ne tp) && (tpw <:< bound) then tpw else tp
669669

670670
def isSingleton(tp: Type): Boolean = tp match
@@ -674,7 +674,7 @@ trait ConstraintHandling {
674674
val wideInst =
675675
if isSingleton(bound) then inst
676676
else
677-
val widenedFromSingle = widenSingle(inst)
677+
val widenedFromSingle = widenSingle(inst, skipSoftUnions = widenUnions)
678678
val widenedFromUnion = widenOr(widenedFromSingle)
679679
val widened = dropTransparentTraits(widenedFromUnion, bound)
680680
widenIrreducible(widened)

0 commit comments

Comments
 (0)