Closed
Description
Compiler version
3.1.0
Minimized code
import scala.deriving.*
type Kind[C, O[_]] = C {
type MirroredType[X] = O[X]
type MirroredMonoType = O[Any]
type MirroredElemTypes[_] <: Tuple
}
type ProductGeneric[O[_]] = Kind[Mirror.Product, O]
type Test = [X] =>> (X, Boolean)
val x = summon[ProductGeneric[Test]]
Output
Compile with scalac -Xprint:typer
:
[[syntax trees at end of typer]] // broken.scala
package <empty> {
import scala.deriving.*
final lazy module val broken$package: broken$package = new broken$package()
final module class broken$package() extends Object() {
this: broken$package.type =>
type Kind[C >: Nothing <: Any, O[_ >: Nothing <: Any] >: Nothing <: Any] =
C
{
type MirroredType[X >: Nothing <: Any] = O[X]
type MirroredMonoType = O[Any]
type MirroredElemTypes[_ >: Nothing <: Any] >: Nothing <: Tuple
}
type ProductGeneric[O[_ >: Nothing <: Any] >: Nothing <: Any] =
Kind[deriving.Mirror.Product, O]
type Test[X >: Nothing <: Any] = Tuple2[X, Boolean]
val x:
(
deriving.Mirror.Product{
MirroredType[X] = (X, Boolean); MirroredMonoType = (Any, Boolean);
MirroredElemTypes[_$2] <: Tuple
}
&
scala.deriving.Mirror.Product{
MirroredMonoType = (?, Boolean); MirroredType[X] = (X, Boolean);
MirroredLabel = ("Tuple2" : String)
}
){
MirroredElemTypes[X] = (=> T1, => T2);
MirroredElemLabels = (("_1" : String), ("_2" : String))
}
=
{
final class $anon() extends Object() {
type MirroredMonoType = (?, Boolean)
}
(new $anon():Object)
}.$asInstanceOf[
(
deriving.Mirror.Product{
MirroredType[X] = (X, Boolean); MirroredMonoType = (Any, Boolean)
;
MirroredElemTypes[_$2] <: Tuple
}
&
scala.deriving.Mirror.Product{
MirroredMonoType = (?, Boolean); MirroredType[X] = (X, Boolean);
MirroredLabel = ("Tuple2" : String)
}
){
MirroredElemTypes[X] = (=> T1, => T2);
MirroredElemLabels = (("_1" : String), ("_2" : String))
}
]
}
}
Expectation
We should see MirroredElemTypes[X] = (X, Boolean)
.
If we replace type Test = [X] =>> (X, Boolean)
with case class Test[X](l: X, r: Boolean)
then it works as expected.
For context, this arose when investigating typelevel/shapeless-3#46.