Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-8063

expose much needed methods in public reflection/macro API

    Details

      Description

      Ideally we should be able to write scala-async / sbt macros without resorting to down casting.

      • expose the current owner of the call site typer
      • conveniences like `paramss`, `typeArgs`, `resultType`, `finalResultType`
      • more to come

        Attachments

          Issue Links

            Activity

            Show
            burmako Eugene Burmako added a comment - https://github.com/scala/scala/pull/3452
            Hide
            pggiarrusso Paolo G. Giarrusso added a comment -

            What about moving TypeMap into scala.reflect.api? Or is one supposed to use it from .internal for now?

            // todo. move these into scala.reflect.api

            (from https://github.com/scala/scala/blob/fabc9f1424824975943241b9bb2c9b7669f805bd/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala#L94, on current master).

            Show
            pggiarrusso Paolo G. Giarrusso added a comment - What about moving TypeMap into scala.reflect.api? Or is one supposed to use it from .internal for now? // todo. move these into scala.reflect.api (from https://github.com/scala/scala/blob/fabc9f1424824975943241b9bb2c9b7669f805bd/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala#L94 , on current master).
            Hide
            burmako Eugene Burmako added a comment -

            What would be the use case for that? Could you provide some more detail?

            Show
            burmako Eugene Burmako added a comment - What would be the use case for that? Could you provide some more detail?
            Hide
            pggiarrusso Paolo G. Giarrusso added a comment -

            I agreed with the TODO because, given how hard type substitution is, if you ever need it you should reuse TypeMap.
            I suppose a use case would require a transformation on terms and types for some DSL implementation — a standard example in metaprogramming literature would be CPS conversion. (I also happen to have another such transformation in my last paper, at PLDI '14, but it's not a paradigmatic example, just some specific transformation).

            But I don't have a specific example I'm working on right now.

            Show
            pggiarrusso Paolo G. Giarrusso added a comment - I agreed with the TODO because, given how hard type substitution is, if you ever need it you should reuse TypeMap. I suppose a use case would require a transformation on terms and types for some DSL implementation — a standard example in metaprogramming literature would be CPS conversion. (I also happen to have another such transformation in my last paper, at PLDI '14, but it's not a paradigmatic example, just some specific transformation). But I don't have a specific example I'm working on right now.
            Hide
            burmako Eugene Burmako added a comment -

            On a related note, it would also be nice to have a convenient way to traverse trees, because Transformer can hardly be called convenient

            Speaking of tree transformers, I also have a hypothesis that with modest changes to compiler internals, we'll be able to downgrade from attributed trees to unattributed trees, so type mapping might actually be equivalent to tree mapping, which should be much easier to get right.

            Show
            burmako Eugene Burmako added a comment - On a related note, it would also be nice to have a convenient way to traverse trees, because Transformer can hardly be called convenient Speaking of tree transformers, I also have a hypothesis that with modest changes to compiler internals, we'll be able to downgrade from attributed trees to unattributed trees, so type mapping might actually be equivalent to tree mapping, which should be much easier to get right.

              People

              • Assignee:
                burmako Eugene Burmako
                Reporter:
                retronym Jason Zaugg
              • Votes:
                1 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: