0

I want to use a class generated with TypeSpec.classBuilder as a property in another class that I am generating. But for this I need to get a TypeName and I cannot find a way to access it. Only from the superclass. Anyone knows a way to do this?

ligi
  • 39,001
  • 44
  • 144
  • 244

1 Answers1

4

You should be perfectly fine with using ClassName there. And the easiest way of obtaining the ClassName is to pass the package and the name of the generated type:

ClassName("your.package.here", "NameOfType")

You can see here how I'm specifying a receiver of an extension function ("similar" use-case):

enter image description here

Bartek Lipinski
  • 30,698
  • 10
  • 94
  • 132
  • 1
    Thanks! This worked - upvoted the answer. Will accept later unless a more elegant solution comes around. It works but does not really feel DRY.. – ligi Nov 17 '19 at 09:58
  • @ligi can you provide a part of your `class`-generating code? Maybe there's a "DRYier" solution – Bartek Lipinski Nov 18 '19 at 10:38