Closed jchyb closed 6 months ago
I think this issue origined in the SIP-56 and the new match types https://github.com/lampepfl/dotty/pull/18262#issuecomment-1848377927 @sjrd can you can a look at this issue?
This is an inline match
, not a match type. SIP-56 did not touch those.
macro.scala // same
main.scala
import scala.compiletime._
inline def summonValidators[A <: Tuple]: Int =
inline erasedValue[A] match
case _: EmptyTuple => 1
case _: (head *: tail) => 2
def main() =
val mirror = IntersectionTypeMirror.derived[Some[Any] & Option[Int]]
summonValidators[mirror.ElementTypes]
For the minimized example, the type that we get from rec(and)
case and: AndType => rec(and).asType.asInstanceOf[Type[Elems]]
is
scala.Tuple.Concat[
scala.*:[_ >: scala.Nothing <: scala.Any, _ >: scala.Nothing <: scala.Any][scala.Some[scala.Any], scala.Tuple$package.EmptyTuple],
scala.*:[_ >: scala.Nothing <: scala.Any, _ >: scala.Nothing <: scala.Any][scala.Option[scala.Int], scala.Tuple$package.EmptyTuple]]
This is a nonsensical type. I suspect there is a bug in the macro implementation. My guess is in the use of
val tplPrependType = TypeRepr.of[? *: ?]
This is a way to fix prependTypes
def prependTypes(head: TypeRepr, tail: TypeRepr): TypeRepr =
(head.asType, tail.asType) match {
case ('[h], '[type t <: Tuple; t]) => TypeRepr.of[h *: t]
}
Fixed and merged in tapir
Compiler version
3.4.0-RC1-bin-20240115-31f837e-NIGHTLY, compiles successfully with 3.3.1
Minimized code
main.scala:
macro.scala:
Output
Expectation
I think it should compile. The code used in tapir actually uses non-transparent inlines in code that calls transparent inlines, which I don't think should have worked, but did (probably because of the previous match types). But even after correcting that, the code errors with what seems to be an abstract type member.