Thank you all so much for all your help over the p...
# compiler
c
Thank you all so much for all your help over the past few weeks! With your assistance, I've just finished work on my first compiler plugin: Overloadable Setters in Kotlin! It wouldn't have been possible without you guys. The general idea is to let you define ways to set a property with multiple types of input, making builders a lot cleaner:
Copy code
buildThing {
  // ThingBuilder#defaultValue: () -> String
  defaultValue = "literal string"
  defaultValue = 0
  defaultValue = { someExpensiveComputation() }
}
You can check it out here: https://github.com/cbrandt77/Kotlin-OverloadableSetters I'm still working on publishing it and getting it on the plugin portal, but it's fully kitted out with diagnostics and should work as-is. I'll be implementing more language features in the future, so keep an eye out! I've got a list that's like two pages long, lol
👀 2
j
how does this work in a library? if my library uses your plugin, will my consumers be able to use the setters without needing your plugin; or do i need to instruct consumers to also add the plugin?
c
Yes, the consumers will also need to use the plugin to have access to the setter syntax, just like with Gradle and the
kotlin-assignment-plugin
it uses. But other than adding the plugin to Gradle, it'll work out of the box. If they don't add it, they'll still be able to invoke the setter methods as normal.