Commit Graph

18 Commits

Author SHA1 Message Date
Allan Shortlidge
2730c19891 Macros: Stop explicitly enabling accepted ExtensionMacros feature in tests.
NFC.
2023-12-10 10:10:15 -08:00
Doug Gregor
5d6746d974 Improve checking of macro-generated accessors against documented names
The checking of the accessors generated by a macro against the
documented set of accessors for the macro is slightly too strict and
produces misleading error messages. Make the check slightly looser in
the case where an observer-producing macro (such as
`@ObservationIgnored`) is applied to a computed property. Here, we
would diagnose that the observer did not in fact produce any
observers, even though it couldn't have: computed properties don't get
observers. Remove the diagnostic in this case.

While here, add some tests and improve the wording of diagnostics a
bit.

Fixes rdar://113710199.
2023-08-17 16:59:42 -07:00
Holly Borla
c867c7c917 [Macros] Allow extension macros to specify conformances in the attached
attribute.
2023-06-28 00:42:23 -07:00
Ben Barham
1141e59b31 [Test] Update expected macro error
https://github.com/apple/swift/pull/66497 and
https://github.com/apple/swift/pull/66482 succeeded separately, then
merged. But after 66497 the error now includes parentheses.

Resolves rdar://110655182.
2023-06-12 11:34:20 -07:00
Doug Gregor
a72fb83034 Requestify AbstractStorageDecl::hasStorage().
The `hasStorage()` computation is used in many places to determine the
signatures of other declarations. It currently needs to expand accessor
macros, which causes a number of cyclic references. Provide a
simplified request to determine `hasStorage` without expanding or
resolving macros, breaking a common pattern of cycles when using
macros.

Fixes rdar://109668383.
2023-06-10 08:28:06 -07:00
Doug Gregor
ae4a5ded8f [Macros] Improve parsing, representation, and serialization of role attributes
Parse compound and special names in the macro role attributes
(`@freestanding` and `@attached`). This allows both compound names and
initializers, e.g., `init(coding:)`.

Fixes rdar://107967344.
2023-04-21 11:36:06 -07:00
Ben Barham
e5a28caa9a [Test] Fix swift_swift_parser feature and use in tests
The macro tests were all using "REQUIRES: OS=macosx" as a proxy for
"have the Swift Swift parser". There was an existing feature for this,
but it was just checking whether the path was passed through. Fix that
to use the same variable as in CMake.

Also remove all extraneous `-I` and `-L` to the host libs in the target
invocations.
2023-04-03 09:25:03 -07:00
Rintaro Ishizaki
1d2fd4223f [Test] Add %host_triple and %host_sdkroot substitutions
Macro tests need to build host libraries/tools. We can't use %target-*
substitutions for that.

rdar://107398734
2023-03-31 07:41:41 -07:00
Doug Gregor
38230b79f9 [Macros] Add (de-)serialization for expanded macro definitions 2023-03-29 16:32:32 -07:00
Doug Gregor
9d9f8326c8 [Macros] Allow macro parameters to have default arguments.
SE-0382 allows macro parameters to have default arguments. Enable these
default arguments, with the normal type checking rules. One
significant quirk to this implementation is that the actual default
argument values don't make it to the macro implementation. This is a
previously-unconsidered design problem we'll need to address.

Tracked by rdar://104043987.
2023-03-26 22:13:37 -07:00
Richard Wei
ecc33865b9 [Macros] Fix MacroDecl serialization crash with custom parameter attributes
Type-check `MacroDecl`'s parameter list so that custom attributes on parameters will have a type. Fixes a serialization crash.
2023-02-23 05:00:28 +08:00
Holly Borla
ae1f8248b3 [Serialization] Don't serialize macro custom attributes. 2023-01-17 17:24:52 -08:00
Doug Gregor
43cadcad3a [Macros] Serialization and printing for @attached. 2023-01-14 21:48:43 -08:00
Doug Gregor
1b14b5d356 Fixup some test cases 2023-01-02 21:22:05 -08:00
Doug Gregor
3be6344619 Eliminate dependencies on _SwiftSyntaxMacros having actual macros in it 2022-12-14 16:13:48 -08:00
Evan Wilde
5f9ac391be Requires-asserts macro tests
Macros are an experimental feature, as such are not available on
non-asserts compilers.

Adding requires asserts to remaining experimental macro tests.
 - ModuleInterface/macros.swift
 - Serialization/macros.swift
2022-12-01 11:18:10 -08:00
Doug Gregor
e6ed154407 Macro tests only run in CI for macOS at the moment 2022-11-28 18:33:11 -08:00
Doug Gregor
4ce0834c51 [Macros] Serialization support for macro declarations. 2022-11-28 18:33:09 -08:00