Skip to content

Commit 2ea9d6e

Browse files
noti0na1tgodzik
authored andcommitted
Refine logic for widenSingle
[Cherry-picked fd61afb]
1 parent 9a08f21 commit 2ea9d6e

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
@@ -663,17 +663,17 @@ trait ConstraintHandling {
663663
if tpw ne tp then
664664
if tpw.isTransparent() then
665665
// Now also widen singletons of soft unions. Before these were skipped
666-
// since we widenUnion on soft unions is independent of whether singletons
666+
// since widenUnion on soft unions is independent of whether singletons
667667
// are widened or not. This avoids an expensive subtype check in widenSingle,
668-
// see 19907_*.scala for test cases.
669-
tp.widenSingletons()
668+
// see i19907_*.scala for test cases.
669+
widenSingle(tp, skipSoftUnions = false)
670670
else if tpw <:< bound then tpw
671671
else tp
672672
else tp
673673
else tp.hardenUnions
674674

675-
def widenSingle(tp: Type) =
676-
val tpw = tp.widenSingletons(skipSoftUnions = widenUnions)
675+
def widenSingle(tp: Type, skipSoftUnions: Boolean) =
676+
val tpw = tp.widenSingletons(skipSoftUnions)
677677
if (tpw ne tp) && (tpw <:< bound) then tpw else tp
678678

679679
def isSingleton(tp: Type): Boolean = tp match
@@ -683,7 +683,7 @@ trait ConstraintHandling {
683683
val wideInst =
684684
if isSingleton(bound) then inst
685685
else
686-
val widenedFromSingle = widenSingle(inst)
686+
val widenedFromSingle = widenSingle(inst, skipSoftUnions = widenUnions)
687687
val widenedFromUnion = widenOr(widenedFromSingle)
688688
val widened = dropTransparentTraits(widenedFromUnion, bound)
689689
widenIrreducible(widened)

0 commit comments

Comments
 (0)