Commit Graph

20126 Commits

Author SHA1 Message Date
Holly Borla
69be7b17fc Merge pull request #40282 from hborla/existential-any
[SE-0335] Introduce existential `any`
2021-12-10 08:56:03 -08:00
swift-ci
e2f1907744 Merge pull request #40487 from rxwei/regex-integration-1 2021-12-10 00:48:09 -08:00
Holly Borla
0b29ba9383 [TypeResolver] Don't use ExistentialType for Any and AnyObject for
now.
2021-12-09 23:15:10 -08:00
Holly Borla
3e936e3e67 [Sema] Require existential types with Self or associated type
requirements to be spelled with 'any' when explicit existential
types are enabled.
2021-12-09 23:15:02 -08:00
Holly Borla
8d52f71561 [NFC][Sema] Rename checkUnsupportedProtocolType to checkExistentialTypes. 2021-12-09 23:15:02 -08:00
Holly Borla
37c0964d3e [Sema] Rename existentialTypeSupported to existentialRequiresAny, and
flip the return value in the implementation accordingly.
2021-12-09 23:15:02 -08:00
Holly Borla
7c7b3ba0da Revert "[NFC, Typechecker] Remove UnsupportedProtocolVisitor and checkUnsupportedProtocolType()"
This reverts commit 15f88e9be3.
2021-12-09 23:15:02 -08:00
Holly Borla
00a4629515 Revert "NFC: Remove the now dead ProtocolDecl::existentialTypeSupported()"
This reverts commit eb1bd07bb3.
2021-12-09 23:15:02 -08:00
Holly Borla
76906304f7 [TypeResolver] Resolve existential types to ExistentialType when
explicit existential types are enabled.

Note that existential metatypes still resolve to ExistentialMetatypeType,
but later this type can be replaced with ExistentialType(MetatypeType).
2021-12-09 23:14:50 -08:00
Holly Borla
445a856652 [Type System] Introduce a dedicated type to represent existential types.
The new type, called ExistentialType, is not yet used in type resolution.
Later, existential types written with `any` will resolve to this type, and
bare protocol names will resolve to this type depending on context.
2021-12-09 23:14:50 -08:00
Doug Gregor
5e9530429c Merge pull request #40488 from DougGregor/sendable-inherit-part-trois
Ensure that Sendable is inherited properly, take 3.
2021-12-09 19:33:10 -08:00
Alexis Laferrière
6fd4cc49cd Merge pull request #40489 from xymus/ignore-non-public-async-when-checking-api 2021-12-09 17:56:16 -08:00
Richard Wei
05363cd55a Regex literal runtime plumbing.
- Frontend: Implicitly import `_StringProcessing` when frontend flag `-enable-experimental-string-processing` is set.
- Type checker: Set a regex literal expression's type as `_StringProcessing.Regex<(Substring, DynamicCaptures)>`. `(Substring, DynamicCaptures)` is a temporary `Match` type that will help get us to an end-to-end working system. This will be replaced by actual type inference based a regex's pattern in a follow-up patch (soon).
- SILGen: Lower a regex literal expression to a call to `_StringProcessing.Regex.init(_regexString:)`.
- String processing runtime: Add `Regex`, `DynamicCaptures` (matching actual APIs in apple/swift-experimental-string-processing), and `Regex(_regexString:)`.

Upcoming:
- Build `_MatchingEngine` and `_StringProcessing` modules with sources from apple/swift-experimental-string-processing.
- Replace `DynamicCaptures` with inferred capture types.
2021-12-09 16:05:34 -08:00
Alexis Laferrière
69ee427532 [Sema] Fix reports on async when checking only the API availability
-check-api-availability-only limits availability checking to the API
only, ensuring that was will appear in the swiftinterface is sound but
without raising issues about implementation details. This patch ensures
it correctly ignore non-public async functions as they wouldn't appear
in the API.

rdar://86174644
2021-12-09 11:34:33 -08:00
Doug Gregor
61e907498c Ensure that Sendable is inherited properly, take 3.
Extend the implicit Sendable request to produce an inherited
conformance when queried, rather than depending on the conformance
lookup table to always have the right entries. This acknowledges that
implicit Sendable needs to happen more at the type checking level than
the name-binding level, which is needed to eliminate cyclic
dependencies.
2021-12-09 11:06:13 -08:00
Slava Pestov
d9fd6cbdbf Merge pull request #40482 from slavapestov/rqm-verify-protocol-signatures
AST: Use RequirementMachine to verify protocol requirement signatures
2021-12-09 13:51:31 -05:00
Pavel Yaskevich
57bfef088e Merge pull request #40480 from LucianoPAlmeida/SR-15562-fail-diag
[SR-15562] [Sema] Do not consider warning fixes for non-augmenting fix recording
2021-12-09 10:13:48 -08:00
Holly Borla
3ab0a78383 [AST] Introduce ExistentialTypeRepr, which is the type repr for an
existential type spelled with `any`.
2021-12-09 09:26:12 -08:00
Slava Pestov
589fc40d5a AST: Use RequirementMachine to verify protocol requirement signatures 2021-12-08 23:07:48 -05:00
LucianoAlmeida
85246bcc55 [test] Add regression test for SR-15562 2021-12-09 00:00:35 -03:00
LucianoAlmeida
b250723f58 [Sema] Do not consider warning fixes for non-augmenting fix recording logic 2021-12-08 23:54:05 -03:00
Xi Ge
3495937bb3 Merge pull request #40474 from apple/revert-40440-prefer-swift-type
Revert "lookup: prefer Swift types over Clang ones when multiple types are present in lookup"
2021-12-08 18:07:29 -08:00
Evan Wilde
a3cc692f01 Merge pull request #40378 from etcwilde/ewilde/concurrency/unavailablefromasync-messages
Adding optional message to `_unavailableFromAsync`
2021-12-08 17:30:50 -08:00
Slava Pestov
cfd8dbf272 Merge pull request #40465 from slavapestov/rqm-protocol-minimization-fixes
RequirementMachine: Protocol requirement signature minimization fixes
2021-12-08 17:19:21 -05:00
Xi Ge
0468b07bba Revert "lookup: prefer Swift types over Clang ones when multiple types are present in lookup" 2021-12-08 13:40:45 -08:00
Evan Wilde
691cf1925d Merge branch 'main' into ewilde/concurrency/unavailablefromasync-messages 2021-12-08 11:41:14 -08:00
Zoe Carver
a46a3c525a Merge pull request #39605 from zoecarver/cxx-interop-import-as-class
[cxx-interop] Implement foreign reference types.
2021-12-08 19:33:50 +00:00
Evan Wilde
3a13721eae Add optional message to unavailablefromasync
Adding the ability to add an optional message to the unavailable from
async attribute. This can be used to indicate other possible API to use,
or help explain why it's unavailable.
2021-12-08 09:39:24 -08:00
zoecarver
fc3b3a1d71 [cxx-interop] Implement foreign reference types.
This is an expiremental feature to allow an attribute, `import_as_ref`, to import a C++ record as a non-reference-counted reference type in Swift.
2021-12-08 15:35:18 +00:00
Slava Pestov
044611dddc RequirementMachine: Another cycle-breaking hack for associated type inference 2021-12-08 00:53:35 -05:00
Pavel Yaskevich
fecc887024 Merge pull request #40438 from xedin/rdar-85843677
[PreCheck] Don't use value declared in closure as outer candidate if …
2021-12-07 12:14:58 -08:00
swift-ci
dc8392cf5a Merge pull request #40442 from DougGregor/explicit-non-sendable-def 2021-12-07 02:28:26 -08:00
Hamish Knight
23a8bf0bec Merge pull request #40367 from hamishknight/pitter-patter 2021-12-07 10:15:44 +00:00
Doug Gregor
529bbec38f Align "explicitly non-Sendable" definition with proposal.
Use the explicit check for a Sendable conformance (even an unavailable
one) as the mechanism for determining whether to diagnose a
missing/unavailable Sendable conformance in a particular context.
2021-12-06 22:29:17 -08:00
Xi Ge
1eadd44a85 Merge pull request #40440 from nkcsgexi/prefer-swift-type 2021-12-06 20:21:16 -08:00
swift-ci
53c17df12d Merge pull request #40439 from DougGregor/require-explicit-sendable-nonsendable 2021-12-06 18:48:40 -08:00
Pavel Yaskevich
f642c3efc8 [PreCheck] Don't use value declared in closure as outer candidate if it's validated
With multi-statement closure inference enabled "outer candidates"
hack needs to be careful with its use of `isInvalid()` because some
of the declarations lookup finds might be coming from a multi-statement
closure that being type-checked, such declarations have to be avoided
as candidates, otherwise calling `isInvalid` on them results in a circular
type-checking.

Resolves: rdar://85843677
2021-12-06 16:47:56 -08:00
Doug Gregor
600fd1775a Merge pull request #40434 from DougGregor/capture-sendable-checking
Diagnose non-sendable captures more directly.
2021-12-06 15:46:15 -08:00
Xi Ge
1781fef107 lookup: prefer Swift types over Clang ones when multiple types are present in lookup 2021-12-06 14:33:13 -08:00
Doug Gregor
d0757349d9 Improve -require-explicit-sendable check to account for @_nonSendable
We were doing the conformance check through a lower-level interface that
didn't deal with the unavailable Sendable synthesis.
Fixes a spurious diagnostic reported via rdar://85894346.
2021-12-06 13:57:47 -08:00
Hamish Knight
37f16520e6 Prototype regex literal AST and emission
With `-enable-experimental-string-processing`,
start lexing `'` delimiters as regex literals (this
is just a placeholder delimiter for now). The
contents of which gets passed to the libswift
library, which can return an error string to be
emitted, or null for success.

The libswift side isn't yet hooked up to the Swift
regex parser, so for now just emit a dummy
diagnostic for regexes starting with quantifiers.

If successful, build an AST node which will be
emitted as an implicit call to an
`init(_regexString:)` initializer of an in-scope
`Regex` decl (which will eventually be a known
stdlib decl).
2021-12-06 21:16:14 +00:00
Evan Wilde
cce3e8a7f5 Merge pull request #40149 from etcwilde/ewilde/concurrency/underscored-unavailablefromasync
Add `_unavailableFromAsync` attribute
2021-12-06 12:38:53 -08:00
Doug Gregor
9bd209d35b Diagnose non-sendable captures more directly.
Rather than only checking the sendability of captures at the point of
use, diagnose captures uniformly for the closure as a whole. Fixes a
case where we were missing a diagnostic due to an explicit capture,
rdar://85988937.
2021-12-06 11:32:29 -08:00
Pavel Yaskevich
8953c09e40 Merge pull request #40397 from xedin/reland-se-0326-related-changes-without-reenabling
[TypeChecker] Re-land fixes/improvements related to SE-0326
2021-12-06 09:53:55 -08:00
Doug Gregor
4715a34c20 Merge pull request #40413 from DougGregor/remove-sendable-nonisolated-check 2021-12-03 23:07:50 -08:00
Doug Gregor
7033944cde Remove Sendable diagnostics for nonisolated declarations.
Non-isolated declarations in general do not require Sendable
diagnostics. However, we do need to make sure that `nonisolated let`
accesses to actor-isolated state are always cross-actor.

Fixes rdar://83371627.
2021-12-03 19:03:22 -08:00
Doug Gregor
be360b24f7 Perform generic substitutions for Sendable checking in protocol conformances 2021-12-03 16:41:36 -08:00
Alexis Laferrière
adf712edaf Merge pull request #40364 from xymus/error-on-import-of-private-in-assert
[Sema] Report public imports of private module as error in asserts mode
2021-12-03 16:09:58 -08:00
Alexis Laferrière
1b42953b43 Merge pull request #40386 from xymus/no-inserted-spi-import
[Sema] Don't insert an @_spi on imports for clang SPIs
2021-12-03 13:44:12 -08:00
Pavel Yaskevich
277b0fcca5 [BuilderTransform] Don't skip multi-statement closures during pre-check
Each of the elements in the result builder has to be fully pre-checked
now that multi-statement inference has been enabled.
2021-12-03 11:08:26 -08:00