Skip to content

Instantly share code, notes, and snippets.

@lbialy
Created October 6, 2019 21:05
Show Gist options
  • Save lbialy/bba3b58ea4ecabcbeed7e57792b8e325 to your computer and use it in GitHub Desktop.
Save lbialy/bba3b58ea4ecabcbeed7e57792b8e325 to your computer and use it in GitHub Desktop.
Checking whether native-image is fine with non-evaluated Lazy[TypeTag[A]] guards
import scala.reflect.runtime.universe.TypeTag
import shapeless._
object LazyTypeTagGuardTest {
case class Whatever()
type X
def f[A](xd: A)(implicit ev: Lazy[TypeTag[A]]) = ev.value.tpe.toString
final def main(args: Array[String]): Unit = {
lazy val test = f(Whatever())
lazy val test2 = f(Array.empty[Int])
// lazy val test3 = f[X](???) // does not compile: No TypeTag available for Test.X
println("Hello world")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment