stackotter / swift-macro-toolkit

A powerful toolkit for creating concise and expressive Swift macros
Apache License 2.0
246 stars 15 forks source link

Can I get the real type of Typealias #12

Closed Mx-Iris closed 10 months ago

Mx-Iris commented 10 months ago

I'm using AddAsyncMacro from the example, and it seems to only get the direct function type, if I use Optional or Typealias I get errors

iShot_2024-01-29_21 38 02
stackotter commented 10 months ago

Hey, thanks for checking out the toolkit!

Unfortunately macros cannot know what a typealias expands to, so that case could not be handled without passing the macro extra information (as in making the macro take an optional argument where the dev can specify the underlying type of the completion handler).

However, optional completion handlers (without typealiases) could definitely be supported! (because all of the required type information is present in the syntax). The example macros aren’t very comprehensive because they’re only intended to demonstrate usage of the toolkit, but I’d happily accept a PR.

stackotter commented 10 months ago

I think my previous comment should answer your question, but feel free to reopen the issue if you have any related concerns