Commit Graph

19563 Commits

Author SHA1 Message Date
Steven Wu
541ee12137 Merge pull request #75598 from cachemeifyoucan/eng/PR-127205953
[DependencyScanner] Use mutex to protect all accesses to contextCacheMap
2024-07-31 16:36:29 -07:00
Pavel Yaskevich
ceeb6ec23f Merge pull request #75526 from gregomni/specialize
[Sema] Improve diagnoses of generic specializations
2024-07-31 16:27:11 -07:00
Steven Wu
9967e58624 [DependencyScanner] Use mutex to protect all accesses to contextCacheMap
Rather than only protecting the insertion and non-const access to
`ContextSpecificCacheMap` in ScanningService, extend the mutex
protection to all accesses. Even a 'const' lookup in the cache map is
not thread safe because the `StringMap` could be in the process of being
rehashed.

rdar://127205953
2024-07-31 13:17:04 -07:00
Greg Titus
d87e049cde Improve diagnoses of generic specializations
Always add constraints, find fixes during simplify.
New separate fix for allow generic function specialization.
Improve parse heuristic for isGenericTypeDisambiguatingToken.
Degrade concrete type specialization fix to warning for macros.
2024-07-30 18:51:34 -07:00
Andrew Trick
50ee84a0b4 Infer LifetimeDependenceInfo on a mutating method
We need this at least until we have 'dependsOn(self)' syntax.

When 'self' is nonescapable and the result is 'void', assume that 'self' depends
on a single nonescapable argument.
2024-07-30 15:57:57 -07:00
Andrew Trick
11640461ef Lifetime dependence: add inferrence for setters.
A nonescapable computed property should always depend on 'newValue'. We simply
infer that now. There's no way to explicitly spell the dependence.
2024-07-30 15:57:57 -07:00
Allan Shortlidge
5819c31a6c Merge pull request #75568 from tshortli/next-isolation-availability
NFC: Update stale references to `next(_:)`
2024-07-30 14:11:19 -07:00
Joe Groff
d37ff048aa Merge pull request #75560 from jckarter/disable-consuming-self-in-deinit
Disallow consuming `self` in a noncopyable `deinit` again.
2024-07-30 10:59:35 -07:00
Allan Shortlidge
4224479a43 NFC: Update stale references to next(_:).
In the accepted proposal for SE-0421, `next(_:)` became `next(isolation:)`.
Some of the references to that method in the codebase need to be updated
accordingly.
2024-07-30 09:47:20 -07:00
Joe Groff
de687db20f Disallow consuming self in a noncopyable deinit again.
The changes to allow for partial consumption unintentionally also allowed for
`self` to be consumed as a whole during `deinit`, which we don't yet want to
allow because it could lead to accidental "resurrection" and/or accidental
infinite recursion if the consuming method lets `deinit` be implicitly run
again. This makes it an error again. The experimental feature
`ConsumeSelfInDeinit` will allow it for test coverage or experimentation
purposes. rdar://132761460
2024-07-29 21:20:14 -07:00
Artem Chikin
5dd4977b0f Revert "[Dependency Scanning] Use a standalone DependencyScanningFilesystem on the scanner, sharing a common status cache from Clang's dependency service cache"
This reverts commit 1804a8486e.
2024-07-29 11:58:59 -07:00
Allan Shortlidge
9aab6ef33e AST: Fix MemberImportVisibility handling of @_exported imports.
In existing Swift, an `@_exported import` in any source file makes the
declarations from the imported module visible in all source files. It's unclear
whether this is an explicit decision or is simply and unintended consequence of
effectively adding an implicit import to each source file for the module being
compiled.

Although it's not clear whether this behavior is desirable, the behavior of
member lookup when the MemberImportVisibility feature is enabled should align
with it in order to avoid causing unnecessary churn in required imports.

Resolves rdar://132525152.
2024-07-26 10:20:41 -07:00
Allan Shortlidge
f7ff3f0001 SILGen: Introduce macCatalyst support for @backDeployed.
Upstreams the necessary changes to compile references to `@backDeployed`
declarations correctly when a `macabi` target triple or a `-target-variant` is
specified.
2024-07-23 17:00:10 -07:00
Allan Shortlidge
6fb6a56b20 SILGen: Introduce macCatalyst support for if #available.
Upstream the necessary changes to compile `if #available` queries correctly
when a `macabi` target triple or a `-target-variant` is specified.
2024-07-23 17:00:10 -07:00
Allan Shortlidge
e4331af916 IRGen: Introduce macCatalyst target variant version check builtins. 2024-07-23 17:00:10 -07:00
Joe Groff
9f2ee07de8 Merge pull request #75334 from jckarter/extern-is-experimental
`@_extern` is an experimental feature.
2024-07-19 09:04:14 -07:00
smonteiro2
684e9ebf0c [cxx-interop] Implements CxxMutableSpan, created from an UnsafeMutableBufferPointer
* Added tests for generic functions
* Add some tests for mutable spans
* Initialize ConstSpan from UnsafeMutableBufferPointer
* Change hardening flag
2024-07-19 10:38:52 +01:00
Konrad `ktoso` Malawski
e53cd7d079 [Distributed] Handle #isolation param in DA as known to not cross isolation (#75327)
The isolation checker was assuming that one can only be isolated to a
specific var, but that's not true for distributed actors -- because the
default parameter emitted by #isolation is a method call -- converting
the self into an any Actor.

We must handle this in isolation checker in order to avoid thinking
we're crossing isolation boundaries and making methods implicitly async
etc, when we're actually not.

resolves rdar://131874709
2024-07-19 09:47:24 +09:00
Joe Groff
51829c17bf @_extern is an experimental feature.
Mark it as such. rdar://132013078
2024-07-18 11:46:16 -07:00
Kavon Farvardin
1fa02fb0fe Revert "NCGenerics: remove the reverse-condfail workaround"
This reverts commit 5b2f2cbfcf.
2024-07-16 08:10:00 -07:00
Pavel Yaskevich
cfb50a0aef Merge pull request #75191 from xedin/inlinable-init-accessors
[AST/Sema] Make it possible to use init accessors in inlinable initializers
2024-07-15 09:16:30 -07:00
Hamish Knight
cbd68dd794 Merge pull request #75226 from hamishknight/some-keyword
[ASTPrinter] Print `some` as a keyword
2024-07-15 16:55:41 +01:00
Kavon Farvardin
be0e61e6d6 Merge pull request #75211 from kavon/handle-stdlib-with-no-files-129092011
NCGenerics: handle failure to load stdlib
2024-07-14 21:13:36 -07:00
Michael Gottesman
59f44f9d0f Merge pull request #75228 from gottesmm/pr-f2f34406d69ac9eaaad55962982a29be7d08c95b
[gardening] Print out nonisolated(unsafe) on var decls when printing VarDecl
2024-07-13 17:39:14 -07:00
Michael Gottesman
b20251eaec [gardening] Print out nonisolated(unsafe) on var decls when printing VarDecl.
Just noticed this was missing when doing some other work.
2024-07-13 14:44:14 -07:00
Holly Borla
e08bd9565d Merge pull request #75135 from hborla/unavailable-superclass-conformance
[ConformanceLookup] Don't allow skipping inherited unavailable conformances in favor of explicit available ones.
2024-07-13 10:15:49 -07:00
Slava Pestov
8be66967ed Merge pull request #75210 from slavapestov/optimize-is-weak-linked
AST: Optimize ModuleDecl::isImportedAsWeakLinked()
2024-07-13 12:43:13 -04:00
Hamish Knight
bfa3ad063d [ASTPrinter] Print some as a keyword
This is consistent with how the TypeRepr is
printed.
2024-07-13 14:55:35 +01:00
Kavon Farvardin
b02b94cd52 NCGenerics: handle failure to load stdlib
The stdlib module can end up being a non-null ModuleDecl that contains
no files, due to a failure to load the stdlib.

In such an unusual case, fall-back to synthesizing Copyable/Escapable
into the Builtin module so that Sema can proceed.

rdar://129092011
2024-07-12 15:48:40 -07:00
Holly Borla
e2ddc6c6c2 [ProtocolConformance] Compute the correct un-availability for inherited
conformances.
2024-07-12 14:58:49 -07:00
Slava Pestov
5e30f6a4c3 AST: Optimize ModuleDecl::isImportedAsWeakLinked() 2024-07-12 15:53:58 -04:00
Pavel Yaskevich
be3396821e [AST] Print init accessors when they are ABI-public
Using init accessors from inlinable code requires `@usableFromInline`
annotation, which means that we need to print them in swift interfaces
and serialize them.
2024-07-12 09:54:08 -07:00
Kavon Farvardin
4529f3b295 Merge pull request #75183 from kavon/remove-reverse-condfail-workaround
NCGenerics: remove the reverse-condfail workaround
2024-07-12 09:39:12 -07:00
Allan Shortlidge
373a3fe7de Merge pull request #75185 from tshortli/revert-aeic-diagnose-unavailable-code-reached
SILGen/stdlib: Remove `_diagnoseUnavailableCodeReached_aeic()`
2024-07-12 09:22:11 -07:00
Holly Borla
b1397703a5 [ConformanceLookup] Just kidding, the compiler needs to prefer available
Sendable conformances for source compatibility.

If conformance lookup always prefers the conformance from the defining module,
libraries introducing unavailable Sendable conformances can break source in
clients that declare retroactive Sendable conformances. Instead, still prefer
the available conformance, and always diagnose the client conformance as
redundant (as a warning). Then, when the retroactive conformance is removed,
the errors will surface, so the programmer has to take explicit action to
experience the source break.
2024-07-11 23:03:33 -07:00
Holly Borla
85b66d1dc2 [ConformanceLookup] Always prefer unavailable Sendable conformances from the
defining module, and diagnose redundant Sendable conformances.

We still allow re-stating inherited unchecked Sendable conformances in
subclasses because inherited Sendable conformances are surprising when
they opt out of static checking. Otherwise, warning on redundant Sendable
conformances nudges programmers toward cleaning up unnecessary retroactive
Sendable conformances over time as libraries incrementally add the
conformances directly.
2024-07-11 20:33:24 -07:00
Allan Shortlidge
39a9d23ff7 Merge pull request #75180 from tshortli/module-interface-omit-convenience-on-actor-init
AST: Don't print `convenience` on actor initializers
2024-07-11 16:28:08 -07:00
Allan Shortlidge
14200e412c SILGen/stdlib: Remove _diagnoseUnavailableCodeReached_aeic().
It should no longer be necessary to provide an `@_alwaysEmitIntoClient` version
of `_diagnoseUnavailableCodeReached()`. This workaround was originally added to
provide compatibility with projects that were misconfigured to compile against
a newer stdlib but link against an older one.

Resolves rdar://119892482.
2024-07-11 14:53:03 -07:00
Kavon Farvardin
5b2f2cbfcf NCGenerics: remove the reverse-condfail workaround
This should no longer be needed, after having staged the first set of
changes in, as it was a temporary workaround.

resolves rdar://131560183
2024-07-11 14:30:27 -07:00
Pavel Yaskevich
dbe151bc0f [AST] Mark init accessors as having internal access
This allows them to be used across files in the same module
and requires explicit `@usableFromInline` annotation to be
used inside of `@_alwaysEmitIntoClient` and `@inlinable`
initializers.
2024-07-11 14:03:11 -07:00
Ellie Shin
cb776089cb Merge pull request #75154 from swiftlang/elsh/drop-exp-prefix
Drop experimental prefixes from PackageCMO flags.
2024-07-11 12:12:29 -07:00
Allan Shortlidge
3453b136c3 AST: Don't print convenience on actor initializers.
Although actor initializers can be classified as convenience initializers by
the internals of the compiler, they are not written that way in source and
should not be printed with the `convenience` keyword.

Resolves rdar://130926278.
2024-07-11 11:47:19 -07:00
Pavel Yaskevich
e4cd1d7acd Merge pull request #75062 from xedin/rdar-122193606
[Concurrency] Allow sendability mismatches while overriding `@preconcurrency` properties in Swift 5 mode
2024-07-11 11:18:53 -07:00
Allan Shortlidge
5d6f6947ed Merge pull request #75158 from tshortli/member-import-visibility-package
AST: Add a `IgnoreMissingImports` option to name lookup
2024-07-11 11:07:39 -07:00
Slava Pestov
c345ba94c8 Merge pull request #75164 from slavapestov/irgen-collect-link-libraries
AST: Optimize collectLinkLibraries()
2024-07-11 09:00:14 -04:00
Allan Shortlidge
d002da0ef2 AST: Add a IgnoreMissingImports option to name lookup.
Control enforcement of member import visibility requirements via a new option,
instead of piggy-backing on the existing IgnoreAccessControl option. Adopt the
option when doing fallback lookups for unviable members so that the compiler
can diagnose the reason that a member is inaccessible more reliably.
Previously, with MemberImportVisibility enabled decls with the package access
level could be mis-diagnosed as inaccessible due to their access level when
really they were inaccessible due to a missing import.

Resolves rdar://131501862.
2024-07-10 22:57:15 -07:00
Andrew Trick
12acde2215 Merge pull request #75096 from meg-gupta/lifetimedeparg
Add support for lifetime dependence in parameter position
2024-07-10 22:56:23 -07:00
Slava Pestov
403bb98451 AST: Optimize collectLinkLibraries()
SourceFile::collectLinkLibraries() did not depend on the source file,
so let's move this logic up into ModuleDecl::collectLinkLibraries().
2024-07-10 23:06:22 -04:00
Slava Pestov
d1847ffde7 Merge pull request #75068 from slavapestov/simplify-sub-map
Simplify and optimize SubstitutionMap
2024-07-10 20:45:56 -04:00
Michael Gottesman
38631ac0b9 Merge pull request #75136 from gottesmm/pr-f4ed7a74d1c86b132efccb042929ea28b764fc90
[sending] Change suppression to use __owned instead of consuming.
2024-07-10 16:46:29 -07:00