Commit Graph

3155 Commits

Author SHA1 Message Date
swift_jenkins
b2a4e23ee4 Merge remote-tracking branch 'origin/main' into next 2022-02-03 09:20:54 -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
swift_jenkins
25d065710a Merge remote-tracking branch 'origin/main' into next 2022-02-01 23:00:52 -08:00
eeckstein
00b795fe11 Merge pull request #41120 from eeckstein/capture-propagate-keypaths
CapturePropagation: specialize closures which capture a constant keypath
2022-02-02 07:54:47 +01:00
swift_jenkins
bbc6b657b3 Merge remote-tracking branch 'origin/main' into next 2022-02-01 20:20:30 -08:00
Anthony Latsis
c7fd60f2dd Merge pull request #39492 from AnthonyLatsis/se-309-2
SE-309: Covariant erasure for dependent member types
2022-02-02 07:07:17 +03:00
swift_jenkins
b8bfff76f5 Merge remote-tracking branch 'origin/main' into next 2022-02-01 18:20:28 -08:00
Artem Chikin
b4926dffe7 Merge pull request #41027 from artemcm/AddConformanceMetadataReader
Add extraction of protocol conformance descriptor info, as read from an object file image, to `TypeRefBuilder`.
2022-02-01 18:05:48 -08:00
Nuri Amari
7ec861fbd9 Enable lazy ClangImporter diagnostics by default
Replace the existing `-enable-experimental-clang-importer-diagnostics`
flag with an opt-out version entitled `-disable-experimentalc-clang-importer-diagnostics`.
Enable the beviour previously hidden behind the old flag by default.
2022-02-01 18:43:49 -05:00
Anthony Latsis
b2fe028885 [NFC] Turn SelfReferenceKind into a standalone utility type 2022-02-01 20:55:47 +03:00
Erik Eckstein
fb8ee0edff extract the MD5Stream utility from IRGen to its own header file. 2022-02-01 08:13:27 +01:00
swift_jenkins
37fa23a66d Merge remote-tracking branch 'origin/main' into next 2022-01-31 02:00:49 -08:00
Anthony Latsis
8e4ea9b01a [NFC] DiagnosticVerifier: Move 'getColumnNumber' into SourceManager 2022-01-31 05:04:09 +03:00
swift_jenkins
1ebb9f0f3c Merge remote-tracking branch 'origin/main' into next 2022-01-28 08:20:51 -08:00
Slava Pestov
877fb2b841 Merge pull request #41043 from slavapestov/rqm-concrete-conformance-minimization-fixes
RequirementMachine: Fix some bugs with concrete conformance minimization
2022-01-28 11:07:58 -05:00
Slava Pestov
33baf77506 RequirementMachine: Bump default -requirement-machine-depth-limit from 10 to 12 2022-01-27 18:54:03 -05:00
swift_jenkins
829b02f2ad Merge remote-tracking branch 'origin/main' into next 2022-01-27 14:00:53 -08:00
Becca Royal-Gordon
1275e626be Merge pull request #41035 from beccadax/dont-take-this-literally
Don't import string macros with invalid UTF-8
2022-01-27 13:56:28 -08:00
swift_jenkins
ef4921f907 Merge remote-tracking branch 'origin/main' into next 2022-01-27 09:20:54 -08:00
Becca Royal-Gordon
4bd532ab9a Don't import string macros with invalid UTF-8
Swift string literals are only permitted to contain well-formed UTF-8, but C does not share this restriction, and ClangImporter wasn't checking for that before it created `StringLiteralExpr`s for imported macros; this could cause crashes when importing a header. This commit makes us drop these macros instead.

Although invalid UTF-8 always *did* cause a segfault in my testing, I'm not convinced that there isn't a way to cause a miscompile with a bug like this. If we somehow did generate code that fed ill-formed UTF-8 to the builtin literal init for Swift.String, the resulting string could cause undefined behavior at runtime. So I have additionally added a defensive assertion to StringLiteralInst that any UTF-8 string represented in SIL is well-formed. Hopefully that will catch any non-crashing compiler bugs like this one.

Fixes rdar://67840900.
2022-01-26 20:57:13 -08:00
Doug Gregor
11a027714d Add frontend flag -enable-experimental-opaque-parameters 2022-01-26 14:47:12 -08:00
Artem Chikin
e934fe201a Add extraction protocol conformance descriptor extraction, as read from an object file image, to TypeRefBuilder. 2022-01-26 13:54:02 -08:00
swift_jenkins
2a62be7be6 Merge remote-tracking branch 'origin/main' into next 2022-01-26 09:07:01 -08:00
Slava Pestov
7dc36c3092 Merge pull request #40714 from slavapestov/parametrized-protocol-type
Parametrized protocol types
2022-01-26 11:44:29 -05:00
swift_jenkins
6b548f2168 Merge remote-tracking branch 'origin/main' into next 2022-01-26 07:03:21 -08:00
Doug Gregor
c7a5049a28 Separate the C++ and Objective-C generated header output types.
Otherwise, when an output file map is provided, we'll use the same
path for both. Fixes rdar://87987062.
2022-01-25 22:53:03 -08:00
Slava Pestov
327a508648 Frontend: Add -enable-parametrized-protocol-types flag 2022-01-25 22:02:59 -05:00
swift_jenkins
6b2d363b8f Merge remote-tracking branch 'origin/main' into next 2022-01-25 15:02:01 -08:00
Slava Pestov
e24031012f RequirementMachine: Disable merged associated types by default
This feature allows the following construct to work:

    protocol P1 {
      associatedtype T : P1
    }

    protocol P2 {
      associatedtype T : P2
    }

    func foo<T : P1 & P2>(_: T) {}

However, I haven't figured out how to make it work with rewrite system
minimization, so it's already disabled when you use the requirement
machine for protocol or generic signature minimization. In addition to
that it adds some complexity.

I haven't found any real-world uses of this pattern yet, so I'm going
to try to turn it off, and if nobody complains, remove the support
altogether.

If people do complain, we'll have to figure out how to make it work with
minimization.
2022-01-25 11:38:50 -05:00
swift_jenkins
4a587324c8 Merge remote-tracking branch 'origin/main' into next 2022-01-21 13:41:14 -08:00
Evan Wilde
794d0e0b9a Merge pull request #40832 from etcwilde/ewilde/async-top-level
A first pass at concurrency in top-level code
2022-01-21 13:24:51 -08:00
swift_jenkins
e77d4a0400 Merge remote-tracking branch 'origin/main' into next 2022-01-20 21:21:27 -08:00
Xi Ge
a448cddb17 Merge pull request #40941 from nkcsgexi/87840268
ModuleInterface: pass-down paths obfuscators to module interface building commands
2022-01-20 21:06:52 -08:00
Xi Ge
53d46841d4 ModuleInterface: pass-down paths obfuscator to module interface building commands
While implicitly building .swiftinterface, the interface may import other binary modules.
These binary modules may contain serialized search paths that have been obfuscated. To help
interface building commands recover these search paths, we need to pass down the obfuscators
to the module building commands.

rdar://87840268
2022-01-20 14:48:55 -08:00
swift_jenkins
b1d58e1d21 Merge remote-tracking branch 'origin/main' into next 2022-01-20 14:41:30 -08:00
Alejandro Alonso
e5d4712829 Merge branch 'main' into new-next 2022-01-20 11:13:22 -08:00
Alex Lorenz
7aa1cd166e Fix comment typos related to printAsCXX 2022-01-20 11:04:21 -08:00
Alex Lorenz
e0eec4dd7c Merge pull request #40923 from hyp/emit-cxx-interface-option
[interop] add an option to emit C++ header interface for a module
2022-01-20 07:16:53 -08:00
Mishal Shah
0bf1389863 Merge pull request #40907 from apple/rebranch
Update swift:main to support llvm-project:stable/20211026 changes (Rebranch merge)
2022-01-19 23:36:38 -08:00
Alex Lorenz
6486c3c1d8 [interop] add an option to emit C++ header interface for a module 2022-01-19 18:55:14 -08:00
swift_jenkins
adefc049d9 Merge remote-tracking branch 'origin/main' into next 2022-01-19 17:20:43 -08:00
Richard Wei
59ad670c0c Merge pull request #40799 from rxwei/pairwise-buildblock
[ResultBuilders] `buildBlock(combining:into:)` for pairwise combination.
2022-01-19 17:11:38 -08:00
Richard Wei
b6e679f22c [ResultBuilders] buildBlock(combining:into:) for pairwise combination.
Allow a user-defined `buildBlock(combining:into:)` to combine subexpressions in a block pairwise top to bottom. To use `buildBlock(_combining:into:)`, the user also needs to provide a unary `buildBlock(_:)` as a base case. The feature is being gated under frontend flag `-enable-experimental-pairwise-build-block`.

This will enable use cases in `RegexBuilder` in experimental declarative string processing, where we need to concatenate tuples and conditionally skip captureless regexes.  For example:

```swift
let regex = Regex {
  "a" // Regex<Substring>
  OneOrMore("b").capture() // Regex<(Substring, Substring)>
  "c" // Regex<Substring>
  Optionally("d".capture()) // Regex<(Substring, Substring?)>
} // Regex<Tuple3<Substring, Substring, Substring?>>
let result = "abc".firstMatch(of: regex)
// MatchResult<(Substring, Substring, Substring?)>
```

In this example, patterns `"a"` and `"c"` have no captures, so we need to skip them. However with the existing result builder `buildBlock()` feature that builds a block wholesale from all subexpressions, we had to generate `2^arity` overloads accounting for any occurrences of captureless regexes. There are also other complexities such as having to drop-first from the tuple to obtain the capture type. Though these features could in theory be supported via variadic generics, we feel that allowing result builders to pairwise combine subexpressions in a block is a much simpler and potentially more useful approach.

With `buildBlock(_combining:into:)`, the regex builders can be defined as the following, assuming we have variadic generics:

```swift
enum RegexBuilder {
  static func buildBlock() -> Regex<Substring>
  static func buildBlock<Match>(_ x: Regex<Match>) -> Regex<Match>
  static func buildBlock<
    ExistingWholeMatch, NewWholeMatch, ExistingCaptures..., NewCaptures...
  >(
    _combining next: Regex<(NewWholeMatch, NewCaptures...)>,
    into combined: Regex<(ExistingWholeMatch,  ExistingCaptures...)>
  ) -> Regex<Substring, ExistingCaptures..., NewCaptures...>
}
```

Before we have variadic generics, we can define overloads of `buildBlock(_combining:into:)` for up to a certain arity. These overloads will be much fewer than `2^arity`.
2022-01-18 05:14:08 -08:00
swift-ci
513183633e Merge remote-tracking branch 'origin/main' into rebranch 2022-01-14 16:53:12 -08:00
swift_jenkins
01ca637ef9 Merge remote-tracking branch 'origin/main' into next 2022-01-14 16:40:57 -08:00
Holly Borla
ee331a8c01 [Type System] Enable explicit existential types. 2022-01-13 19:31:35 -08:00
swift-ci
aa984841d2 Merge remote-tracking branch 'origin/main' into rebranch 2022-01-12 14:13:54 -08:00
swift_jenkins
926e3a14bc Merge remote-tracking branch 'origin/main' into next 2022-01-12 14:13:30 -08:00
Slava Pestov
3a92d2fc53 AST: Remove legacy GSB-based GenericSignature query implementation 2022-01-12 12:33:34 -05:00
Evan Wilde
130f5caf48 Add experimental-async-top-level flag
Protect this feature behind a feature flag until it's ready for
prime-time.
2022-01-11 11:04:43 -08:00