What is the replacement in scala3 of scala2's `ClassTag <:<`?

Welcome to Scala 3.2.0-RC2 (17.0.3.1, Java Java HotSpot(TM) 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> import scala.reflect.ClassTag

scala> summon[ClassTag[Int]] <:< summon[ClassTag[AnyVal]]
1 warning found
-- Deprecation Warning: --------------------------------------------------------------------------------------------------------------------------------------------------------------------------

1 |summon[ClassTag[Int]] <:< summon[ClassTag[AnyVal]]
  |^^^^^^^^^^^^^^^^^^^^^^^^^
  |method <:< in trait ClassManifestDeprecatedApis is deprecated since 2.10.0: use scala.reflect.runtime.universe.TypeTag for subtype checking instead
val res0: Boolean = true

scala> import scala.reflect.runtime.universe.TypeTag
-- [E008] Not Found Error: -----------------------------------------------------------------------------------------------------------------------------------------------------------------------

1 |import scala.reflect.runtime.universe.TypeTag
  |       ^^^^^^^^^^^^^^^^^^^^^
  |       value runtime is not a member of reflect
1 error found
1 Like

Scala 3 does not have any equivalent to TypeTag for run-time reflection.

However, there exists a third party library izumi-reflect that aims at providing a replacement.

3 Likes

Depending on what your use case is exactly, using Scala 3 macros directly can also be the way to go instead. For instance consider: Obtaining the name of a type (Scala 3) - #6 by hmf

I’m myself going through that for my library, and I have been able to replace most of my former reliance on scala.reflect.runtime with scala.quoted counterparts (e.g utilities that were in this, the result of which I’ll post soon)

1 Like

You just did. But you can do it again. :wink:

(though probably you should open a new discussion, even if it links to or quotes this one)

I am so unlucky, that if I found a bottle with a genie inside, I would uncork it and sjrd would appear and trick me out of a wish. “I said genie, not genius!”

My question is, how can I use chatgpt to reply on moribund threads with embedded commercial links?

The reply should appear friendly and helpful and of genius quality, much like sjrd.

1 Like