swift
3b536c63 - [Macros] Cope with local types and opaque result types in macros and expansions

Commit
2 years ago
[Macros] Cope with local types and opaque result types in macros and expansions Address a few related issues that affect local types and opaque result types within macros: * Don't add local types or opaque types encountered while parsing the arguments of a freestanding macro to the global list. When we do add them, make sure we're adding them to the outermost source file so they'll get seen later. This avoids trying to generate code for these types, because they aren't supposed to be part of the program. Note that a similar problem remains for arguments to attached macros, which will need to be addressed with a more significant refactoring. * When determining whether opaque types should be substituted within a resilience domain, check the outermost source files rather than the exact source file, otherwise we will end up with a mismatch in argument-passing conventions. * When delaying the type checking of functions that occur as part of a macro expansion, make sure we record them in the outermost Swift source file. Otherwise, we won't come back to them. There is a common theme here of using AST state on the source file in a manner that isn't ideal, and starts to break down with macros. In these cases, we're relying on side effects from earlier phases (parsing and type checking) to inform later phases, rather than properly expressing the dependencies through requests. Fixes rdar://110674997&110713264.
Author
Committer
Parents
Loading