Skip to content
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

Compile time whitebox macro returns a type that is too wide #17

Open
tribbloid opened this issue Apr 28, 2021 · 0 comments
Open

Compile time whitebox macro returns a type that is too wide #17

tribbloid opened this issue Apr 28, 2021 · 0 comments

Comments

@tribbloid
Copy link

Demo:

  import shapeless.syntax.singleton._
  import shapeless.record._

  it("can get name singleton") {

    val t1 = NameOf.nameOfType[Seq[Int]]

    val record = (t1 ->> "r") :: "a" ->> 5 :: HNil

    val r = record.apply("Seq")

    println(r)
  }

which compiles to the following error:

[Error] /home/peng/git/shapesafe/core/src/test/scala/org/shapesafe/core/debugging/InfoCTSpec.scala:19: No field String("Seq") in record String with shapeless.labelled.KeyTag[t1.type,String] :: Int with shapeless.labelled.KeyTag[String("a"),Int] :: shapeless.HNil
one error found

This doesn't use the full potential of the macro, as t1 can be assigned a singleton type "Seq" in scala 2.13, or a witnessed type in scala < 2.13 using shapeless

The following works however in scala 2.13, not sure how:

  import shapeless.syntax.singleton._
  import shapeless.record._

  it("can get name singleton") {

    val t1: "Seq" = NameOf.nameOfType[Seq[Int]]

    val record = (t1 ->> "r") :: "a" ->> 5 :: HNil

    val r = record.apply("Seq")

    println(r)
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant