zio / izumi-reflect

TypeTag without scala-reflect. Supports Scala 2 and Scala 3.
https://zio.dev/izumi-reflect
Other
139 stars 35 forks source link

False-positive subtype checking for Scala 3 opaque types #472

Open kyri-petrou opened 1 month ago

kyri-petrou commented 1 month ago

For some reason, when 2 Scala 3 opaque types have the same underlying type, the subtype check <:< seems to falsely return true. AFAICT, this seems to be what's causing https://github.com/zio/zio/issues/8882 (albeit there might be more to it, but first things first 😅)

Repro:

import izumi.reflect.Tag

type UserName = UserName.T
object UserName {
  opaque type T = String
}

type UserId = UserId.T
object UserId {
  opaque type T = String
}

val idTag   = Tag[UserId]
val nameTag = Tag[UserName]

@main def m = {
  assert(!(idTag =:= nameTag), "idTag =:= nameTag") // passes
  assert(!(idTag <:< nameTag), "idTag <:< nameTag") // fails
}
neko-kai commented 1 month ago

Addressed in https://github.com/zio/izumi-reflect/pull/468