Skip to content

Is it possible to obtain the corresponding TypeTree from TypeParamRef using macro functionality? #17374

Closed Answered by cacapouh
cacapouh asked this question in Metaprogramming
Discussion options

You must be logged in to vote

I may have found a way to solve the Meta-Problem, although it may not be a good approach:

    def makeMethods(cls: Symbol): List[Statement] = {
      TypeRepr.of[T].typeSymbol.declaredMethods.map { d =>
        def rhsFn(params: List[List[Tree]]): Option[Term] = {
          val symbol = cls.declarations.find(_.name == d.name).head

          val returnTypeInDecration = d.tree match
            case DefDef(_, _, typeTree, _) =>
              typeTree
          val returnTypeInParams =  params.flatten.collect {
            case t: TypeTree if t.tpe.typeSymbol.name == returnTypeInDecration.tpe.typeSymbol.name =>
              t
          }
          
          Some(
            TypeApply(
  …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cacapouh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant