Scala Programming Language
  1. Scala Programming Language
  2. SI-6186

macros should only allow AbsTypeTag context bounds

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.0-M6, Scala 2.10.0
    • Component/s: Macros
    • Labels:
      None

      Description

      Back then, we had TypeTag (=AbsTypeTag now) and ConcreteTypeTag (=TypeTag now), and people used "TypeTag" context bounds everywhere (I guess that's because if everyone mentions "type tags", then your knee jerk reaction is to write TypeTag without even suspecting that there's ConcreteTypeTag). As a result, things like this could happen (and actually happened): https://issues.scala-lang.org/browse/SI-5884. So we decided to make concrete type tags the default choice to prevent confusion.

      However for macros the situation is exactly the opposite. As you rightly mentioned, AbsTypeTags are most often the right choice. At first, I thought that this won't be a problem, because people who write macros will be more experienced than people who just want to migrate from manifests. However on a second thought I think we fall into the same problem - encouraging people to shoot off their feet (and the "more experienced" argument is just an excuse).

      I think we should simply prohibit TypeTags in macro impl context bounds, leaving AbsTypeTag as the only supported bound. If a macro really-really needs concreteness guarantees (and, as your example above shows, that would be an exceptional case), then this verification can be easily performed inside the macro body.

        Activity

        Show
        Eugene Burmako added a comment - Discussion: http://groups.google.com/group/scala-internals/browse_thread/thread/35d0fc5adc1ffae4
        Hide
        Eugene Burmako added a comment -

        "Something to consider as well is having Context.typeOf use AbsTypeTag"

        Show
        Eugene Burmako added a comment - "Something to consider as well is having Context.typeOf use AbsTypeTag"
        Show
        Eugene Burmako added a comment - https://github.com/scala/scala/pull/1080

          People

          • Assignee:
            Eugene Burmako
            Reporter:
            Eugene Burmako
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development