Commit Graph

1089 Commits

Author SHA1 Message Date
Saleem Abdulrasool
deed57cefe Merge pull request #64721 from tristanlabelle/fix-lit-python-test-failure-backslash
Fix test failure on Windows due to path separators being treated as escapes
2023-03-31 11:29:27 -07:00
Doug Gregor
7c7459ac6b Merge pull request #64641 from DougGregor/macro-replacement-expansion 2023-03-29 20:47:30 -07:00
Doug Gregor
68b367b266 Disable macros-related tests harder 2023-03-29 16:32:32 -07:00
Doug Gregor
30f17940f9 Require the Swift swift parser for a few tests affected by macros 2023-03-29 16:32:32 -07:00
Doug Gregor
cfbdae586d [Macros] Add a test ensuring that we print expanded macro definitions
This should complete the implementation of expanded macro
definitions, rdar://104044325.
2023-03-29 16:32:32 -07:00
Allan Shortlidge
f4b79594a8 Tests: Fix and re-enable @_spi_available tests
The main issue was that the tests specified `-library-level=api` in
`swift-frontend` invocations instead of `-library-level api`. The former seems
to have no effect and therefore expected diagnostics were not being emitted.

Additional clean up:
- Make every test require `OS=macosx` for ease of local testing.
- Avoid unnecessarily specifying target arches (this makes tests slow).
- Add missing `FileCheck` invocation.
- Add some missing test coverage.

Resolves rdar://91325474
2023-03-29 14:45:22 -07:00
Tristan Labelle
8155f07ca6 Fix test failure on Windows due to path separators being treated as escapes 2023-03-29 12:03:43 -04:00
Dario Rexin
45b8cfd511 [ModuleInterface] Guard layout based prespecializations in swiftinter… (#64695)
* [ModuleInterface] Guard layout based prespecializations in swiftinterface files

rdar://107269447

To allow compilers that don't have this feature enabled to parse interface files that contain declarations that use layout based prespecializations, it has to be guarded.

* Incorporate feedback
2023-03-28 22:43:45 -07:00
Alexis Laferrière
d707dc4d81 Merge pull request #64516 from xymus/remark-transitive
[Serialization] Remark on transitive dependencies and loading requirement
2023-03-28 09:18:07 -07:00
Alexis Laferrière
bf2d2475f3 [Serialization] Remark on transitive dependencies 2023-03-27 10:04:03 -07:00
Becca Royal-Gordon
ab5d3ac42c [NFC] Verify ModuleInterface/objc_implementation
Switch the ModuleInterface/objc_implementation.swift test to using standard substitutions to properly emit its module interface, and make sure it also verifies.
2023-03-25 14:53:29 -07:00
Becca Royal-Gordon
e8c43bb168 Fix @objcImpl subclass init visibility computation
When writing an @objc subclass of an @objcImplementation class, implicit initializers in the subclass were treated as overriding the *implementation decl*, not the *interface decl*, of the initializer in the superclass. This caused Swift to incorrectly compute the visibility of the superclass initializer and omit an `override` keyword from the module interface when one would definitely be necessary.

Correct this oversight by looking up the interface decl matching the superclass implementation in `collectNonOveriddenSuperclassInits()`.
2023-03-25 14:53:29 -07:00
Becca Royal-Gordon
04a27b822c Omit @objcImpl from module interfaces
Module interfaces should not include the @objcImplementation attribute, member implementations that are redundant with the ObjC header, or anything that would be invalid in an ordinary extension (e.g. overridden initializers, stored Swift-only properties).
2023-03-25 14:53:29 -07:00
Kavon Farvardin
bf7091f046 ensure #if $MoveOnly evaluates to true
I enabled move-only types by default, but I didn't
realize that the `Feature::MoveOnly` needs to graduate
into a `LANGUAGE_FEATURE` so that `EvaluateIfConfigCondition`
will recognize `$MoveOnly` as being true.

fixes rdar://107050387
2023-03-24 08:48:26 -07:00
Allan Shortlidge
5da4e2df40 Sema: Allow unavailable decls to witness requirements in more conformances.
In https://github.com/apple/swift/pull/63898 conformance requirement
typechecking was relaxed to allow unavailable decls to witness conformance
requirements as long as the conforming nominal was also unavailable. However,
only nominals that were directly marked unavailable were accepted. Nominals
that are declared in unavailable scopes should also be allowed to have
unavailable wintesses.

Resolves rdar://107052715
2023-03-22 12:37:51 -07:00
swift-ci
fd0f148a07 Merge pull request #64518 from artemcm/NoExtraClangPCMSearchPaths
[Dependency Scanning] Do not add extra search paths to the Clang's explicit PCM prebuild commands
2023-03-22 11:51:46 -07:00
Nate Chandler
2d19632d88 [Test] Fully disabled test.
It's failing on more platforms than originally thought.

rdar://107052715
2023-03-22 10:26:27 -07:00
Artem Chikin
4ed874c276 [Dependency Scanning] Do not add extra search paths to the Clang's explicit PCM prebuild commands
Clang dependency scanner's output will be complete here w.r.t. the required search paths.

Resolves rdar://107018240
2023-03-22 09:36:17 -07:00
Konrad `ktoso` Malawski
11decb017f disable actor_availability on ios 2023-03-22 22:54:22 +09:00
Allan Shortlidge
620462ddf6 Sema: Don't diagnose declarations more available than unavailable container.
It turns out that we must allow declarations with `introduced:` availability
nested inside of other declarations that are `unavailable` in order to
influence weak linking. Stop diagnosing declarations as being more available
than their unavailable containers and revert some changes to availability
inference that were designed to avoid creating these nestings but caused
regressions for declarations marked `@_spi_available.`

Reverts parts of https://github.com/apple/swift/pull/64310,
https://github.com/apple/swift/pull/64015, and
https://github.com/apple/swift/pull/62900.
2023-03-21 13:55:05 -07:00
Alexis Laferrière
3e79583e4e Merge pull request #64404 from xymus/access-level-import-tests
[Sema] Reenable two access-level on imports tests
2023-03-16 12:56:33 -07:00
Kavon Farvardin
a8a44ebb17 Merge pull request #64106 from kavon/enable-moveonly-by-default
Enable moveonly / noncopyable types by default
2023-03-15 09:59:29 -07:00
Kavon Farvardin
2c7d9a5047 update tests given move-only types are enabled
the main things still left behind the experimental flag(s) are
- move-only classes (guarded by MoveOnlyClasses feature)
- noimplicitcopy
- the _borrow operator
2023-03-14 18:35:13 -07:00
Alexis Laferrière
f4d2d2a30f [Sema] Reenable access-level on imports tests 2023-03-14 09:35:24 -07:00
Allan Shortlidge
4058ad1421 AST: Improved inferred availability accuracy.
Previously, when creating availability attributes for synthesized declarations
we would identify some set of reference declarations that the synthesized
declaration should be as-available-as. The availability attributes of the
reference declarations would then be merged together to create the attributes
for the synthesized declaration. The problem with this approach is that the
reference declarations themselves may implicitly inherit availability from their
enclosing scopes, so the resulting merged attributes could be incomplete. The
fix is to walk though the enclosing scopes of the reference declarations,
merging the availability attributes found at each level.

Additionally, the merging algorithm that produces inferred availability
attributes failed to deal with conflicts between platform specific and platform
agnostic availability. Now the merging algorithm notices when platform agnostic
availability should take precedence and avoids generating conflicting platform
specific attributes.

Resolves rdar://106575142
2023-03-13 18:27:03 -07:00
Allan Shortlidge
b36b946e97 Sema: Only add implicit imports to module interface during resilience typechecking.
Previously, implicit imports were also being added to the module interface during override checking (without any diagnostic).

Additionally, correct the structure of the import which contained an extra, duplicated path component. It would be diagnosed as a scoped import and written into the interface like this:

```
import UIKit/*.UIKit*/
```

Resolves rdar://104935794
2023-03-13 11:37:59 -07:00
Allan Shortlidge
f6b1cc0134 Tests: Add a regression test for module interface printing of conditionally available property wrappers. 2023-03-12 18:02:49 -07:00
Doug Gregor
b412c6c884 [Macros] Treat FreestandingExpressionMacros as a suppressible feature
When the feature isn't available, use the older `@expression` syntax to
work around limitations of older compilers.
2023-03-09 20:33:30 -08:00
Kavon Farvardin
b78e2f58e7 Ensure all decls using move-only types are feature-guarded
rdar://106262652
2023-03-05 16:28:09 -08:00
Doug Gregor
6a9e9d6f24 Merge pull request #64116 from DougGregor/macro-escape-declared-names-printing 2023-03-05 07:42:19 -08:00
swift-ci
b15957631a Merge pull request #64059 from kavon/staging-bootstrap-with-copyable
Turn on the `Copyable` as an inferred generic constraint by default
2023-03-04 22:46:40 -08:00
Doug Gregor
1a4d6b6519 [Macros] Ensure that we escape macro declared names in printing.
Fixes an issue where we couldn't round-trip macro declared names
2023-03-04 22:41:09 -08:00
Kavon Farvardin
091d63a5c8 revise how the Copyable constraint is added
The _Copyable constraint was implemented as a marker protocol.
That protocol is part of the KnownProtocol's in the compiler.
When `ASTContext::getProtocol(KnownProtocolKind kind)` tries
to find the ProtocolDecl for Copyable, it will look in the
stdlib module (i.e., Swift module), which is where I initially
planned to put it.

That created problems initially when some regression tests
use `-parse-stdlib` failed to do that protocol lookup, which is
essential for adding the constraint (given the current implementation).

That led to believe we need to pull Copyable out of the stdlib, but that's
wrong. In fact, when building the Swift module itself, we do `-parse-stdlib`
but we also include `-module-name Swift`. This causes the _Copyable protocol
defined in the Stdlib to be correctly discovered while building the stdlib
itself (see the test case in this commit). So, the only downside of
having the Copyable protocol in the Stdlib is that `-parse-stdlib` tests
in the compiler can't use move-only types correctly, as they'll be
allowed in generic contexts. No real program would build like this.

Until I have time to do a further refactoring, this is an acceptable trade-off.

fixes rdar://104898230
2023-03-04 11:42:09 -08:00
Meghana Gupta
b262311f24 Disable access level import tests 2023-03-03 17:33:30 -08:00
swift-ci
d0f88433da Merge pull request #63822 from kavon/resilient-noncopyable
Support resilient properties of move-only type
2023-03-03 01:24:37 -08:00
Sophia Poirier
a9e5075a94 Merge pull request #64039 from sophiapoirier/pack-type-syntax-each
[Variadic Generics] type parameter pack syntax change: T... -> each T
2023-03-02 19:17:19 -08:00
Doug Gregor
4d3f1fa67b Merge pull request #64044 from DougGregor/macros-feature-flags
Clean up feature flags for macros.
2023-03-02 19:03:32 -08:00
Allan Shortlidge
5d680532c7 Merge pull request #64015 from tshortli/unavailable-actor
AST: Emit correct synthesized availability attributes for `unownedExecutor` property
2023-03-02 17:48:19 -08:00
Kavon Farvardin
410673c51f add a bunch of hopeful tests 2023-03-02 15:14:24 -08:00
Sophia Poirier
70cffb06f3 [Variadic Generics] type parameter pack syntax change: T... -> each T 2023-03-02 14:42:28 -08:00
Doug Gregor
f88d2c638f Clean up feature flags for macros.
Enable expression macros by default, and add separate feature flags for
attached and freestanding macros.
2023-03-02 14:34:59 -08:00
Alexis Laferrière
fbac54546d Merge pull request #64014 from xymus/access-level-import
[Sema] Diagnose exportability of decls limited by a non-public import
2023-03-02 10:11:15 -08:00
Allan Shortlidge
9c76e0d1bf AST: Emit correct synthesized availability attributes for unownedExecutor property.
When synthesizing a declaration and inferring its availability, the synthesized attribute should factor in unavailability of the parent declarations. This recently regressed with https://github.com/apple/swift/pull/63361. However, the previous implementation did not produce correct results, either, because the logic for merging availability attributes produced a non-sensical result when both `unavailable` and `introduced:` availability attributes were merged. For example, this was the result for the synthesized `unownedExecutor` property of an actor when the actor was marked unavailable:

```
@available(macOS, unavailable)
actor A {
  // Incorrectly synthesized availability for `unownedExecutor` which results from merging
  // the unavailability of the parent and the availability of the UnownedSerialExecutor type.
  @available(macOS, unavailable, introduced: macOS 10.15)
  @_semantics("defaultActor") nonisolated final var unownedExecutor: UnownedSerialExecutor { get }
}
```

This is fixed by omitting all version components from the synthesized attribute when the overall attribute kind is "unavailable".

Additionally, I discovered that the `concurrency_availability.swift` test case was no longer testing what it intended to test. The conformances to `Actor` for each `actor` in the test were no longer being synthesized and therefore `unownedExecutor` was not being synthesized. That was fixed by importing the `_Concurrency` module directly, which seems to be necessary because of the `-parse-stdlib` flag in the test.

Resolves rdar://106055566
2023-03-02 10:09:30 -08:00
Allan Shortlidge
e101b225ef NFC: Remove unnecessary -disable-availability-checking flags from test. 2023-03-02 10:09:29 -08:00
Alexis Laferrière
0d82ba3059 [ModuleInterface] Fixup tests about access-level on imports and dependencies 2023-03-01 14:41:11 -08:00
Alexis Laferrière
87f8650e41 Merge pull request #63974 from xymus/access-level-import-swiftinterface
[ModuleInterface] Hide non-public imports from a resilient module
2023-03-01 14:38:01 -08:00
Saleem Abdulrasool
2626f23bf5 Merge pull request #63880 from compnerd/development-vfs
stdlib: remove VS injection for Swift development
2023-03-01 09:09:55 -08:00
Alexis Laferrière
94aeb8c0ff [ModuleInterface] Hide non-public imports from a resilient module
When using access level on imports, consider non-public imports to be
implementation details not exposed to clients. As such, a client loading
a library doesn't need to load non-public transitive dependencies.

This behave like `@_implementationOnly imports` at a module-wide level,
but it is restricted to resilient modules only. An import with any
access-level in a non-resilient module remains visible to transitive
clients.
2023-03-01 00:11:59 -08:00
Artem Chikin
3ea5087e2f Add Swift compilation flags to enable Clang's validate-per-build-session module behavior
Add '-validate-clang-modules-once' and '-clang-build-session-file' corresponding to Clang's '-fmodules-validate-once-per-build-session' and '-fbuild-session-file='. Ensure they are propagated to module interface build sub-invocations.

We require these to be first-class Swift options in order to ensure they are propagated to both: ClangImporter and implicit interface build compiler sub-invocations.

Compiler portion of rdar://105982120
2023-02-28 13:19:05 -08:00
Saleem Abdulrasool
4075d706a2 stdlib: remove the dependency on the injected modules
Inject the necessary module maps and apinotes via the VFS.  This cleans
up the developer build in preparation for a secondary change to remove
this need for deployed scenarios as well.  Injecting the content via the
VFS will enable us restore the ability to work with a pristine
installation of Visual Studio, dropping the custom action for the Swift
installer, and open the pathway to per-user installation of Swift.

Thanks to @bnbarham for the help and discussion in resolving the test
issues.
2023-02-28 09:40:51 -08:00