St.Antario
St.Antario

Reputation: 27375

Detecting all classes extending trait

I have the following trait:

trait Tr

It's being contained in a module cdl-common.

I want to detect all classes/objects extending it during compilation of the module cdl-impl dependign on cdl-common. For instance:

class Cls extends Tr

In Java, I could use annotation processor and annotate these classes with some annotation and then analyze AST.

Is it possible to do so in Scala with macro without annotating the classes?

Upvotes: 1

Views: 683

Answers (1)

oblivion
oblivion

Reputation: 6548

You can do this easily using ClassUtil .

For usage, you can refer the answer given here: Get all the classes that implments a trait in Scala using reflection

Upvotes: 1

Related Questions