Skip to content

Typer regression in creativescala/krop #23095

Closed
@WojciechMazur

Description

@WojciechMazur

Based on OpenCB failure in creativescala/krop - build logs. Discovered after codebase changes between version 0.8.0 -> 0.9.2

Compiler version

Last good release: 3.6.4-RC1-bin-20250112-ae980a7-NIGHTLY
First bad release: 3.6.4-RC1-bin-20250113-c10def4-NIGHTLY
Bisect points to 56b60ac

Minimized code

// defs.scala
import scala.compiletime.*
import scala.deriving.*

trait SeqStringCodec[A]:
  def decode(value: Seq[String]): Either[Any, A]

trait UrlForm
trait FormCodec[A]

object FormCodec {
  inline given derived[A](using p: Mirror.ProductOf[A]): FormCodec[A] =
    val codecs = summonAll[Tuple.Map[p.MirroredElemTypes, SeqStringCodec]].toArray
    val values = codecs.map {
      _.asInstanceOf[SeqStringCodec[?]]
        .decode(List.empty[String])
    }
    ???
}
// test.scala
given SeqStringCodec[Int] = ???
given SeqStringCodec[String] = ???
final case class Form(int: Int, string: String) derives FormCodec

Output

-- [E007] Type Mismatch Error: /Users/wmazur/projects/scala/sandbox/codec.test.scala:3:56 ---------------------------------------------------------------------------------------------------
 3 |final case class Form(int: Int, string: String) derives FormCodec
   |                                                        ^
   |                                                        Found:    Either[Any, SeqStringCodec[?]#A]
   |                                                        Required: Either[Any, ?1.A]
   |
   |                                                        where:    ?1 is an unknown value of type SeqStringCodec[?]
   |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   |Inline stack trace
   |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   |This location contains code that was inlined from codec.scala:15
14 |      _.asInstanceOf[SeqStringCodec[?]]
15 |        .decode(List.empty[String])
   |      ^
    -------------------------------------------------------------------

Expectation

Probably should continue to compile

Workaround

<       _.asInstanceOf[SeqStringCodec[?]]
---
>       _.asInstanceOf[SeqStringCodec[Any]]

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions