Commit Graph

17644 Commits

Author SHA1 Message Date
Doug Gregor
e7a5887fec Merge pull request #68057 from DougGregor/fileprivate-extension-macros 2023-08-22 09:13:02 -07:00
Doug Gregor
323561b157 [Macros] Use outermost source file for establishing (file)private access scope
Fixes rdar://114048069.
2023-08-21 22:01:19 -07:00
Slava Pestov
595a7a530b RequirementMachine: Fix potential 'pollution' from installing an invalid requirement machine
If the substitution terms of a concrete type symbol contain unresolved
name symbols, we have an invalid requirement that is dropped from the
minimized signature. In this case, the rewrite system used for minimization
cannot be installed as the official rewrite system for this generic
signature, because building a rewrite system from the signature will
produce a different result.

This might be the cause of the crash in rdar://114111159.
2023-08-21 23:36:37 -04:00
Artem Chikin
871118e827 Merge pull request #67928 from artemcm/DoNotCountOverlayDepsAsDirect
[Dependency Scanning] Remove Swift Overlay dependencies from the set of direct dependencies
2023-08-21 11:52:02 -07:00
Hamish Knight
7982e4bd7e [AST] Handle null in printDeclDescription
Sink down the null Decl printing into
`printDeclDescription` such that all callers
benefit from it.

This is an attempt at fixing at least the secondary
crash in rdar://113491294, it does not address the
underlying crash.
2023-08-21 15:35:16 +01:00
Doug Gregor
df2e2eee30 Merge pull request #68028 from DougGregor/supersede-pre-macro-expansion-implied-conformances
Always supersede conformances implied by pre-macro-expansion conformances
2023-08-20 21:41:36 -07:00
Doug Gregor
ab576b31a7 Always supersede conformances implied by pre-macro-expansion conformances
Pre-macro-expansion conformances are introduced at the point where an
attached extension macro is attached to a particular nominal type, and
can imply other conformances. Once the macro is expanded, they are
expected to be replaced by the real conformance from the extension
produced by the macro. This includes any other conformances that are
implied by that conformances. Ensure that the real conformance---and
every conformances it implies---are considered "better" than the
pre-expansion conformances.

Fixes a bug where we would pick the wrong (pre-expansion)
conformances, which would then fail to get fully type-checked prior to
serialization. This could accept invalid code that then crashed the
compiler, as in rdar://112916159.
2023-08-20 09:27:38 -07:00
Sophia Poirier
aec59f2f9c Merge pull request #67974 from sophiapoirier/global-static-data-race-safety
enforce under strict concurrency that globals and statics be either…
2023-08-19 08:28:02 -07:00
Sophia Poirier
936ab20e5d enforce under strict concurrency that globals and statics be either isolated to a global actor or Sendable plus immutable
rdar://81629027 Global and static variable data-race safety
2023-08-18 15:08:42 -07:00
Slava Pestov
c2f1193ae3 Merge pull request #67952 from slavapestov/tuple-conformance-tbd-etc
A pile of mostly unrelated one-liners
2023-08-18 15:31:26 -04:00
Slava Pestov
bea1ba412a AST: Add breadcrumb for crashes in GenericFunctionType canonicalization 2023-08-18 12:13:23 -04:00
Slava Pestov
eadffd3c6c AST: Don't look at PatternBindingDecl in usesBuiltinType()
Type-checking patterns is not fully requestified, so the
ASTPrinter should not assume this has been filled in.

It appears sufficient to just visit the associated VarDecl,
as we do already.
2023-08-18 12:12:50 -04:00
zachary0kent
802e63a778 Merge pull request #67973 from zachary0kent/lazy-immediate-globals
[Immediate] JIT'ing Globals
2023-08-18 08:53:18 -07:00
Artem Chikin
4610a83bdf [Dependency Scanning] Remove Swift Overlay dependencies from the set of direct
dependencies

It is valuable for clients to be able to distinguish which dependencies of a
Swift module originated from 'import' statements, and which ones are implicit
dependency Swift overlays of imported Clang modules.
2023-08-17 11:38:09 -07:00
Allan Shortlidge
9ecb6b4657 Merge pull request #67980 from tshortli/stop-ignoring-me
Frontend: Migrate several options to no longer be ignorable in swiftinterfaces
2023-08-17 09:51:18 -07:00
Alexis Laferrière
be3492152e Merge pull request #67970 from xymus/spi-only-printer
[AST] Update source module correction logic to support @_spiOnly imports
2023-08-17 09:05:39 -07:00
Joe Groff
ad6423f465 Merge pull request #67979 from jckarter/narrow-nominal-type-decl-is-resilient-originally-defined-in-check
Narrow `@_originallyDefinedIn` check in NominalTypeDecl::isResilient to protocols.
2023-08-17 08:43:57 -07:00
Doug Gregor
b126a0f34b Merge pull request #67977 from DougGregor/extension-macro-conformances-and-witnesses
[Macros] Fix handling of extension macro conformances and witnesses
2023-08-16 22:46:06 -07:00
Allan Shortlidge
774ba28606 NFC: Fix a warning in ModuleDependencies.cpp. 2023-08-16 20:34:25 -07:00
Joe Groff
448bb42225 Narrow @_originallyDefinedIn check in NominalTypeDecl::isResilient to protocols.
And add a comment explaining why this check is only relevant to protocols, and shouldn't
be copied to other similar-looking isResilient methods on other types.
According to 25376025ae, which introduced the original
`@_originallyDefinedIn` check, this check was necessary to maintain ABI compatibility
when protocol declarations are moved, but in all other cases, we should treat declarations
as resilient when they are defined in other library-evolution-enabled modules, even when
the declaration was originally defined in the current module.
2023-08-16 20:23:48 -07:00
Joe Groff
d948213c72 Merge pull request #67972 from jckarter/revert-abstractstoragedecl-originally-defined-in-check
Revert "AST: Spot fix for AbstractStorageDecl::isResilient()"
2023-08-16 20:19:56 -07:00
zachary0kent
25f078adb5 Merge branch 'main' into lazy-immediate 2023-08-16 19:45:27 -07:00
Zak Kent
831cfb575d [Sema] [NFC] Don't accumulate lazily typechecked functions in lazy immediate mode 2023-08-16 19:30:31 -07:00
Doug Gregor
b7bfaf3522 [Macros] Fix handling of extension macro conformances and witnesses
Fix two inter-related issues with extension macros that provide
conformances to a protocol, the combined effect of which is that one
cannot meaningfully provide extension macros that implement
conformances to a protocol like Equatable or Hashable that also
supports auto-synthesis.

The first issue involves name lookup of operators provided by macro
expansions. The logic for performing qualified lookup in addition to
unqualified lookup (for operators) did not account for extension
macros in the same manner as it did for member macros, so we would not
find a macro-produced operator (such as operator==) in witness
matching.

The second issue is more fundamental, which is that the conformance
lookup table would create `NormalProtocolConformance` instances for
pre-macro-expansion conformance entries, even though these should
always have been superseded by explicit conformances within the macro
expansion buffers. The end result is that we could end up with two
`NormalProtocolConformance` records for the same conformance. Some
code was taught to ignore the pre-expansion placeholder conformances,
other code was not. Instead, we now refuse to create a
`NormalProtocolConformance` for the pre-expansion entries, and remove
all of the special-case checks for this, so we always using the
superseding explicit conformances produced by the macro expansions (or
error if the macros don't produce them).

Fixes rdar://113994346 / https://github.com/apple/swift/issues/66348
2023-08-16 19:18:36 -07:00
Pavel Yaskevich
c38b9b1e08 Merge pull request #67945 from xedin/remove-runtimeMetadata
[Frontend] NFC: Remove code and tests related to rejected @runtimeMetadata feature
2023-08-16 17:16:46 -07:00
Alexis Laferrière
011222da16 [AST] Fix source module correction logic to support @_spiOnly imports
This logic may override the module considered as the source of a decl to
ensure that only visible modules are printed in the swiftinterface. This
change updates it to consider @_spiOnly imported modules from the local
module as visible when printing the private swiftinterface only.

rdar://103325332
2023-08-16 16:40:57 -07:00
Joe Groff
e2db4d221c Revert "AST: Spot fix for AbstractStorageDecl::isResilient()"
This reverts commit d5b354fd5f. It causes miscompiles when
accessing properties declared with `@_originallyDefinedIn` that are now defined in modules
with library evolution enabled from the module that the property was originally defined in.
Just because the property used to be declared in the current module doesn't mean it can
bypass the stable ABI of the module that the property now belongs to.

It looks like the logic that this PR replaced is also faulty, since `@_originallyDefinedIn`
really oughtn't factor into the resilience computation at any level, but let's unwind one
level of brokenness at a time.

Fixes rdar://113935401.
2023-08-16 14:59:43 -07:00
Allan Shortlidge
117a5ecdae Merge pull request #67920 from tshortli/unavailable-decl-opt-complete-resilient-enum-switch
SILOptimizer: Remove switch cases matching unavailable enum elements
2023-08-16 09:06:20 -07:00
Alejandro Alonso
44198d16a4 Merge pull request #67611 from Azoy/raw-types-are-cool!
[WIP] Implement dependent layouts for raw types
2023-08-16 06:55:42 -07:00
Allan Shortlidge
9eda39c85f NFC: Clean up code duplication in Decl.cpp. 2023-08-15 17:19:03 -07:00
Allan Shortlidge
455f3dcaee AST: Clang enum elements can't be unavailable during lowering.
There aren't sufficiently strong compiler checks that would prevent unavailable
elements of clang enums from being instantiated at runtime, so don't consider
any clang enum elements as unavailable during lowering. Since there aren't any
symbols associated with clang enum elements, we don't have to worry about
linker failures that might result from leaving references to them in SIL.
2023-08-15 17:13:10 -07:00
Allan Shortlidge
29374cb802 SILOptimizer: Skip unreachable cases optimization when elements are available.
Cache a bit on `EnumDecl` indicating whether there are any elements that are
unavailable during lowering and then use that bit to decided whether to attempt
optimization for `switch_enum`/`switch_enum_addr` instructions.
2023-08-15 17:13:10 -07:00
Pavel Yaskevich
b21e8426a0 [AST] NFC: Remove @runtimeMetadata related code 2023-08-15 12:16:40 -07:00
Slava Pestov
1dc4c4699f RequirementMachine: Fix warning in noassert build 2023-08-15 13:51:27 -04:00
Pavel Yaskevich
14cf3c3fd7 [AST] NFC: Teach getExpandedGenericArgs to handle partially resolved parameter packs
A temporary fix to make it possible to debug expressions
with partially resolved variadic generic types. The issue stems
from the fact that `BoundGenericType` is allowed to have pack
parameters directly represented by type variables, as soon as
that is no longer the case this check should be removed.
2023-08-14 17:06:40 -07:00
Zak Kent
289b812a14 [Immediate] Add frontend option for lazy compilation 2023-08-14 13:28:22 -07:00
Allan Shortlidge
4af501a19d Merge pull request #67890 from tshortli/prevent-comparable-synthesis-for-enum-with-assoc-values-and-availability
AST: Fix EnumDecl's hasPotentiallyUnavailableCaseValue() cache
2023-08-11 09:51:55 -07:00
Hamish Knight
1ef4f801db Merge pull request #67800 from hamishknight/conjunction-order 2023-08-11 10:33:11 +01:00
Allan Shortlidge
d438bac68d AST: Fix EnumDecl's hasPotentiallyUnavailableCaseValue() cache.
The cached values for `hasOnlyCasesWithoutAssociatedValues()` and
`hasPotentiallyUnavailableCaseValue()` are computed in a single pass over the
elements of an `EnumDecl`. However, the pass would return early after finding
an element with an associated value, without checking whether any of the rest
of the elements were potentially unavailable. This made `Comparable` synthesis
succeed for any enum with potentially unavailable elements so long as the first
element in the enum has an associated value.
2023-08-10 21:59:55 -07:00
Holly Borla
6c18ffba76 Merge pull request #67882 from hborla/extension-macro-availability
[Macros] Always consider pre-macro-expansion conformances as subsumed by other conformance entry kinds, before considering availability.
2023-08-10 21:59:15 -07:00
Holly Borla
309e3403f6 [Macros] Always consider pre-macro-expansion conformances as subsumed by
other conformance entry kinds, before considering availability.
2023-08-10 18:19:33 -07:00
swift-ci
fbfeb4fbfc Merge pull request #67750 from artemcm/SeparateClangScannerCachePath
[Dependency Scanning] Separate module output path from Clang scanner's module cache
2023-08-10 16:41:15 -07:00
Egor Zhdan
3723ff1401 [cxx-interop] Add UnsafeCxxMutableRandomAccessIterator protocol
This will be used to provide a safe overload of `std::vector::erase` in Swift.

`std::vector::erase` is not currently imported into Swift because it returns a C++ iterator.

rdar://113704853
2023-08-10 19:58:51 +01:00
Artem Chikin
6ef79c4ba0 [Dependency Scanning] Specify Explicit Module output path to the scanner explicitly
Instead of the code querying the compiler's built-in Clang instance, refactor the
dependency scanner to explicitly keep track of module output path. It is still
set according to '-module-cache-path' as it has been prior to this change, but
now the scanner can use a different module cache for scanning PCMs, as specified
with '-clang-scanner-module-cache-path', without affecting module output path.

Resolves rdar://113222853
2023-08-10 11:11:05 -07:00
Slava Pestov
c6387fd079 Merge pull request #67839 from slavapestov/tuple-conformance-sendable-copyable
Replace bespoke Sendable and Copyable conformance on tuples with tuple conformances
2023-08-10 07:22:14 -04:00
Slava Pestov
c26cafc47a AST: Remove bogus PackExpansionType logic in lookupConformance() 2023-08-09 18:28:22 -04:00
Slava Pestov
f219274e9b AST: Remove generic signature and conditional requirements from BuiltinProtocolConformance 2023-08-09 17:42:57 -04:00
Slava Pestov
9f51ea1de6 AST: Remove old tuple conformance logic from getBuiltinTupleTypeConformance() 2023-08-09 17:42:25 -04:00
Slava Pestov
10359ea839 AST: Synthesize ExtensionDecls for conditional conformances of Builtin.TheTupleType to Sendable and Copyable 2023-08-09 17:42:25 -04:00
Slava Pestov
e6d611cda3 AST: Pass allowMissing=true from getPackTypeConformance() 2023-08-09 17:42:25 -04:00