Macros: Create Function type of arbitrary arity via the reflect API #23326
                  
                    
                      TomasMikula
                    
                  
                
                  started this conversation in
                Feature Requests
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, it is not possible (to the best of my knowledge) to create a function type (like
Function3orFunction52) whose number and types of parameters become known only at macro expansion time.There is the
Closure(meth: Term, tpe: Option[TypeRepr])method to construct such functions as terms, but I'm lacking a way to explicitly assign a type to such functions (via thetpeparameter), as I'm unable to construct such function type.My use case is to preserve the parameter names of the method the
Closureis closing over. I.e., I don't want parameters to be namedv1,v2, ... as inFunctionN, but use custom names.As an unstable workaround, I'm tapping into compiler-internal APIs to achieve that:
This is a request to provide a public API to create function types, something like
Beta Was this translation helpful? Give feedback.
All reactions