Commit Graph

1116 Commits

Author SHA1 Message Date
Doug Gregor
8cef6d5572 Don't emit @preconcurrency import warnings for Swift interfaces
Fixes rdar://88758592.
2022-04-13 23:19:50 -07:00
Daniel Duan
3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
Allan Shortlidge
f27005b8d0 ModuleInterface: When printing synthesized extensions, we need to be sure to guard them with required features if applicable. Not doing so can result in broken interfaces that do not typecheck because, for instance, a conformance can refer to a nominal type that is only declared when certain features are enabled.
Also, fix a typo where `#elsif` was printed into interfaces instead of `#elseif`.

Resolves rdar://91509673
2022-04-12 17:53:59 -07:00
Artem Chikin
b3726d097b Merge pull request #42217 from artemcm/BareBonesRegexSyntax
Rename flag for enabling forward slash literals to be less ambiguous.
2022-04-11 16:40:23 -07:00
Slava Pestov
9a7df88bc8 ASTPrinter: Rename PrimaryAssociatedTypes feature to PrimaryAssociatedTypes2
There was a window where the PrimaryAssociatedTypes feature guarded the old
syntax; let's make sure we don't see breakage if a new standard library is
used with an old compiler.
2022-04-11 15:27:38 -04:00
Slava Pestov
b16498c3df ASTPrinter: Remove printWithCompatibilityFeatureChecks() from printSynthesizedExtensionIfNeeded()
This path was not exercised in the test suite, and when the
PrimaryAssociatedTypes feature finally (incorrectly) triggered it,
it would print '#endifextension'.
2022-04-06 23:47:10 -04:00
Slava Pestov
1bf248e374 Enable parameterized protocols by default, and add new staging flag for parameterized existentials 2022-04-06 17:30:10 -04:00
Artem Chikin
7ba377b3c2 Rename flag for enabling forward slash literals to be less ambiguous.
Previous spelling could easily be mistaken for gating the entire feature.

Part of rdar://91119995
2022-04-06 09:46:40 -07:00
Xi Ge
6b1f736f16 Availability: only diagnose exposing SPI_AVAILABLE symbols in modules with library-level=API
For executable targets or private libraries, using SPI_AVAILABLE symbols should be allowed.

rdar://91088241
2022-04-04 15:33:30 -07:00
Slava Pestov
07e53c2b0f Merge pull request #42158 from slavapestov/se-0346-revisions
Revise SE-0346 implementation for core team decision
2022-04-04 02:01:40 -04:00
Slava Pestov
8c47cd75fd Sema: The primary associated type list references existing associated types instead of declaring new ones 2022-04-03 22:03:49 -04:00
Xi Ge
8dd638fbd0 ModuleInterface: ensure -disable-clang-spi flag to propagate to module interface builders 2022-04-02 21:31:00 -07:00
Artem Chikin
b04ae26391 Add support for -enable-regex-literals flag
- Add driver and frontend option
- Add LangOptions entry
- Ensure driver propagates flag to frontends
- Add feature to `features.json`

Part of rdar://91119995
2022-04-01 12:14:28 -07:00
Doug Gregor
5e50ee8560 Add @available attributes on the implicit "extension" for @_nonSendable types
`@_nonSendable` on a type effectively desugars to an unavailable
extension that provides (`@unchecked`) conformance to the `Sendable`
protocol. Make sure we copy over platform availability so that the
extension does not promise greater availability than the type it extends.

Fixes rdar://90330588.
2022-03-25 11:01:44 -07:00
Evan Wilde
aa51bdf17a Add noasync availability kind to available attr
This patch adds the `noasync` availability kind to `@available`. The
spelling is `@available(*, noasync)`.
2022-03-22 15:12:51 -07:00
Allan Shortlidge
59b62c2cc9 NFC: Update tests to include "before: " label in the @_backDeploy attribute. 2022-03-18 11:24:47 -07:00
Slava Pestov
305a1e42b6 RequirementMachine: Update some tests to pass with -requirement-machine-inferred-signatures=verify 2022-03-14 12:33:18 -04:00
Allan Shortlidge
c1e326cbb0 SILGen: Fix SILGen for accessor functions with @_backDeploy. Previously, the @_backDeploy attribute was ignored when generating SIL for accessors on declarations with the attribute since the accessor decls themselves were not directly annotated.
Also, emit an error when `@_backDeploy` is applied to coroutine accessors since they are not supported yet.

Resolves rdar://90112441
2022-03-11 11:07:04 -08:00
Doug Gregor
323238fc79 Merge pull request #41760 from DougGregor/print-sendable-typereprs 2022-03-10 12:56:21 -08:00
Doug Gregor
a6b586ded7 Ensure that we print @Sendable when printing TypeReprs.
Fixes rdar://85453819.
2022-03-09 17:51:36 -08:00
Allan Shortlidge
b29251219a Parse: Add availability macro support to @_backDeploy attribute parsing. Consolidate parsing code shared between @_originallyDefinedIn and @_backDeploy. 2022-03-08 14:13:10 -08:00
Allan Shortlidge
e25b822f7a Merge pull request #41673 from tshortli/inlining-availability-checking
Add -target-min-inlining-version to aid type checking for inlinable functions in resilient libraries
2022-03-07 17:30:59 -08:00
Xi Ge
610a4a5e41 Merge pull request #41692 from nkcsgexi/spi-available 2022-03-06 12:40:20 -08:00
Xi Ge
1395af1c9c test: more module interface tests 2022-03-05 12:00:39 -08:00
Xi Ge
c8ada279d0 test: add a module interface test 2022-03-05 11:25:10 -08:00
Evan Wilde
822097353b Check unavailable from async in interface file
We need to check the feature availability of _unavailableFromAsync
before it gets picked up in the swift interface file. This updates the
compiler to provide the necessary wrappings for that check.
2022-03-04 15:16:03 -08:00
Becca Royal-Gordon
bbcd980aff Add flag for minimum inlining version 2022-03-04 10:54:52 -08:00
Slava Pestov
20ccd05120 AST: Support new primary associated type syntax in the ASTPrinter 2022-03-03 10:15:12 -05:00
Allan Shortlidge
e39c55023f AST: Add support for @_backDeploy on computed properties, subscripts, and accessors. 2022-03-01 13:29:09 -08:00
Allan Shortlidge
da2ae43b4f Sema: Diagnose invalid back deployed declarations. Back deployed declarations must:
- have public visibility
- have at most one back deployment version per-platform
- specify an introduced version for each platform with a back deployment version using @available
- have a back deployment version that is greater than the introduced version
- not have conflicting attributes like @_alwaysEmitIntoClient

Refactor to share code with type checking for @_originallyDefinedIn which has overlapping diagnostics.
2022-02-28 16:00:28 -08:00
Allan Shortlidge
20b454a037 NFC: Flip the OS versions for the @available attribute and the @_backDeploy attribute. Declarations should be marked available starting in the first OS they can be back deployed to and the @_backDeploy attribute should indicate which OS version the declaration first became ABI in. 2022-02-25 17:51:12 -08:00
Allan Shortlidge
9e4ba442a2 Merge pull request #41416 from tshortli/back-deploy-thunk
Emit and call thunks for back deployed functions
2022-02-25 17:49:08 -08:00
Xi Ge
1115332ab9 ModuleInterface: add a frontend flag to skip printing import statement corresponding to a module name.
Related: rdar://63465931
2022-02-24 15:33:26 -08:00
Victoria Mitchell
cab1669e09 only recurse getDisplayDecls in SymbolGraphGen 2022-02-19 10:32:29 -07:00
Allan Shortlidge
123f953e31 NFC: Remove out of date FIXME in back-deploy-attr.swift test. 2022-02-18 16:30:27 -08:00
John McCall
bfffae279c Merge pull request #41399 from rjmccall/suppressible-compatibility-checks
Fix and generalize the printing of suppressible features
2022-02-17 03:26:44 -05:00
Alexis Laferrière
a2d5bae8ac Merge pull request #41372 from apple/disable-win-cache-diag
[ModuleCache] Disable flaky module-cache-diagnostics test on Windows
2022-02-16 14:20:28 -08:00
John McCall
54c38cbb71 Fix and generalize the printing of suppressible features,
and make `@_unsafeInheritExecutor` a suppressible feature.

Some language features are required in order to parse a
declaration correctly, but some can safely be ignored.
For the latter, we'd like the module interface to simply
contain the declaration twice, once with the feature and
once without.  Some basic support for that was already
added for the SpecializeAttributeWithAvailability feature,
but it didn't interact correctly with required features
that might be checked in the same `#if` clause (it simply
introduced an `#else`), and it wasn't really set up to
allow multiple features to be handled this way.  There
were also a few other places that weren't updated to
handle this, presumably because they never coincided
with a `@_specialize` attribute.

Introduce the concept of a suppressible feature, which
is anything that the ASTPrinter can modify the current
PrintOptions in order to suppress.  Restructure the
printing of compatibility checks so that we can print
the body multiple times with different settings.
Print required feature checks in an outer `#if...#endif`,
then perform a separate `#if...#else...#endif` within
if we have suppressible features.  If there are multiple
suppressible features, check for the most recent first,
on the assumption that it will imply the rest; then
perform subsequent checks with an `#elsif` clause.

This should be a far more solid foundation on which to
build compatibility checks in the future.

`@_unsafeInheritExecutor` needs to be suppressible
because it's been added to some rather important
existing APIs.  Simply suppressing the entire decl will
effectively block old tools from using a new SDK to
build many existing projects (if they've adopted
`async`).  Dropping the attribute changes the semantics
of these functions, but only if the compiler features
the SE-0338 scheduling change; this is a very narrow
window of main-branch development builds of the tools,
none of which were officially released.
2022-02-16 16:58:56 -05:00
Allan Shortlidge
70e7e84977 Merge pull request #41348 from tshortli/emit-backdeploy-function-bodies
Emit function bodies for functions annotated with @_backDeploy
2022-02-14 16:19:33 -08:00
Alexis Laferrière
b9eb90b443 [ModuleCache] Disable flaky module-cache-diagnostics test on Windows 2022-02-14 10:28:06 -08:00
Doug Gregor
1b21f13654 Add missing test file 2022-02-11 19:18:47 -08:00
Doug Gregor
0d39a8dd29 Limit inference of Sendable for public, frozen types relying on preconcurrency
When inferring Sendable for a public, frozen type, that Sendable conformance
becomes part of the contract. Therefore, don't infer this conformance
when any of instance storage is implicitly non-Sendable.

Fixes rdar://88652324.
2022-02-11 16:40:01 -08:00
Allan Shortlidge
25b59cb8bc AST: Emit @_backDeploy function bodies into .swiftinterface files.
Resolves rdar://88650341
2022-02-11 14:47:32 -08:00
Allan Shortlidge
ab457959b1 Fix the back-deploy-attr.swift test case by using target-swiftc_driver instead of swiftc_driver. 2022-02-09 09:18:23 -08:00
Allan Shortlidge
2de28dfa75 AST: Use -verify-emitted-module-interface in test case the emits a swiftinterface containing a back-deployed decl. Also leave a FIXME to stop using -merge-modules in the future and fix a diagnostic typo. 2022-02-08 14:04:49 -08:00
Allan Shortlidge
b860e762b2 AST: Introduce the @_backDeploy function attribute:
- Parse the attribute and diagnose parsing issues
- Serialize the attribute
2022-02-08 10:11:04 -08:00
Robert Widmann
25ab410896 Implement (Sugared) Bound Generic Extensions
A scoped-down version of #39307. Implement extension of bound generic types. The important bit here is in TypeCheckGeneric where we now use the underlying type of a typealias and its associated nominal type decl when we're generating substitutions for the extended type.

Put this behind a new experimental flag

-enable-experimental-bound-generic-extensions

Resolves SR-4875
Resolves rdar://17434633
2022-02-02 17:05:23 -08:00
Allan Shortlidge
12102c4181 [Sema] Warn if the @_originallyDefinedIn attribute is applied to a decl that is inaccessible outside the current module.
Resolves rdar://82441657
2022-02-01 16:51:03 -08:00
Allan Shortlidge
49e351f404 Ensure that a module can be compiled successfully from the swiftinterface produced for enums-layout-helper.swift. 2022-01-26 13:57:57 -08:00
Allan Shortlidge
646a3a545f [Sema] Avoid computing raw values for enum cases in swiftinterface files
Raw values of enum cases from another module are not specified in the declaration of the enum unless that enum is `@objc`. This meant that `EnumRawValuesRequest` was computing potentially incorrect raw values when the enum declaration supported it and was emitting incorrect diagnostics for other enum decls.

Resolves SR-14355 and rdar://75451691
2022-01-26 13:43:00 -08:00