Commit Graph

1088 Commits

Author SHA1 Message Date
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
Pavel Yaskevich
233d279a5c [AST] Support @preconcurrency attribute on test/extension inheritance entries 2024-01-16 10:30:58 -08:00
Allan Shortlidge
ba1f50fddb [c-interop] Make Extern a suppressible language feature.
Fixes building the standard library's .swiftinterface with older Swift
compilers.
2024-01-11 13:54:24 -08:00
Kavon Farvardin
64d43f9638 [NCGenerics] handle ReferenceStorageType queries 2024-01-10 19:37:21 -08:00
Kavon Farvardin
a2defd5367 [NCGenerics] fix AnyObject and inverses
resolves rdar://120512544
2024-01-10 19:37:21 -08:00
Kavon Farvardin
af7ff43d0d [NCGenerics] printing class-constrained generics
In cases where the generic parameter is class-constrained,
`GenericSignature::requiresProtocol` will not contain `Copyable` or
`Escapable` because GenericSignature minimization will recognize that
the class already requires them.

Thus, because classes always require those protocols, we can
simply ask if the generic parameter is required to be a class to
determine if it had any inverses.
2024-01-10 19:37:21 -08:00
Kavon Farvardin
b6b27eb3b5 [NCGenerics] add coverage for any Error 2024-01-10 19:37:21 -08:00
Doug Gregor
baaa8f3e5b Merge pull request #70677 from DougGregor/se-0413-typed-throws
Enable SE-0413 "Typed Throws" by default
2024-01-04 16:11:26 -08:00
Alexis Laferrière
39aa516f0d Merge pull request #70701 from xymus/no-verify-test
ModuleInterface: enable test for the no-verify flag in swiftinterfaces
2024-01-04 15:00:10 -08:00
Alexis Laferrière
e32c05da9e Merge pull request #70700 from xymus/fix-submodule-import-warnings
Sema: Don't report public imports of submodules as being unused in API
2024-01-04 14:59:55 -08:00
Allan Shortlidge
548df6917a Merge pull request #70718 from tshortli/module-interface-test-submodule-types
ModuleInterface: Test printing of qualified types from submodules
2024-01-04 14:00:39 -08:00
Alexis Laferrière
ab769e57c5 [Tests] Update test showing a superfluous warning that was just fixed 2024-01-04 10:47:06 -08:00
Allan Shortlidge
3087454b05 ModuleInterface: Test printing of qualified types from submodules. 2024-01-04 10:39:39 -08:00
Doug Gregor
b7fd43949a Remove the TypedThrows experimental feature from the remaining tests 2024-01-03 22:08:56 -08:00
Allan Shortlidge
6c1fe8137a Sema: Allow some references to declarations that are unavailable-in-Swift.
Swift generates implicit constructors for inherited designated initializers in
case some implicit initialization (such as running property initializer
expressions) needs to run after calling the initializer on the superclass.
These implicit initializers are printed in .swiftinterfaces and previously they
could cause the interface to fail to typecheck when one of the parameters is
declared to be unavailable-in-Swift. These initializers need to be generated
because they may be called from Objective-C where the unavailable-in-Swift
designation is irrelevant. To account for this possibility, relax availability
checking to allow this narrow exception only in .swiftinterfaces.

Another possible but more complicated solution would be to print the
initializers with an attribute that indicates that the initializer is inherited
and implicit. This would allow the typechecking exception to be more precise
but seems unnecessarily complicated given that the exception is only needed in
.swiftinterfaces, which are already compiler generated.

Resolves rdar://77221357
2024-01-03 19:36:16 -08:00
Alexis Laferrière
71fcd82685 ModuleInterface: enable test for the no-verify flag in swiftinterfaces 2024-01-03 15:33:33 -08:00
Alexis Laferrière
e431716e93 Merge pull request #70678 from xymus/write-no-verify
ModuleInterface: write down the -no-verify-emitted-module-interface flag in swiftinterfaces
2024-01-03 09:08:56 -08:00
Alexis Laferrière
1533894fed ModuleInterface: write down the -no-verify flag in the swiftinterface
The flag -no-verify-emitted-module-interface tells the driver to skip
verifying the swiftinterfaces emitted by the compiler. It used to be
passed only to the driver.

Let's pass it down to the frontend as well and write it in the
swiftinterfaces. This will help understand them from the reader side.
2024-01-02 16:40:19 -08:00
Allan Shortlidge
61111ed4fe AST: Fix macCatalyst availability for synthesized declarations.
The macCatalyst platform availability of a declaration may be inferred from the
iOS platform availability of that declaration in the absence of an explicit
macCatalyst availability attribute. This means that when inheriting macCatalyst
platform availability, the explict iOS availability of an inner ancestor should
take precedence over explicit macCatalyst availability of an outer ancestor.
The algorithm that computes inferred availability attributes for synthesized
declarations was treating macCatalyst and iOS as independent platforms, though,
sometimes yielding inapproparite macCatalyst availability.

Resolves rdar://107766644
2023-12-18 23:49:26 -08:00
Andrew Trick
979334e723 Merge pull request #70459 from atrick/rename-nonescapable
Rename NonesapableTypes feature
2023-12-14 16:00:46 -08:00
Andrew Trick
ace9937e95 Rename NonesapableTypes feature
Follow the feature flag convention for capitalization and be
consistent with the related NoncopyableGenerics feature.

This is a new feature that no wild Swift code has used it yet:

commit e99ce1cc5d
Author: Kavon Farvardin <kfarvardin@apple.com>
Date:   Tue Dec 5 23:25:09 2023

    [NCGenerics] add `~Escapable`

    Basic implementation of `~Escapable` in the type system.
2023-12-14 11:32:03 -08:00
Kavon Farvardin
040e95cd7d [NCGenerics] extra coverage for interface emission 2023-12-14 08:45:27 -08:00
Kavon Farvardin
5988608c89 Merge pull request #70180 from kavon/noncopyable-serialization
[NCGenerics] Serialization for noncopyable generic types.
2023-12-13 00:36:53 -08:00
Konrad `ktoso` Malawski
55c932c568 [Distributed] Bring back module interface test for DA (#70199) 2023-12-13 10:53:42 +09:00
Kavon Farvardin
bd1330715c [NCGenerics] only print ~Copyable in interface
We can't simply emit the desugared, expanded version of the requirements
because there's no way to pretty-print the type `some ~Copyable` when
the `~Copyable`'s get replaced with the absence of `Copyable`. We'd be
left with just `some _` or need to invent a new top type so we can write
`some Top`. Thus, it's best to simply reverse the expansion of default
requirements when emitting a swiftinterface file.
2023-12-12 16:40:26 -08:00
Kavon Farvardin
ffc06f9d31 [NCGenerics] add tests for modules/interface files 2023-12-12 16:40:26 -08:00
Ian Anderson
35eb5cb7f4 Merge pull request #69707 from ian-twilightcoder/builtin-flag
[ClangImporter] Swift needs to pass `-Xclang -fbuiltin-headers-in-system-modules` for its module maps that group cstd headers
2023-12-12 11:35:17 -08:00
Allan Shortlidge
2730c19891 Macros: Stop explicitly enabling accepted ExtensionMacros feature in tests.
NFC.
2023-12-10 10:10:15 -08:00
Ian Anderson
94e860e795 [ClangImporter] Swift needs to pass -Xclang -fbuiltin-headers-in-system-modules for its module maps that group cstd headers
Swift has some module maps it overlays on Linux and Windows that groups all of the C standard library headers into a single module. This doesn’t allow clang and C++ headers to layer properly with the OS/SDK modules. clang will set -fbuiltin-headers-in-system-modules as necessary for Apple SDKs, but Swift will need to pass that flag itself when required by its module maps.
2023-12-08 22:33:12 -08:00