Commit Graph

20496 Commits

Author SHA1 Message Date
Kavon Farvardin
04454054b7 NCGenerics: add availability checking
Not all runtimes can correctly operate with types that use noncopyable
generics. When the generic argument of a type is noncopyable, old
runtimes can't recognize that to correctly check conformances that may
be conditional on those arguments being Copyable, etc.

resolves rdar://126239335
2024-07-07 15:38:00 -07:00
Michael Gottesman
9f8e5e8998 Merge pull request #75016 from gottesmm/pr-d4640c7e2919faea7bc7eb96ebd8af643108e2d8
[region-isolation] When determining isolation from a class_method, check for global actor isolation first.
2024-07-07 09:58:24 -07:00
Slava Pestov
bd2fcf34af Merge pull request #75015 from slavapestov/split-caching
Request evaluator split caching
2024-07-07 12:41:55 -04:00
Michael Gottesman
0a06c00f47 [region-isolation] When determining isolation from a class_method, check for global actor isolation first.
Before this change in the following code, we would say that message is isolated to the actor instead of the global actor isolation of the actor's method:

```swift
class Message { ... }

actor MessageHolder {
  @MainActor func hold(_ message: Message) { ... }
}

@MainActor
func sendMessage() async {
    let messageHolder = MessageHolder()
    let message = Message()
    // We identified messageHolder.hold as being MessageHolder isolated
    // instead of main actor isolated.
    messageHolder.hold(message)
    Task { @MainActor in print(message) }
}
```

I also used this as an opportunity to simplify the logic in this part of the
code. Specifically, I had made it so that multiple interesting cases were
handled in the same conditional statement in a manner that it made it hard to
know which cases were actually being handled and why it was correct. Now I split
that into two separate if statements with comments that make it clear what we
are actually trying to pattern match against.

rdar://130980933
2024-07-06 23:01:21 -07:00
Slava Pestov
4c7ca3ea72 Convert ApplyAccessNoteRequest to use separate caching 2024-07-06 23:36:00 -04:00
Slava Pestov
ec28d62d61 Convert AttachedPropertyWrappersRequest to use split caching 2024-07-06 23:36:00 -04:00
Slava Pestov
6489b60f8a Convert DynamicallyReplacedDeclRequest to use split caching 2024-07-06 23:36:00 -04:00
Slava Pestov
010ddfc816 Convert LifetimeDependenceInfoRequest to use split caching 2024-07-06 23:36:00 -04:00
Slava Pestov
0097ef68a6 Convert ActorIsolationRequest to use split caching 2024-07-06 23:36:00 -04:00
Slava Pestov
6b9267aaac Convert ExpandPeerMacroRequest to use split caching 2024-07-06 23:35:59 -04:00
Slava Pestov
edf8237df2 Convert SPIGroupsRequest to use split caching 2024-07-06 23:35:59 -04:00
Slava Pestov
80ddc3275f Convert PropertyWrapperAuxiliaryVariablesRequest to use split caching 2024-07-06 23:35:59 -04:00
Slava Pestov
9d163c4139 Convert GlobalActorAttributeRequest to use split caching 2024-07-06 23:35:59 -04:00
Slava Pestov
8a92c9cfc5 Convert ExpandMemberAttributeMacros to use split caching 2024-07-06 23:35:59 -04:00
Slava Pestov
7dc1328fad Basic: Introduce 'split caching' for requests 2024-07-06 23:35:46 -04:00
Slava Pestov
7ba2b76966 Basic: Add -analyze-request-evaluator flag to dump request cache statistics 2024-07-06 23:35:39 -04:00
Hamish Knight
fe68fab1e2 [AST] Simplify construction of EnumElementPattern
Add `EnumElementPattern::create` and
`EnumElementPattern::createImplicit`, and replace
existing constructions with them.
2024-07-06 22:56:30 +01:00
Slava Pestov
86d567f95a AST: ModuleDecl::lookupConformance() is a static method 2024-07-06 12:05:47 -04:00
Slava Pestov
e8d717bcd6 AST: Remove ModuleDecl parameter from checkRequirements() 2024-07-06 12:05:46 -04:00
Slava Pestov
1901862afc AST: Remove LookUpConformanceInSignature 2024-07-06 12:05:46 -04:00
Slava Pestov
fae01d9776 AST: Remove ModuleDecl parameter from more places 2024-07-06 12:05:46 -04:00
Slava Pestov
b7117aa877 AST: Start untangling ModuleDecl from conformance lookup 2024-07-06 12:05:45 -04:00
Hamish Knight
63e7c9380d Merge pull request #74890 from hamishknight/attr-etc
[Completion] Update type attribute completions
2024-07-04 17:57:15 +01:00
Doug Gregor
e50beb0a46 Merge pull request #74962 from DougGregor/typed-throws-backdeploy-fixes
Typed throws backdeploy fixes
2024-07-04 00:12:52 -07:00
eeckstein
46256f5cd7 Merge pull request #74897 from eeckstein/fix-vtable-specializer
Fix a SourceKitCrash in the VTableSpecializer pass
2024-07-04 08:16:30 +02:00
Doug Gregor
21e5066249 Diagnose deployment constraints on type metadata involving typed throws
Fixes the rest of rdar://121530587.
2024-07-03 21:08:54 -07:00
Doug Gregor
9604019c87 Drop typed throws from the mangling in closure and field reflection metadata
This follows what we just did for `@isolated(any)` function types.

Part of rdar://130858222.
2024-07-03 20:14:01 -07:00
Pavel Yaskevich
17deda69eb [AST] NFC: Add a flag that allows matching to skip any Sendable and `& Sendable compositions 2024-07-03 20:02:11 -07:00
Artem Chikin
15dda6c9a7 Merge pull request #74945 from artemcm/FixCrossImportOnScannerValidatedBinaryModules
[Dependency Scanning] Resolve cross-import overlays relative to defining interface for prebuilt binary Swift dependencies
2024-07-03 18:03:23 -07:00
Alejandro Alonso
427077b148 Merge pull request #74901 from Azoy/static-exclusive-requirements
[Sema] Let protocols define getter requirements for @_staticExclusiveOnly types
2024-07-03 14:33:19 -07:00
Artem Chikin
2464f87f8f [Dependency Scanning] Resolve cross-import overlays relative to defining interface for prebuilt binary Swift dependencies
When the dependency scanner picks a pre-built binary module candidate for a given dependency, it needs to be able to attempt to resolve its cross-import overlays relative to the textual interface that the binary module was built from. For example, if a collection of binary modules are located in, and resolved as dependencies from, a pre-built module directory, the scanner must lookup their corresponding cross-import overlays relative to the defining interface as read out from the binary module's MODULE_INTERFACE_PATH. https://github.com/swiftlang/swift/pull/70817 ensures that binary modules serialize the path to their defining textual interface.

Resolves rdar://130778577
2024-07-03 10:05:54 -07:00
Erik Eckstein
9360c76cd8 Fix a SourceKitCrash in the VTableSpecializer pass
Replace the assert-check if a vtable is available with a regular error message.
This cannot occur in regular builds - only if built with embedded swift and without wmo.
The command line compiler prevents this combination, but it  can happen in SourceKit.

rdar://130167087
2024-07-03 17:13:53 +02:00
Hamish Knight
42f563d6d8 [Completion] Use TypeAttr.def for simple type attributes
Pick up all non-underscored simple type attributes
for code completion, and add support for
`@isolated(any)`.

rdar://130741006
rdar://130288443
2024-07-03 11:41:58 +01:00
Hamish Knight
e4bec41717 [AST] Demote @noescape and @async to SIL attributes
These aren't currently claimed by anything other
than SILFunctions, and as such are invalid in
regular Swift code. Treat them as SIL type
attributes. Also while here, fix the SIL reference
attributes to be SIL attributes.
2024-07-03 11:41:06 +01:00
John McCall
80e23d377d Merge pull request #74916 from rjmccall/strip-isolated-any-reflection-metadata
Suppress `@isolated(any)` in reflective metadata strings on old targets
2024-07-03 02:41:23 -04:00
Michael Gottesman
6fe749626f [region-isolation] Add 'inout sending' diagnostics.
Specifically:

1. We error now if one transfers an 'inout sending' parameter and does not
reinitialize it before the end of the function.

2. We error now if one merges an 'inout sending' parameter into an actor
isolated region and do not reinitialize it with a non-actor isolated value
before the end of the function.

rdar://126303739
2024-07-02 16:21:44 -07:00
John McCall
2c6e0efb9c Suppress @isolated(any) in reflective metadata strings on old targets
Fix another aspect of rdar://129861211
2024-07-02 18:12:20 -04:00
Michael Gottesman
34195ff213 Merge pull request #74610 from gottesmm/pr-324fd70c13e87a329334341aae4667f2d1be152c
[sending] Remove transferring.
2024-07-02 14:02:18 -07:00
Alejandro Alonso
66de676348 Update include/swift/AST/DiagnosticsSema.def
Co-authored-by: Hamish Knight <hamish_knight@apple.com>
2024-07-02 13:00:52 -07:00
Alejandro Alonso
2f0750a450 Let protocols define getter requirements for @_staticExclusiveOnly types 2024-07-02 10:35:11 -07:00
Hamish Knight
0f30a1ab35 [Completion] Handle body macro attribute completion
Add support for function-attached macros, and
complete body and preamble macros in those
positions.

rdar://130740590
2024-07-02 09:44:32 +01:00
Michael Gottesman
a13c1dc2dc Merge pull request #74869 from gottesmm/rdar130915737
[region-isolation] Improve async let errors to always use a new style error.
2024-07-01 16:24:32 -07:00
Egor Zhdan
75a00adcf0 Merge pull request #74625 from swiftlang/egorzhdan/upstream-ptrauth-vwt
[IRGen] Upstream pointer auth for value witness tables
2024-07-01 22:17:59 +01:00
Michael Gottesman
02e003f0de [region-isolation] Change capturing a value into an async let that is not further sent into an actor isolated function to use a new style error.
Just going through and fixing sending errors.

rdar://130915737
2024-07-01 13:12:36 -07:00
Egor Zhdan
b22057e637 [IRGen] Upstream pointer auth for value witness tables
This makes Swift emit a signed pointer to the value witness table in type metadata.

The original change was done by Varun Gandhi.
2024-07-01 16:38:06 +01:00
susmonteiro
e86099c26d [cxx-interop] Implements constructor for std::span from UnsafeBufferPointer
Tests: init span from UnsafeBufferPointer, for loop, map, filter, init Array from span, span of strings
2024-07-01 16:07:28 +01:00
Michael Gottesman
a4eb43ec88 Merge pull request #74850 from gottesmm/pr-34859085fc34b650049006f026ab33726f79b600
[concurrency] Standardize sending of non-isolated -> nonisolated to match the keyword 'nonisolated'.
2024-06-29 22:19:28 -07:00
Michael Gottesman
474aa47732 [concurrency] Standardize sending of non-isolated -> nonisolated to match the keyword 'nonisolated'.
rdar://130827967
2024-06-29 18:09:38 -07:00
Allan Shortlidge
d48f949f8c AST: Functions nested in exportable functions are also exportable.
Centralize the exportability checking logic for nested functions in the
`DeclExportabilityVisitor` utility. This logic was previously added to SILGen
but there should not be special casing for nested functions at that layer.
2024-06-28 16:08:37 -07:00
Ben Barham
d8f381e660 Merge pull request #74804 from bnbarham/rename-equals
Update `StringRef::equals` references to `operator==`
2024-06-28 11:22:20 -07:00