Skip to content

Commit 16170a5

Browse files
authored
Merge pull request #11340 from dotty-staging/fix-11250
Fix unpickling of match type aliases
2 parents 6fe5f8e + 7c3dce2 commit 16170a5

File tree

5 files changed

+41
-5
lines changed

5 files changed

+41
-5
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,10 +858,7 @@ class TreeUnpickler(reader: TastyReader,
858858
rhs.tpe.typeParams
859859
}
860860
sym.info = sym.opaqueToBounds(
861-
rhs.tpe match {
862-
case _: TypeBounds | _: ClassInfo => checkNonCyclic(sym, rhs.tpe, reportErrors = false)
863-
case _ => rhs.tpe.toBounds
864-
},
861+
checkNonCyclic(sym, rhs.tpe.toBounds, reportErrors = false),
865862
rhs, rhs.tpe.typeParams)
866863
if sym.isOpaqueAlias then sym.typeRef.recomputeDenot() // make sure we see the new bounds from now on
867864
sym.resetFlag(Provisional)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ trait TypeAssigner {
463463
def assignType(tree: untpd.TypeBoundsTree, lo: Tree, hi: Tree, alias: Tree)(using Context): TypeBoundsTree =
464464
tree.withType(
465465
if !alias.isEmpty then alias.tpe
466-
else if lo eq hi then TypeAlias(lo.tpe)
466+
else if lo eq hi then
467+
if lo.tpe.isMatch then MatchAlias(lo.tpe)
468+
else TypeAlias(lo.tpe)
467469
else TypeBounds(lo.tpe, hi.tpe))
468470

469471
def assignType(tree: untpd.Bind, sym: Symbol)(using Context): Bind =

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ i7872.scala
3434
6687.scala
3535
i11236.scala
3636
i11247.scala
37+
i11250
3738

3839
# Opaque type
3940
i5720.scala

tests/pos/i11250/1.scala

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package shapeless3.data
2+
3+
import scala.compiletime._
4+
5+
trait Monoidal {
6+
type to[_] <: Tuple
7+
type length[m] = Monoidal.length[to[m]]
8+
}
9+
10+
object Monoidal {
11+
import Tuple._
12+
13+
type length[m <: Tuple] = Size[m]
14+
}
15+
16+
trait UnboundedMonoidal[T0[_, _], U0] extends Monoidal {
17+
type to[t] <: Tuple = t match {
18+
case T0[hd, tl] => hd *: to[tl]
19+
case U0 => EmptyTuple
20+
}
21+
}
22+
23+
object pairs extends UnboundedMonoidal[Tuple2, Unit]
24+
25+
object MonoidalTest { // Compiles fine here
26+
type p = (Int, (String, (Boolean, Unit)))
27+
summon[pairs.length[p] =:= 3]
28+
}
29+

tests/pos/i11250/2.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package shapeless3.data
2+
3+
object MonoidalTest2 { // But not here
4+
type p = (Int, (String, (Boolean, Unit)))
5+
summon[pairs.length[p] =:= 3]
6+
}
7+

0 commit comments

Comments
 (0)