Commit Graph

1923 Commits

Author SHA1 Message Date
Robert Widmann
d4b8f1df96 Implement TypeBase::isTypeSequenceParameter
Behaves much like isTypeParameter but specifically checks for the type sequence bits. Also, add the type sequence bits as a recursive type property.
2021-12-16 01:16:45 -08:00
Robert Widmann
746aa1fb58 Model Pack Types
A pack type looks a lot like a tuple in the surface language, except there
is no way for the user to spell a pack. Pack types are created by the solver
when it encounters an apply of a variadic generic function, as in

```
func print<T...>(_ xs: T...) {}
// Creates a pack type <String, Int, String>
print("Macs say Hello in", 42, " different languages")
```

Pack types substituted into the variadic generic arguments of a
PackExpansionType "trip" the pack expansion and cause it to produce a
new pack type with the pack expansion pattern applied.

```
typealias Foo<T...> = (T?...)
Foo<Int, String, Int> // Forces expansion to (Int?, String?, Int?)
```
2021-12-16 00:25:34 -08:00
Alex Hoppen
fe7878ecce [Serialization] Improve module loading performance
When looking for a Swift module on disk, we were scanning all module search paths if they contain the module we are searching for. In a setup where each module is contained in its own framework search path, this scaled quadratically with the number of modules being imported. E.g. a setup with 100 modules being imported form 100 module search paths could cause on the order of 10,000 checks of `FileSystem::exists`. While these checks are fairly fast (~10µs), they add up to ~100ms.

To improve this, perform a first scan of all module search paths and list the files they contain. From this, create a lookup map that maps filenames to the search paths they can be found in. E.g. for
```
searchPath1/
  Module1.framework

searchPath2/
  Module1.framework
  Module2.swiftmodule
```
we create the following lookup table
```
Module1.framework -> [searchPath1, searchPath2]
Module2.swiftmodule -> [searchPath2]
```
2021-12-14 12:44:13 +01:00
Konrad `ktoso` Malawski
cee89ec541 [Distributed] DistributedActorSystem renaming and redesign (#40387)
* [Distributed] towards DistributedActorSystem; synthesize the id earlier, since Identifiable.id

* Fix execute signature to what Pavel is working with

* funcs are ok in sil

* fixed lifetime of id in inits

* fix distributed_actor_deinit

* distributed_actor_local

* update more tests

fixing tests

fix TBD test

fix Serialization/distributed

fix irgen test

Fix null pointer crashes

* prevent issues with null func ptrs and fix Distributed prorotocol test

* fix deinit sil test
2021-12-13 11:29:25 +09:00
Holly Borla
69be7b17fc Merge pull request #40282 from hborla/existential-any
[SE-0335] Introduce existential `any`
2021-12-10 08:56:03 -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
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
Slava Pestov
044611dddc RequirementMachine: Another cycle-breaking hack for associated type inference 2021-12-08 00:53:35 -05:00
Saleem Abdulrasool
910fbee14e gardening: make c++98-compat-extra-semi an error
This cleans up 90 instances of this warning and reduces the build spew
when building on Linux.  This helps identify actual issues when
building which can get lost in the stream of warning messages.  It also
helps restore the ability to build the compiler with gcc.
2021-11-27 11:40:17 -08:00
Slava Pestov
24bdecdca5 AST: Remove ASTContext::getOrCreateRequirementMachine() in favor of getRewriteContext() 2021-11-11 22:39:20 -05:00
Robert Widmann
658de80ca8 Merge pull request #39627 from CodaFi/the-replacements
Suggest Replacement Types for Invalid Placeholders
2021-11-10 16:23:29 -08:00
Ellie Shin
a24d74bbef Merge pull request #40102 from apple/es-param
[NFC] Add module alias lookup option enum / use the option to look up in ASTContext::getRealModuleName
2021-11-09 13:39:29 -08:00
Ellie Shin
89fb5ff3fc Merge branch 'main' into es-param 2021-11-08 17:55:25 -08:00
Ellie Shin
06683cda43 Add module alias lookup option enum
Pass the enum param to ASTContext::getRealModuleName
2021-11-08 17:51:27 -08:00
Robert Widmann
22405cefea Plumb the "Is Type Sequence" Bit Through the Surface AST 2021-11-08 13:48:30 -08:00
Kavon Farvardin
49b0e25fa5 fix the isolation of the self param in ctors and dtors
The isolation of `self` was missing on its ParamDecl of ctors
of an actor, leading to situations where closures that should
inherit the isolation of the ctor, not actually inheriting it
because they only inspect the ParamDecl.

This patch makes it so that both inits and deinits also
get their `self` isolation by making a query in the
type checker.

resolves rdar://84682865
2021-11-04 19:04:13 -07:00
Robert Widmann
1fe2e4b3e7 Relax Restrictions on Placeholder Types Appearing in Interface Types
These restrictions are meant to keep placeholder types from escaping TypeCheckType. But there's really no harm in that happening as long as we diagnose it on the way out in the places it's banned. (We also need to make sure we're only diagnosing things in primaries, but that's a minor issue). The end result is that we lose information because a lot of the AST that has placeholders in it becomes filled with error types instead.

Lift the restriction on placeholders appearing in the interface type, teach the mangler to treat them as unresolved types, and teach serialization to treat them as error types.
2021-11-03 10:29:15 -07:00
Pavel Yaskevich
09f160aabf Merge pull request #40001 from salinas-miguel/cf-cgfloat
Allow CoreFoundation to declare CGFloat
2021-11-02 13:44:49 -07:00
Ellie Shin
b294fe94f2 Merge pull request #39929 from apple/es-src
Module Aliasing: do not allow module real names to appear in source files (only allow module aliases).
Resolves rdar://83592084
2021-11-01 17:50:49 -07:00
Miguel Salinas
055edaf0df allow CoreFoundation to declare CGFloat 2021-11-01 16:08:34 -07:00
Slava Pestov
0d167a435c AST: Move GenericSignatureBuilder.h from include/swift/AST/ to lib/AST/ 2021-10-30 00:35:59 -04:00
Slava Pestov
f38f25a3de AST: Factor out AbstractGenericSignatureRequest into a new buildGenericSignature() function
This is slightly cleaner.
2021-10-30 00:35:59 -04:00
Ellie Shin
66d64b610d Updates params to ASTContext::getRealModuleName 2021-10-29 01:52:33 -07:00
elsh
daf07c0306 Update getRealModuleName
Assert map is empty in setModuleAliases
Update doc comments
2021-10-28 23:43:16 -07:00
elsh
10a96dff57 Module Aliasing: do not allow module real names to appear in source files / only allow aliases
Resolves rdar://83592084
2021-10-28 02:36:59 -07:00
Mishal Shah
c2fd49cebb Merge pull request #39473 from apple/rebranch
Update swift:main to support llvm-project:stable/20210726 changes (Rebranch merge)
2021-10-11 09:00:51 -07:00
elsh
daa335c42f Merge pull request #39533 from apple/es-mod3
[Module Aliasing] Modify module loaders to use module 'real name' (physical name on-disk) when loading, since it can be different from 'name' if module aliasing is used. Also use the 'real name' to add/retrieve loaded modules in ASTContext. Resolves rdar://83591943.
2021-10-06 22:19:37 -07:00
Slava Pestov
2335116aee Merge pull request #39606 from slavapestov/rqm-requirement-signature-minimization
RequirementMachine: More progress toward computing protocol requirement signatures
2021-10-06 13:19:08 -04:00
swift-ci
3f8fea8508 Merge remote-tracking branch 'origin/main' into rebranch 2021-10-06 10:17:29 -07:00
Slava Pestov
c3270742dc RequirementMachine: Compute strongly connected components from the protocol dependency graph 2021-10-05 21:30:57 -04:00
elsh
55b9fa11d8 Load modules using real names if module aliases are used
rdar://83591943
2021-10-05 10:55:22 -07:00
Meghana Gupta
f458d9b490 Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag (#39516)
* Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag

This includes a bit in the module format to represent if the module was
compiled with -enable-ossa-modules flag. When compiling a client module
with -enable-ossa-modules flag, all dependent modules are checked for this bit,
if not on, recompilation is triggered with -enable-ossa-modules.

* Updated tests
2021-10-04 18:46:40 -07:00
swift-ci
c51550f30e Merge remote-tracking branch 'origin/main' into rebranch 2021-09-30 15:11:41 -07:00
elsh
6b4951e31e Rename lookupModuleAlias to getRealModuleName 2021-09-30 13:29:02 -07:00
elsh
fc420d04e2 Modify setModuleAliases and lookup
Add examples to documentation comment
2021-09-29 16:40:22 -07:00
elsh
0e05d10308 Add module alias map and lookup func to ASTContext
Set module underlying name in ModuleDecl if a module alias exists
rdar://83682112
2021-09-29 16:40:22 -07:00
Slava Pestov
47ab4a9f28 AST: GenericSignatures point directly to their RequirementMachine
This avoids a hashtable lookup when performing queries.
2021-09-27 21:36:45 -04:00
swift-ci
d12197f488 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-21 08:33:46 -07:00
Artem Chikin
131a081699 Merge pull request #39326 from artemcm/MultiTargetScan
[Dependency Scanning] Make dependency scanner cache specific to a given target triple.
2021-09-21 08:16:40 -07:00
swift-ci
8fba532a11 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-20 18:33:34 -07:00
Robert Widmann
980fde2ede Lift requirementsNotSatisfiedBy Into GenericSignature 2021-09-20 15:29:51 -07:00
Artem Chikin
e64a40451b [Dependency Scanning] Model main module as separate dependency kind: SwiftSource
These kinds of modules differ from `SwiftTextual` modules in that they do not have an interface and have source-files.
It is cleaner to enforce this distinction with types, instead of checking for interface optionality everywhere.
2021-09-15 09:31:20 -07:00
swift-ci
b56685ee37 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-10 13:35:21 -07:00
Hamish Knight
cab39bf26c [CS] Formalize param flag handling for imploding params
By default avoid imploding params that have parameter
flags, but carve out exceptions for ownership flags,
which can be thunked, and `@_nonEphemeral` which can
be freely dropped without issue.
2021-09-09 21:46:31 +01:00
Hamish Knight
af14bba276 [AST] Simplify AnyFunctionType::composeTuple
Remove the canonicalVararg parameter and
CanParamArrayRef wrapper. Almost none of the
callers want canonicalVararg, and the one that
does calls `getCanonicalType` on the result
anyway.
2021-09-09 21:46:31 +01:00
swift-ci
cb32b553de Merge remote-tracking branch 'origin/main' into rebranch 2021-09-04 11:32:57 -07:00
Hamish Knight
01a082a058 [AST] Adopt ArgumentList
Switch out the representation of argument lists
in various AST nodes with ArgumentList.
2021-09-01 18:40:23 +01:00
swift-ci
c6178125d9 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-25 20:33:27 -07:00
Konrad `ktoso` Malawski
7c1ed4069e [Distributed] the distributed module may not be available 2021-08-26 09:46:13 +09:00
swift-ci
a18dcf3511 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-24 11:34:00 -07:00