Skip to content

Commit 2f0785d

Browse files
committed
avoid minimize in prefix inference
1 parent fdb9e99 commit 2f0785d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
292292
private val nullType = ConstantType(Constant(null))
293293
private val nullSpace = Typ(nullType)
294294

295-
override def intersectUnrelatedAtomicTypes(tp1: Type, tp2: Type) = {
295+
override def intersectUnrelatedAtomicTypes(tp1: Type, tp2: Type): Space = {
296296
val and = AndType(tp1, tp2)
297297
// Precondition: !(tp1 <:< tp2) && !(tp2 <:< tp1)
298298
// Then, no leaf of the and-type tree `and` is a subtype of `and`.
@@ -689,7 +689,8 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
689689
tvar =>
690690
!(ctx.typerState.constraint.entry(tvar.origin) `eq` tvar.origin.underlying) ||
691691
(tvar `eq` removeThisType.prefixTVar),
692-
minimizeAll = false
692+
minimizeAll = false,
693+
allowBottom = false
693694
)
694695

695696
// If parent contains a reference to an abstract type, then we should

compiler/src/dotty/tools/dotc/typer/Inferencing.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ object Inferencing {
115115
val minimize =
116116
force.minimizeAll ||
117117
variance >= 0 && !(
118-
force == ForceDegree.noBottom &&
118+
!force.allowBottom &&
119119
defn.isBottomType(ctx.typeComparer.approximation(tvar.origin, fromBelow = true)))
120120
if (minimize) instantiate(tvar, fromBelow = true)
121121
else toMaximize = true
@@ -466,9 +466,9 @@ trait Inferencing { this: Typer =>
466466

467467
/** An enumeration controlling the degree of forcing in "is-dully-defined" checks. */
468468
@sharable object ForceDegree {
469-
class Value(val appliesTo: TypeVar => Boolean, val minimizeAll: Boolean)
469+
class Value(val appliesTo: TypeVar => Boolean, val minimizeAll: Boolean, val allowBottom: Boolean = true)
470470
val none = new Value(_ => false, minimizeAll = false)
471471
val all = new Value(_ => true, minimizeAll = false)
472-
val noBottom = new Value(_ => true, minimizeAll = false)
472+
val noBottom = new Value(_ => true, minimizeAll = false, allowBottom = false)
473473
}
474474

0 commit comments

Comments
 (0)