-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression (?) in softwaremill/tapir - refined type returned in a macro unable to be matched #19458
Comments
I think this issue origined in the SIP-56 and the new match types #18262 (comment) |
This is an |
Minimizedmacro.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 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 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.
The text was updated successfully, but these errors were encountered: