Rogach
Rogach

Reputation: 27250

Is it possible to generate Apply from Tree and a MethodSymbol?

I have acquired a MethodSymbol from some class, and now I want create a code that invokes that method on some tree:

tpe.declarations.collect {
  case acc: MethodSymbol =>
    Apply(Select(tree.duplicate, ???), Nil)
}

Is it possible to get the name of a method in a clean way?

Upvotes: 3

Views: 71

Answers (1)

Travis Brown
Travis Brown

Reputation: 139058

The universe has a Select factory method that takes a symbol as its second argument, so you'd just write the following:

tpe.declarations.collect {
  case acc: MethodSymbol => Select(tree.duplicate, acc)
}

Note that you don't need the Apply here.

Upvotes: 1

Related Questions