0

for a example,append a implicit param id for func method:
Before

def func(p1: String) = { println("hi")}

After

@Param
def func(p1: String)(implicit id: String = "default") = { println("hi")}

Is scala meta able do this?

LoranceChen
  • 2,453
  • 2
  • 22
  • 48

1 Answers1

1

I got how to do this:

//create Param  
val impParam = Term.Param(Nil, Term.Name("id"), Some(Type.Name("String")), Some(Term.Name("default")))
//append to existing params seq.`defn` is this method meta object
val appendImpParam = defn.paramss :+ impParam

Notice: you'd better check if the method had exist implicit params.

LoranceChen
  • 2,453
  • 2
  • 22
  • 48