Skip to content

Commit 326feb1

Browse files
committed
Fix handling of Nothing in OrType atoms
1 parent 1e19250 commit 326feb1

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3483,9 +3483,11 @@ object Types {
34833483
private var myWidened: Type = _
34843484

34853485
private def computeAtoms()(using Context): Atoms =
3486-
if tp1.hasClassSymbol(defn.NothingClass) then tp2.atoms
3487-
else if tp2.hasClassSymbol(defn.NothingClass) then tp1.atoms
3488-
else tp1.atoms | tp2.atoms
3486+
val tp1n = tp1.normalized
3487+
val tp2n = tp2.normalized
3488+
if tp1n.hasClassSymbol(defn.NothingClass) then tp2.atoms
3489+
else if tp2n.hasClassSymbol(defn.NothingClass) then tp1.atoms
3490+
else tp1n.atoms | tp2n.atoms
34893491

34903492
private def computeWidenSingletons()(using Context): Type =
34913493
val tp1w = tp1.widenSingletons

compiler/test/dotc/pos-test-pickling.blacklist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ i15155.scala
5252
i15827.scala
5353
i17149.scala
5454
tuple-fold.scala
55+
mt-redux-norm.perspective.scala
5556

5657
# Opaque type
5758
i5720.scala
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// while making MT post-redux consistent in its normalisation/simplification
2+
// one version of the change broke a line of the perspective community project in CI
3+
// this is a minimisation of the failure
4+
5+
import scala.compiletime._, scala.deriving._
6+
7+
transparent inline def foo(using m: Mirror): Unit =
8+
constValueTuple[m.MirroredElemLabels].toList.toSet // was:
9+
//-- [E057] Type Mismatch Error: cat.scala:8:14 ----------------------------------
10+
//8 |def test = foo(using summon[Mirror.Of[Cat]])
11+
// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
// |Type argument ("name" : String) | Nothing does not conform to lower bound m$proxy1.MirroredElemLabels match {
13+
// | case EmptyTuple => Nothing
14+
// | case h *: t => h | Tuple.Fold[t, Nothing, [x, y] =>> x | y]
15+
// |}
16+
// |-----------------------------------------------------------------------------
17+
// |Inline stack trace
18+
// |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
19+
// |This location contains code that was inlined from cat.scala:4
20+
//4 | constValueTuple[m.MirroredElemLabels].toList.toSet
21+
// | ^
22+
23+
case class Cat(name: String)
24+
25+
def test = foo(using summon[Mirror.Of[Cat]])

0 commit comments

Comments
 (0)