Skip to content

Commit 6e256b7

Browse files
committed
Fix lubbing, push isSoft=false through
1 parent de4ad2b commit 6e256b7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2388,7 +2388,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
23882388
case Atoms.Range(lo2, hi2) =>
23892389
if hi1.subsetOf(lo2) then return tp2
23902390
if hi2.subsetOf(lo1) then return tp1
2391-
if (hi1 & hi2).isEmpty then return orType(tp1, tp2)
2391+
if (hi1 & hi2).isEmpty then return orType(tp1, tp2, isSoft = isSoft)
23922392
case none =>
23932393
case none =>
23942394
val t1 = mergeIfSuper(tp1, tp2, canConstrain)

tests/pos/i18626.min1.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
sealed trait Animal
2+
object Cat extends Animal
3+
object Dog extends Animal
4+
5+
type Mammal = Cat.type | Dog.type
6+
7+
class Test:
8+
def t1 =
9+
val mammals: List[Mammal] = ???
10+
val result = mammals.head
11+
val mammal: Mammal = result // was: Type Mismatch Error:
12+
// Found: (result : Animal)
13+
// Required: Mammal
14+
()

0 commit comments

Comments
 (0)