Thread overview
Check attribute against value
Apr 03, 2021
frame
Apr 03, 2021
rikki cattermole
Apr 03, 2021
frame
April 03, 2021

I have an attribute scope:

@PublicApi {
  // ...
}

Querying with hasUDA! works as expected.
Later, I added a property to PublicApi:

struct PublicApi {
   bool exposeDetails;
}

And want to ask the compiler via getUDAs! about the boolean but this fails with:
Error: type PublicApi has no value

because I need to rewrite it to

@PublicApi() {
  // ...
}

... which works again.
But how do I check against such cases? And why does a struct not have a value here?

April 03, 2021
"Whether the attributes are values or types is up to the user, and whether later attributes accumulate or override earlier ones is also up to how the user interprets them."

This doesn't explain it well, but you were adding types as attributes on to those symbols. Not struct instances.
April 03, 2021
On Saturday, 3 April 2021 at 04:03:14 UTC, rikki cattermole wrote:

> This doesn't explain it well, but you were adding types as attributes on to those symbols. Not struct instances.

omg - that's dumb - I was thinking the compiler whould be aware of that.

So, I need to check for isType! first, thanks.