Commit Graph

2129 Commits

Author SHA1 Message Date
Kavon Farvardin
81ea9981c8 Merge pull request #69842 from kavon/ncgenerics-stdlib-building
[NCGenerics] more work towards getting the stdlib building
2023-11-29 17:31:45 -08:00
Meghana Gupta
fd588ab509 Remove SelfAccessKind::ResultDependsOnSelf 2023-11-29 12:11:57 -08:00
Zhiyu Zhu/朱智语
9d1a92eb72 [Compile Time Constant Extraction] Add @extractConstantsFromMembers (#69944)
Add @extractConstantsFromMembers attribute under ExtractConstantsFromMembers experimental feature flag
2023-11-29 08:49:57 -08:00
Holly Borla
7cb9880b04 [Features] Gate SE-0383 behind an upcoming feature flag. 2023-11-29 07:35:37 -08:00
Doug Gregor
0eb71d1c03 Merge pull request #70034 from DougGregor/function-body-macros
Function body macros
2023-11-28 09:43:40 -08:00
Alejandro Alonso
e214ba5092 Merge pull request #69735 from Azoy/static-exclusive-only
Introduce @_staticExclusiveOnly
2023-11-27 21:24:56 -08:00
Doug Gregor
36a2dcd927 Implement function body macros
Function body macros allow one to introduce a function body for a
particular function, either providing a body for a function that
doesn't have one, or wholesale replacing the body of a function that
was written with a new one.
2023-11-27 17:04:55 -08:00
Alejandro Alonso
7da7c73c71 Introduce @_staticExclusiveOnly 2023-11-27 09:11:13 -08:00
Allan Shortlidge
8999ed3e3f AST: Desugar typed patterns in swiftinterfaces consistently.
To match the swiftinterfaces that are emitted for eagerly typechecked ASTs,
lazily trigger initializer expression typechecking for typed patterns that were
written using a typealias.

Resolves rdar://118698233
2023-11-26 09:59:24 -08:00
Kavon Farvardin
9da000fc32 [nfc] localize getAnyTypeDecl
After review, Slava and I decided it's not a good idea to provide a
`TypeBase::getAnyTypeDecl` method, as it is not typically what people
generally should use, as it doesn't handle all cases (type parameters
with no associated decl, for example).
2023-11-16 15:27:00 -08:00
Kavon Farvardin
2cd298926f [NCGenerics] fix existential conformances
I was not expanding default requirements in
AbstractGenericSignatureRequest or ExistentialLayout.

Also fixes printing of composition types.
2023-11-15 15:43:11 -08:00
Ellie Shin
e8d43434db Merge pull request #69733 from apple/es-pkg-intf
Introduce a package interface
2023-11-15 03:53:49 -08:00
Kavon Farvardin
1797c4cd89 [NoncopyableGenerics] fix swiftinterface 2023-11-14 10:21:58 -08:00
Rintaro Ishizaki
b3991732c7 Merge pull request #69761 from rintaro/astgen-incremental-develop
[ASTGen] Infrastructure for implementing ASTGen incrementally
2023-11-13 14:10:28 -08:00
Ellie Shin
9d716394b1 Add an interface mode getter/setter in PrintOptions and ModuleInterfaceOptions
Update args parsing
2023-11-13 13:48:07 -08:00
Rintaro Ishizaki
f3f4b19776 [ASTGen] Remove ASTGenTypes experimental feature
There's no reason to generate only TypeRepr using ASTGen anymore.
Use ParserASTGen feature to test test/ASTGen/types.swift because
ASTGen now can generate the whole test file for type checking.
2023-11-12 21:43:09 -08:00
Allan Shortlidge
ad9715761b AST: Compute actor isolation when expanding semantic attributes.
Declarations may have semantic actor isolation requirements that were not
written in source. For example, the default implementation of a protocol
requirement must be `@MainActor` isolated if the protocol declaration itself is
`@MainActor` isolated. When computing the semantic attributes of a declaration
lazily, we must compute the actor isolation of the declaration to ensure that
any global actor constraint attributes are added.

Also, avoid request cycles and recursive diagnostic printing by only triggering
the computation of semantic attributes when printing for swiftinterfaces.

Resolves rdar://118277555
2023-11-11 14:24:52 -08:00
Ellie Shin
e5ca8e5c0b Allow loading package interface if in same package.
Add a new flag to enable package interface loading.
Use the last value of package-name in case of dupes.
Rename PrintInterfaceContentMode as InterfaceMode.
Update diagnostics.
Test package interface loading with various scenarios.
Test duplicate package-name.
2023-11-09 18:44:06 -08:00
Ellie Shin
aba3b6c24e Introduce a package interface.
It has an extension .package.swiftinterface and contains package decls
as well as SPIs and public/inlinable decls. When a module is loaded
from interface, it now looks up the package-name in the interface
and checks if the importer is in the same package. If so, it uses
that package interface found to load the module. If not, uses the existing
logic to load modules.

Resolves rdar://104617854
2023-11-08 14:56:20 -08:00
Meghana Gupta
5658deae27 Add initial support for _resultDependsOnSelf
This is used to establish lifetime dependence between self and the result.

Add under NonEscapableTypes experimental feature
2023-11-08 01:48:59 -08:00
Kavon Farvardin
ab6734aa04 Merge pull request #69590 from kavon/check-if-copyable-inferred
[NoncopyableGenerics] Synthesize conditional conformances
2023-11-07 18:19:23 -08:00
Angela Laar
eb277d9ee7 Merge pull request #67498 from angela-laar/implicit-sendable-for-methods
[Sema] Implicitly add @Sendable attribute to partial methods
2023-11-07 16:46:16 -08:00
Angela Laar
c09ec72e85 [Constraint System] Always add Sendable to unapplied function applications 2023-11-07 13:37:24 -08:00
Kavon Farvardin
a9c64baaa3 [Sema] refactor TypeDecl::isNoncopyable
In preparation for reporting whether the inverse marking on a TypeDecl
was inferred instead of explicit.
2023-11-06 15:40:12 -08:00
Allan Shortlidge
e05dbb696d AST: Trigger IsFinalRequest when retrieving semantic attributes.
ASTPrinter already had special logic to handle ensuring that `final` is printed
when necessary, but we can remove that logic and instead ensure that
`IsFinalRequest` runs as part of computing semantic attributes before printing.
2023-11-02 17:50:51 -07:00
Allan Shortlidge
f4ed2696d3 AST: Print attributes using getSemanticAttrs(). 2023-11-01 10:44:29 -07:00
Kavon Farvardin
29acda5136 Merge pull request #69406 from kavon/noncopyable-generics-pt2
[NoncopyableGenerics] handle `~Copyable` in `where`, `some`, and compositions.
2023-10-28 22:36:22 -07:00
Michael Gottesman
cb46851194 [region-isolation] Rename the experimental feature to RegionBasedIsolation.
This ensures that the pass is called TransferNonSendable but the experimental
feature is RegionBasedIsolation.
2023-10-26 12:01:44 -07:00
Michael Gottesman
0bad8f9b67 [region-isolation] Rename SendNonSendable.cpp -> TransferNonSendable.cpp. 2023-10-26 12:01:44 -07:00
Angela Laar
34ca702031 [Frontend] Feature flag for InferredSendableMethods 2023-10-25 12:30:24 -07:00
Rintaro Ishizaki
03bf349778 [Macros] Improve visitation of auxiliary decls
Use the same pattern as 'getAllMembers()'. This supports nested macro
expansion:
```
std::function<void(Decl *)> visit;
visit = [&](Decl *d) {
  doIt(d);
  d->visitAuxiliaryDecls(visit);
};
for (auto *d : decls)
  visit(d);
```

Don't visit auxiliary decls in `PrintAST::visit(Decl *)` this function
is only intended for single decl printing. The caller should visit them
separately. For that, add
`ModuleDecl::getTopLevelDeclsWithAuxiliaryDecls()`
2023-10-23 14:51:12 -07:00
Yuta Saito
4f0e3bf3ea Merge pull request #69207 from kateinoigakukun/yt/cdecl-without-body
Introduce `@extern(c)` to declare C function without Clang module
2023-10-23 12:48:12 -07:00
Kavon Farvardin
66712ce6e0 [Sema] introduce InverseType
This type will become the corresponding type that is resolved for an
`InverseTypeRepr`. This kind of type is not expected to appear past type
 checking (currently, not even past requirement lowering!).
2023-10-23 10:37:22 -07:00
Harlan Haskins
4ac34a40ea @retroactive conformance syntax and checking (#36068) 2023-10-20 14:27:03 -07:00
Yuta Saito
03ed46aa74 [c-interop] Gate @_extern behind experimental feature flag 2023-10-20 17:04:36 +00:00
Kavon Farvardin
148897ac1a [nfc] refactor ValueDecl::isMoveOnly
I've renamed the method to `TypeDecl::isNoncopyable`, because the query
doesn't make sense for many other kinds of `ValueDecl`'s beyond the
`TypeDecl`'s. In fact, it looks like no one was relying on that anyway.

Thus, we now have a distinction where in Sema, you ask whether
a `Type` or `TypeDecl` is "Noncopyable". But within SIL, we still
preserve the notion of "move-only" since there is additionally the
move-only type wrapper for types that otherwise support copying.
2023-10-18 13:45:50 -07:00
Andrew Trick
681a2b72e0 Merge pull request #69164 from atrick/nonescapable_attr
Add a temporary @_nonEscapable and @_hasUnsafeNonEscapableResult attribute
2023-10-17 21:39:10 -07:00
Alexis Laferrière
64cd96e629 Merge pull request #69210 from xymus/export-as-module-interface-by-default
ModuleInterface: Always ignore export-as for printing references in private swiftinterfaces
2023-10-17 16:41:37 -07:00
Andrew Trick
1f521cd7f1 Add -experimental-feature NonEscapableTypes 2023-10-17 12:45:00 -07:00
Doug Gregor
083333f17f [Typed throws] Add upcoming feature FullTypedThrows
Introduce the upcoming feature `FullTypedThrows`. When enabled, infer
the error type of a `throw` statement based on its original type,
instead of always being `any Error`. This is technically a
source-breaking change, hence the upcoming feature flag.
2023-10-16 23:14:41 -07:00
Alexis Laferrière
6f1a774e7d [ModuleInterface] Always ignore export-as in private swiftinterfaces
Always print the real module name for references in private
swiftinterfaces, ignoring export-as declarations. Keep using the
export-as name for the public swiftinterface only.

The flag `ModuleInterfaceExportAs` used to enable this behavior and
we're removing it to make it the default.

rdar://115922907
2023-10-16 13:19:55 -07:00
Arnold Schwaighofer
0a5cb1e93f Merge pull request #69160 from aschwaighofer/wip_partial_sil_support_for_generic_throws
Preliminary SIL and IRGen support for error_indirect
2023-10-13 09:34:44 -07:00
Arnold Schwaighofer
9482b0c86b Preliminary SIL and IRGen support for error_indirect
IRGen lowering of non-fixed-sized typed errors and the SIL support necessary to
spell out IRGen test cases.
2023-10-12 18:09:52 -07:00
Alexis Laferrière
322ada60c8 [Sema] Intro flag to default imports to internal, the Swift 6 mode
The feature InternalImportsByDefault makes imports default to internal instead
of public. Applying the Swift 6 behavior of SE-0409 in Swift 5.

Let's use only that flag to track the Swift 6 behavior as well instead
of separately checking for the language version.
2023-10-10 09:09:21 -07:00
Hamish Knight
042ccdda01 Merge pull request #68344 from hamishknight/do-it 2023-10-10 10:26:12 +01:00
Holly Borla
5a81c00b3e [Concurrency] Rename IsolatedDefaultArguments to IsolatedDefaultValues. 2023-10-06 16:59:41 -07:00
Hamish Knight
33f94bc874 Introduce do expressions 2023-10-06 11:17:48 +01:00
Holly Borla
95a7107872 [Concurrency] Allow default arguments to require actor isolation.
Type checking a default argument expression will compute the required
actor isolation for evaluating that argument value synchronously. Actor
isolation checking is deferred to the caller; it is an error to use a
default argument from across isolation domains.

Currently gated behind -enable-experimental-feature IsolatedDefaultArguments.
2023-10-04 13:12:11 -07:00
Joe Groff
b4f536927a Disable destructuring initializations in struct let stored properties.
This looks like it was never properly implemented, since when we generate the
memberwise initializer for the struct in SILGen, it incorrectly tries to apply
the entire initializer expression to each variable binding in the pattern,
rather than destructuring the result and pattern-matching it to the variables.
Since it never worked it doesn't look like anyone is using this, so let's
put up an error saying it's unsupported until we can implement it properly.
Add `StructLetDestructuring` as an experimental feature flag so that tests around
the feature for things like module interface printing can still work.
2023-10-03 13:24:39 -07:00
Doug Gregor
51eed19d4b [Typed throws] Type system support for typed throws.
Add the thrown type into the AST representation of function types,
mapping from function type representations and declarations into the
appropriate thrown type. Add tests for serialization, printing, and
basic equivalence of function types that have thrown errors.
2023-09-29 10:51:53 -07:00