Commit Graph

1116 Commits

Author SHA1 Message Date
Doug Gregor
0652bb7abe Always infer AsyncSequence.Failure from AsyncIteratorProtocol.Failure
The newly-introduced associated type `AsyncSequence.Failure` must
always be equivalent to the `Failure` type of the
`AsyncIteratorProtocol`. If the `AsyncSequence` type itself defines a
nested `Failure` type (say, for another purpose), associated type inference
would pick it and reject the `AsyncSequence`, causing a source compatibility
problem.

Work around the issue in two ways. First, always infer the type
witness for `AsyncSequence.Failure` from the type witness for
`AsyncIteratorProtocol.Failure`, so they can't be out of sync. This
means that we'll never even consider a nested `Failure` type in the
`AsyncSequence`-conforming type. This hack only applies prior to Swift 6.

Second, when we have inferred a `Failure` type and there is already
something else called `Failure` within that same nominal type, don't
print the inferred typelias into a module interface because it will
cause a conflict.

Fixes rdar://123543633.
2024-02-28 13:49:50 -08:00
Doug Gregor
ec73cf379d Fix test for tvOS, heh 2024-02-28 08:37:44 -08:00
Doug Gregor
ef7185a4a2 Don't infer empty availability attributes
Due to the mapping of iOS platform availability to tvOS platform availability,
we were ending up inferring an availability attribute `@available(tvOS)` for
an associated type, which does not parse properly. Suppress the creation
of inferred availability attributes when they convey no information
(e.g., because they have no introduced/deprecated/obsoleted/etc. in them).

Fixes rdar://123545422.
2024-02-27 11:28:31 -08:00
Alexis Laferrière
4945cfcad1 ModuleInterface: Setup logic to load swiftinterfaces by default
The Swift compiler can load either the binary swiftmodule file or the
textual swiftinterface file when importing a module. It currently picks
the swiftmodule over the swiftinterface, unless there’s an exception. We
should flip the default for distributed modules, prefer the
swiftinterface over the swiftmodule unless there’s an exception.

rdar://122955640
2024-02-27 10:26:31 -08:00
Doug Gregor
0c9c734f7e Merge pull request #71722 from DougGregor/diagnostic-style-swift-default 2024-02-24 14:42:38 -10:00
Meghana Gupta
0a2ec68270 Merge pull request #71856 from meg-gupta/fixastprinting
Fix ASTPrinting of lifetime dependence
2024-02-23 18:21:29 -08:00
Ellie Shin
efbe393fbe Merge pull request #71778 from apple/es-pkgint
Re-enable package interface test.
2024-02-23 16:41:04 -08:00
Meghana Gupta
a79facf02b Fix ASTPrinting of lifetime dependence
This fixes the errors while compiling functions with lifetime dependence
in the textual interface files.

Also fixes rdar://122573346
2024-02-23 15:35:37 -08:00
Meghana Gupta
ca73cba046 Enable lifetime dependence inference when NonescapableTypes is on 2024-02-23 01:49:47 -08:00
Kavon Farvardin
c50cd2e48c Merge pull request #71794 from kavon/ncgenerics-test-fixes-kavon-v19
NCGenerics: conformances can depend on Copyable
2024-02-22 12:40:42 -08:00
Mishal Shah
cb96ec2893 Merge remote-tracking branch 'origin/main' into bump-swift-version-to-6 2024-02-22 09:44:44 -08:00
Kavon Farvardin
19933d0a00 NFC: move Swiftskell to shared test/Inputs directory 2024-02-21 22:38:23 -08:00
Allan Shortlidge
1b7d8b6eda ModuleInterface: Improve TypedThrows feature guards.
Functions that use typed throws _anywhere_ in their signature (including in
closure types) need to be surrounded with `if $TypedThrows` guards in
swiftinterfaces.
2024-02-21 17:59:49 -08:00
Ellie Shin
edc5aba318 Re-enable package interface test.
Previously package decls at the defition sites were non-resilient.
Now they are resilient by default and are printed in interface as so.

Ref: rdar://118461385
2024-02-21 16:28:19 -08:00
Mishal Shah
b8cd763b21 Merge branch 'main' into bump-swift-version-to-6 2024-02-21 12:40:54 -08:00
Mishal Shah
b488702cc9 Merge remote-tracking branch 'origin/main' into bump-swift-version-to-6 2024-02-20 21:04:47 -08:00
Kavon Farvardin
f296d8e158 NCGenerics: mass XFAIL tests
It's easier to get a handle on regressions while working through
failures if the tests that are known to not pass are XFAIL'd for
NoncopyableGenerics.
2024-02-20 18:26:05 -05:00
Holly Borla
f8094061ad Merge pull request #71727 from hborla/double-preconcurrency
[Concurrency] Don't add redundant implicit `@preconcurrency` attributes.
2024-02-20 07:27:39 -08:00
Kavon Farvardin
722282ee4f ASTPrinter: fix nested inverse printing
Nested types with inverse requirements on generic parameters would
sometimes print incorrectly. We only print the inverses on outer generic
parameters for extensions.

fixes rdar://123281976
2024-02-19 23:50:15 -08:00
Mishal Shah
af112c1591 Update the Swift version to 6.0 from 5.11 2024-02-19 17:47:16 -08:00
Holly Borla
b609d804da [Concurrency] Don't add redundant implicit @preconcurrency attributes to
declarations with an explicit annotation.
2024-02-19 11:09:36 -08:00
Doug Gregor
e3c2162be2 Cope with change to default diagnostic style 2024-02-19 02:48:36 -10:00
John McCall
668297e977 Don't print conformance attributes redundantly in -preserve-types-as-written.
Since we no longer remove these attributes from the AttributedTypeRepr,
if we print based on the TypeRepr, we'll print them twice.  The best
solution is to only print the attributes based on the inheritance clause
if we're not printing the type based on the TypeRepr.

Fixes rdar://122965951.
2024-02-16 15:12:24 -05:00
Kavon Farvardin
08b71e0136 NCGenerics: rebuild stdlib from its interface
When a NoncopyableGenericsMismatch happens between the compiler and
stdlib, allow the compiler to rebuild the stdlib from its interface
instead of exiting with an error.
2024-02-15 18:08:54 -08:00
Doug Gregor
3ecbfcf885 Merge pull request #71637 from apple/ApolloZhu/SE-0422/accepted 2024-02-15 03:57:05 -08:00
Doug Gregor
63c8fe3e4d Clean up formatting in test cases 2024-02-14 21:53:54 -08:00
Doug Gregor
bae1026b77 Stop emitting conditions for Swift 5.5-era features into textual interfaces
The "#if compiler(>=5.3) && $AsyncAwait" checks were necessary for
staging in concurrency in Swift 5.5. At this point, it's safe to assume
that any compiler that tries to read a generated Swift interface file will
support concurrency, so we can stop emitting these guards.
2024-02-14 21:51:55 -08:00
Apollo Zhu
9ccfb574fd Enable SE-0422 Expression macro as caller-side default argument 2024-02-14 19:22:35 -08:00
Slava Pestov
ffd651c7b4 Sema: Try not to let protocol type aliases leak into inferred type witnesses
They don't always round-trip through a module interface, because of
request cycles in type resolution.

Fixes rdar://problem/122957148.
2024-02-14 15:43:29 -05:00
Holly Borla
bf8f9acfbb Merge pull request #71581 from hborla/swift-6-noasserts 2024-02-13 15:13:26 -08:00
Holly Borla
f1cd9cb422 [Test] Remove REQUIRES: asserts from tests that use -swift-version 6. 2024-02-13 07:13:35 -08:00
Alexis Laferrière
2875980d01 Merge pull request #71563 from xymus/sdk-version-in-hash
Serialization: Apply the SDK build version as part of the swiftmodule cache hash
2024-02-12 16:45:55 -08:00
Alexis Laferrière
86ea594f21 Serialization: apply the SDK build version as part of the cache hash
The SDK build version is a decent heuristic for expected changes in the
SDK. Any change in SDK, to clang headers in particular, can break
references from cached swiftmodules.

Track the SDK build version as part of the swiftmodule cache hash. This
will ensure we rebuild from swiftinterfaces on SDK updates.

rdar://122655978
2024-02-12 12:35:03 -08:00
Alexis Laferrière
517d185688 Merge pull request #71483 from xymus/superfluously-public-import-fixes
Sema: Don't warn on @_exported public imports that are not used in API
2024-02-09 13:05:35 -08:00
Doug Gregor
0ab7f56001 Merge pull request #71496 from DougGregor/infer-assoc-type-witness-availability 2024-02-08 23:59:50 -08:00
Robert Widmann
ea49d13a12 Availability 2024-02-08 21:38:09 -07:00
Doug Gregor
6a43a680d1 Infer availability for typealiases for inferred type witness
Now that associated types can have availability, make sure that we
infer availability attributes for any inferred type witnesses of said
associated types based on both the enclosing context and the associated
type itself. This eliminates failures in the emitted Swift interfaces.

Fixes rdar://122596219.
2024-02-08 19:14:57 -08:00
Alexis Laferrière
eca1cf99af Sema: Don't warn on @_export public imports not used in API
An `@_export public import` is meaningful on it's own as it declares a
relationship between two modules and how clients see them. As such that
import doesn't have to be referenced from API to be appropriate. Let's
not warn on any public import with an `@_export` attribute.

rdar://122032960
2024-02-08 17:29:25 -08:00
Robert Widmann
6da33336d3 Tests 2024-02-08 14:29:05 -07:00
Kavon Farvardin
f0b4f4a865 NCGenerics: omit inverses on invertible protocols
The interface files were still printing inverses on the invertible
protocols, when that's not required. Doing so yielded warnings during
the build because `~Escapable` isn't yet ready for appearing in the
stdlib.
2024-02-06 08:15:26 -08:00
Pavel Yaskevich
db7959668e [Frontend] NFC: Rename PreconcurrencyConformances to DynamicActorIsolation 2024-02-01 13:28:25 -08:00
Slava Pestov
80205ecf9c Merge pull request #71241 from slavapestov/ncgenerics-fixes
Non-copyable generics fixes
2024-02-01 07:18:29 -05:00
Slava Pestov
9e247469a1 Sema: Implement new behavior of extensions with non-copyable generics
We want extensions to introduce default Copyable/Escapable just like
other generic contexts, so that once Optional adopts ~Copyable,
an `extension Optional` actually adds `Wrapped: Copyable` by default.
2024-01-31 21:56:45 -05:00
Slava Pestov
23b1690f6b ASTPrinter: Refactor printing of RequirementSignatures 2024-01-31 21:55:52 -05:00
Kavon Farvardin
5f977ca763 NCGenerics: force module mismatches 2024-01-31 14:00:08 -08:00
John McCall
41cdfb04ad Introduce a proper TypeAttribute class hierarchy.
The old TypeAttributes reprsentation wasn't too bad for a small number of
simple attributes.  Unfortunately, the number of attributes has grown over
the years by quite a bit, which makes TypeAttributes fairly bulky even at
just a single SourceLoc per attribute.  The bigger problem is that we want
to carry more information than that on some of these attributes, which is
all super ad hoc and awkward.  And given that we want to do some things
for each attribute we see, like diagnosing unapplied attributes, the linear
data structure does require a fair amount of extra work.

I switched around the checking logic quite a bit in order to try to fit in
with the new representation better.  The most significant change here is the
change to how we handle implicit noescape, where now we're passing the
escaping attribute's presence down in the context instead of resetting the
context anytime we see any attributes at all.  This should be cleaner overall.

The source range changes around some of the @escaping checking is really a
sort of bugfix --- the existing code was really jumping from the @ sign
all the way past the autoclosure keyword in a way that I'm not sure always
works and is definitely a little unintentional-feeling.

I tried to make the parser logic more consistent around recognizing these
parameter specifiers; it seems better now, at least.
2024-01-28 22:30:26 -05:00
Holly Borla
d6f27a8a80 [Concurrency] Always print @preconcurrency instead of (unsafe) in
swiftinterfaces.
2024-01-21 19:38:35 -08:00
Pavel Yaskevich
c3a0822260 [Tests] NFC: Disable availability checking in @preconcurrency conformances tests 2024-01-16 16:21:06 -08:00
Pavel Yaskevich
451308422b [Sema] Suppress actor isolation checking for @preconcurrency conformances
Suppress warnings/errors when actor isolated synchroneous witness
is matched against `@preconcurrency` conformance requirement.

Witness thunk assumes isolation of the witness but instead of a
hop to its executor it would emit a runtime check to make sure
that its always called from the expected context.
2024-01-16 11:51:49 -08:00
Pavel Yaskevich
4943e146bd [Frontend] Add experimental flag for @preconcurrency conformances feature 2024-01-16 10:31:01 -08:00