Skip to content

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

@tribbloid

Description

@tribbloid

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)
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions