Commit Graph

7859 Commits

Author SHA1 Message Date
Slava Pestov
991a6de207 Merge pull request #71131 from slavapestov/conformance-checker-vs-type-witnesses-untangling
Sema: Decouple type witness resolution from the ConformanceChecker
2024-01-25 20:06:01 -05:00
Pavel Yaskevich
609eaf762e Merge pull request #71146 from xedin/disable-one-swiftui-test
[Tests] NFC: Remove one of SwiftUI test-cases because its overly SDK …
2024-01-25 08:54:20 -08:00
Pavel Yaskevich
da14b97875 [Tests] NFC: Remove one of SwiftUI test-cases because its overly SDK sensitive 2024-01-24 21:15:14 -08:00
Slava Pestov
2764333fea Sema: Introduce ResolveTypeWitnessesRequest 2024-01-24 21:45:34 -05:00
Kavon Farvardin
ba2f05cce2 NCGenerics: adjust number of diagnostics
Something I changed in the implementation of NoncopyableGenerics has
gotten the number back down to 6, where it was before I started :)
2024-01-23 22:42:38 -08:00
Kavon Farvardin
b92fe5f2e9 [build-script] fix NoncopyableGenerics option
This patch introduces `--enable-experimental-noncopyable-generics` for
the build script. It replaces
`--swift-stdlib-experimental-noncopyable-generics`

The old build option only enables the feature when building the
stdlib, but if we've built the stdlib with NoncopyableGenerics, the
compiler should be hardwired to have that feature enabled, too.

This patch also introduces the `noncopyable_generics` lit parameter, so
that tests assuming the system was built with the feature can live
in-tree and be tested, if they specify `REQUIRES: noncopyable_generics`.
2024-01-23 22:41:59 -08:00
Alex Hoppen
5001980d40 Merge pull request #71054 from ahoppen/ahoppen/argument-completion
[CodeComplete] Suggest single argument labels if code completion is invoked at start of function call with exiting parameters
2024-01-22 17:19:50 -08:00
Holly Borla
d60a06760b Merge pull request #71050 from hborla/global-actor-unsafe
[Concurrency] Deprecate `@GlobalActor(unsafe)` in favor of `@preconcurrency @GlobalActor`
2024-01-22 16:52:56 -08:00
Pavel Yaskevich
be39c05df2 Merge pull request #71026 from xedin/rdar-111120803
[CSSimplify] Increase impact of requirement failures in special result builder methods
2024-01-22 13:10:59 -08:00
Alex Hoppen
695e69e09e [CodeComplete] Suggest single argument labels if code completion is invoked at start of function call with exiting parameters
This removes the distinction between argument completions and postfix expr paren completions, which was meaningless since solver-based completion.

It then determines whether to suggest the entire function call pattern (with all argument labels) or only a single argument based on whether there are any existing arguments in the call.

For this to work properly, we need to improve parser recovery a little bit so that it parsers arguments after the code completion token properly.

This should make call pattern heuristics obsolete.

rdar://84809503
2024-01-22 12:21:04 -08:00
Holly Borla
2a18edc178 [NFC][Concurrency] Update validation tests for @MainActor(unsafe) changes. 2024-01-22 08:43:27 -08:00
Slava Pestov
24814c5e9d Merge pull request #71041 from slavapestov/refactor-conformance-checker-diagnostics
Refactor conformance checker diagnostics
2024-01-21 11:14:47 -05:00
Slava Pestov
0b0ad738dd AST: Record a HadError bit in DelayedConformanceDiags 2024-01-20 19:16:58 -05:00
Holly Borla
a1a975f528 Merge pull request #71002 from hborla/preconcurrency-downgrade-take-two
[Concurrency] Set `preconcurrency` for actor isolation created from unsafe global actor attributes.
2024-01-19 15:39:52 -08:00
Pavel Yaskevich
b3152d8bc0 [CSSimplify] Increase impact of requirement failures in special result builder methods
Handle requirement failures in result builder `build*` methods explicitly
and give them a high impact rating because issues if such positions
imply that the transform didn't work and it shouldn't shadow errors
in user code.

Resolves: rdar://111120803
Resolves: rdar://120342129
2024-01-19 15:11:41 -08:00
Holly Borla
79593411d9 [Concurrency] Set preconcurrency for actor isolation created from unsafe global
actor attributes.
2024-01-19 09:29:13 -08:00
Allan Shortlidge
07a67437be Merge pull request #64656 from artemcm/LegacyDeathBed
Deprecate Legacy driver by removing incremental builds and adding warnings
2024-01-18 08:55:59 -08:00
Allan Shortlidge
8d1b578275 [Regex] Really build _RegexParser without resilience.
This was originally attempted with https://github.com/apple/swift/pull/58810
but `_RegexParser` still ended up being built with library evolution enabled
because the `-enable-library-evolution` flag is added to the command line after
calling `add_swift_target_library` and therefore stripping the flag out of
`SWIFT_COMPILE_FLAGS` does nothing.

The `IS_FRAGILE` flag was introduced to support building C++ interop overlay
modules without library evolution and it can now be used to prevent
`_RegexParser` from being built with library evolution.

Resolves rdar://93067204
2024-01-17 08:03:54 -08:00
Artem Chikin
73b01dccfc Remove incremental builds from the Legacy driver
The C++-based driver is deprecated and this will help reduce the code surface that requires maintenance as the legacy driver is fully sunset.
2024-01-16 16:34:51 -08:00
Alex Hoppen
09ae4f5d5d [CodeCompletion] Fix issue in which parts of a result builder were incorrectly skipped
`getLoc` does not necesarrily return the start location of the location (e.g. for `a.b().c()` it returns the location of `c` because that’s the location of the call). But we used the location from `getLoc` as the start location of the synthesized `buildExpression` call. In the added test case, this means that the `buildExpression` call only contained `everlay() {}` and not the code completion token. We thus infered that we could skip it the entire `MyStack {}.pnTabGesture {}.everlay() {}` call for code completion, which isn’t correct.

rdar://120798355
2024-01-12 15:03:57 -08:00
Stephen Canon
7a0c4b5e4a Add default implementations for FixedWidthInteger.dividingFullWidth (#70823)
These are provided for FixedWidthInteger & UnsignedInteger (the base implementation, following Knuth's Algorithm D) and SignedInteger (converting to magnitudes and calling the former). Previously no default implementations were available, requiring every type to implement these operations.

These defaults will not be optimal for large fixed-width integers, so types vending Int512 or similar integers should still provide their own implementations, but they are unconditionally available as a fallback, which simplifies the process of writing such types, and work well enough as a fallback for modest fixed-width integer types like Int64 or 32b or smaller platforms or Int128 on 64b platforms.

Additionally rework the concrete implementations to guarantee that we always trap when the quotient is not representable, and to improve performance for 64b integers on arm64_32, and added some new test coverage for these operations.
2024-01-12 15:25:01 -05:00
Meghana Gupta
5d2454f3e3 Merge pull request #68180 from meg-gupta/lowerb4inline
Lower OwnershipModelEliminator to just before inlining
2024-01-10 13:53:34 -08:00
Slava Pestov
597fb216cb Merge pull request #70457 from slavapestov/parameter-pack-open-type
Fix openType() handling of parameter packs
2024-01-10 13:41:08 -05:00
Jeremy Schonfeld
2404013f78 [SE-0270] Add Collection Operations on Noncontiguous Elements (#69766)
* Adds RangeSet/DiscontiguousSlice to the stdlib

* Remove redundant DiscontiguousSlice.Index: Comparable conformance

* Attempt to fix embedded build

* Attempt to fix macOS test failures

* Fix Constaints/members.swift failure on linux

* Add exceptions to ABI/source checker to fix macOS tests

* Fix incremental dependency test failure

* Remove inlining/unfreeze implementation for future improvements

* Simplify indices(where:) implementation

* Address review feedback

* Add test for underscored, public slice members

* Address feedback on inlining, hashing, and initializing with unordered arrays

* Fix ABI checker issues

* Remove MutableCollection extension for DiscontiguousSlice

* Make insertion return a discardable Bool

* Fix ABI checker tests

* Fix other ABI checker tests due to dropping MutableCollection subscript
2024-01-09 14:02:19 -08:00
Slava Pestov
5d58a634ad Sema: Clean up openType() and openUnboundGenericType()
Fixes:
- rdar://112785081
- https://github.com/apple/swift/issues/67906
- https://github.com/apple/swift/issues/68160
2024-01-09 15:23:42 -05:00
Meghana Gupta
ad170b6758 Update test lexical-lifetimes.swift 2024-01-08 22:22:08 -08:00
Pavel Yaskevich
d61eac29d8 Merge pull request #70613 from honghoker/fix-typo
Fix typo whiteSpace between line comment
2024-01-08 09:17:32 -08:00
nate-chandler
bf50e2f81b Merge pull request #70729 from nate-chandler/rdar119732084
[SILGen] Fix leak in thunk for async throwing swift conformance to ObjC requirement with optional completion.
2024-01-05 00:37:33 -08:00
Nate Chandler
9f5a7c87c3 [SILGen] Fix leak in objc async thunk.
Fix a leak when emitting the native to foreign thunk for an async
function which fulfills an Objective-C protocol requirement which can be
fulfilled with either a value or an error via a nullable completion.

Previously, the SIL in question used to look like this:

```sil
  %maybe_completion = ...
  try_apply %impl..., normal success, ...

success(%value):
  switch_enum %maybe_completion...
      case some!enumelt: invoke
      case none!enumelt: ignore

ignore:
  br join

invoke(%completion):
  %some_value = enum Optional, some!enumelt, %value // consumes %value
  %guaranteed_some_value = begin_borrow %some_value
  %none_error = enum Optional, none!enumelt
  apply %completion(%guaranteed_some_value, %none_error)
  end_borrow %guaranteed_some_value
  destroy_value %some_value
  br join

join:
  destroy_value %maybe_completion
  ...
```

which leaks %value on the codepath through `ignore`.

Note that `%value` is consumed by the `enum` instruction, but
`%completion` is invoked with `%guaranteed_some_value`, a guaranteed
value.  So there is no need to consume %value in `invoke`.

Here, `%value` itself is borrowed and forwarded into an enum instruction
whose result is passed to `%completion`:

```sil
  %maybe_completion = ...
  try_apply %impl..., normal success, ...

success(%value):
  switch_enum %maybe_completion...
      case some!enumelt: invoke
      case none!enumelt: ignore

ignore:
  br join

invoke(%completion):
  %guaranteed_value = begin_borrow %value
  %guaranteed_some_value = enum Optional, some!enumelt, %guaranteed_value
  %none_error = enum Optional, none!enumelt
  apply %completion(%guaranteed_some_value, %none_error)
  end_borrow %guaranteed_some_value
  br join

join:
  destroy_value %maybe_completion
  destroy_value %value
  ...
```

Because an argument scope was already being created and a cleanup was
already being pushed for `%value`, nothing more is required to fix the
issue than to reorder the enum and the borrow.

rdar://119732084
2024-01-04 19:10:17 -08:00
Pavel Yaskevich
e4f9965ff7 [ConstraintSystem] Fail key path capability inference if root is a placeholder
If root type of a key path has been determined to be a hole there
is no reason to delay the inference decision which should be a
failure because none of the components would be inferrable from
a placeholder root.
2024-01-01 12:48:31 -08:00
honghoker
2fdb8b0481 Fix typo whiteSpace between line comment 2023-12-24 00:05:57 +09:00
Alex Hoppen
e56708c84f [CodeCompletion] Fix crash when completing inside a protocol that inherits from other protocol with extension
rdar://119408961
2023-12-13 14:27:50 -08:00
Slava Pestov
335d6ffea1 Frontend: Add -disable-experimental-associated-type-inference flag 2023-12-08 13:39:10 -05:00
Slava Pestov
e29c3a90aa AST: Lazily populate associated conformances with -enable-experimental-associated-type-inference 2023-12-07 19:27:59 -05:00
Slava Pestov
b1ed3c270c Add regression tests for rdar://116434843 and #59772 2023-12-07 19:27:59 -05:00
Erik Eckstein
8fb002e009 tests: add a missing target-codesign in constant_folded_fp_operations.swift
rdar://119268917
2023-12-07 09:45:02 +01:00
Kavon Farvardin
df8367604d Merge pull request #70161 from kavon/test-coverage-rdar118360449
[test] add coverage for rdar://118360449
2023-12-01 15:19:51 -08:00
Kavon Farvardin
5672ddfb31 [test] add coverage for rdar://118360449 2023-12-01 10:02:16 -08:00
Pavel Yaskevich
dde501485e [CSBinding] Prefer array literal type over a disjunction in certain cases
If array literal type is not delayed and doesn't have any type variables
associated with it, let's prefer it over a disjunction to facilitate
type propagation through its `Element` type to element expressions.

Resolves: rdar://118993030
2023-11-30 17:43:13 -08:00
Pavel Yaskevich
2701d431cf [CSBindings] Prefer key path type over a disjunction if key path is resolved
If key path type has bindings and is no longer delayed it means
that it's fully resolved and ready to be bound (even though value
type might not be resolved yet).
2023-11-30 16:26:10 -08:00
eeckstein
2c43c273f9 Merge pull request #69828 from jkshtj/main
[sil-optimizer] Add FP comparison support in constant folder
2023-11-28 06:59:52 +01:00
Kshitij
cc3c51ecb9 [sil-optimizer] Don't constant fold eq comparisons b/w inf and non-inf
This commit modifes the constant folder to not handle equality comparisons b/w
infinity and non-infinity operands. In such comparisons, special floating point
types - Float80 and Float16, may come into play and pattern matching againt them
complicates the constant folding logic more than we'd like.
2023-11-27 11:32:28 -08:00
Kshitij
c800dd731f [sil-optimizer] Add validation tests for constant folded FP arithmetic 2023-11-27 11:32:28 -08:00
Kshitij
97a5a83ae6 [sil-optimizer] Add FP comparison support in constant folder 2023-11-27 11:32:28 -08:00
Alex Hoppen
423826f742 [CodeComplete] Add test case for #57148, #57149
The issue no longer occurs on `main`. Add a test case for it.

Fixes #57148
Fixes #57149
2023-11-23 18:01:03 -08:00
Pavel Yaskevich
79ac431780 Merge pull request #69742 from xedin/transitive-keypath-base-inference
[ConstraintSystem] More changes to key path inference
2023-11-14 17:31:14 -08:00
Slava Pestov
e65290c2bd Sema: Associated type inference skips witnesses that might trigger a request cycle
This implements a structural walk over the TypeRepr to catch
situations where we attempt to infer `A` from `func f(_: A)`,
which references the concrete `A` that will be synthesized
in the conforming type.

Fixes:
- rdar://34956654 / https://github.com/apple/swift/issues/48680
- rdar://38913692 / https://github.com/apple/swift/issues/49066
- rdar://56672411
- https://github.com/apple/swift/issues/50010
- rdar://81587765 / https://github.com/apple/swift/issues/57355
- rdar://117442510
2023-11-14 12:08:59 -05:00
Ben Barham
9ea3146904 Merge pull request #69564 from finagolfin/early-driver
[Build] Enable building the early Swift Driver on linux with the prebuilt host toolchain
2023-11-09 14:36:27 -08:00
Pavel Yaskevich
9f21b95fcb [CSDiagnostics] A tailored diagnostic when passing key path as an argument to non-key path parameter
Produce a tailored diagnostic that omits a fully unresolved key path
type (`KeyPath<_, _>`) when key path without an explicit root type is
passed as an argument to non-keypath parameter type (i.e. `Int`).
2023-11-08 19:54:32 -08:00
Alejandro Alonso
3deacf8944 Fix backwards iteration of word breaking 2023-11-08 13:26:20 -08:00