Commit Graph

46922 Commits

Author SHA1 Message Date
Xi Ge
93eae81b04 Merge pull request #37375 from nkcsgexi/diagnose-new-driver-only-options
Driver: diagnose options that are only supported in the new driver
2021-05-11 19:05:30 -07:00
Holly Borla
c297070106 [Diagnostics] Always use the parameter name for closure parameter diagnostics,
because the $ prefix does not indicate that the parameter is anonymous.
2021-05-11 18:30:27 -07:00
Holly Borla
ef58f6a827 [ConstraintSystem] If the contextual parameter type doesn't exist when
resolving a closure, create a new type variable for inferred property
wrapper types.
2021-05-11 18:26:22 -07:00
fredriss
3ed11125f3 Merge pull request #37325 from fredriss/async-task-id
[Concurrency] Add a unique Task ID to AsyncTask
2021-05-11 17:59:47 -07:00
Xi Ge
01b1aea958 Driver: diagnose options that are only supported in the new driver 2021-05-11 16:28:57 -07:00
Pavel Yaskevich
c346bbd514 [Diagnostics] Point out where anonymous closure parameters are used in a multi-statement closure 2021-05-11 15:07:44 -07:00
Arnold Schwaighofer
bd010c3998 Merge pull request #37369 from aschwaighofer/availability_macro_concurrency_tests
Use availability macro insteada of macOS 9999 in Concurrency tests
2021-05-11 14:01:15 -07:00
Rintaro Ishizaki
147f81c304 Merge pull request #37364 from rintaro/sourcekit-syntaxinfo-rdar77665805
[SourceKit] Update SyntaxInfo but with lazy parsing in "edit" request
2021-05-11 13:23:09 -07:00
Arnold Schwaighofer
753fae3fd1 Disable async_task_async_let_child_cancel.swift test
It sometimes fails on bots.

rdar://77671328
2021-05-11 10:49:17 -07:00
Arnold Schwaighofer
887902eabd Use availability macro insteada of macOS 9999 in Concurrency tests 2021-05-11 10:40:45 -07:00
Rintaro Ishizaki
4c213c4b76 [sourcekitd-test] Add ability to expand single placeholder 2021-05-11 10:15:51 -07:00
Pavel Yaskevich
ddfaf80181 Merge pull request #37347 from xedin/rdar-77700261
[CSFix] Suppress ambiguity warning about non-`Optional` base with sta…
2021-05-11 10:13:14 -07:00
Joe Groff
63613a9a83 Merge pull request #37348 from jckarter/runtime-test-async-objc-method-completion-handler-override
Add test that exercises still overriding ObjC async methods as completion handlers
2021-05-11 09:50:16 -07:00
Rintaro Ishizaki
54683ca607 [SourceKit] Update SyntaxInfo but with lazy parsing in "edit" request
Previously, if the client requests no information from "edit" request,
the syntax info wasn't updated. But "expand placeholder" request
requires the up-to-date syntax info.

rdar://77665805
2021-05-11 09:46:14 -07:00
Fred Riss
bbda706393 [Concurrency] Add a unique Task ID to AsyncTask
This commit changes JobFlags storage to be 32bits, but leaves the runtime
API expressed in terms of size_t. This allows us to pack an Id in the
32bits we freed up.

The offset of this Id in the AsyncTask is an ABI constant. This way
introspection tools can extract the currently running task identifier
without any need for special APIs.
2021-05-11 08:28:17 -07:00
Victoria Mitchell
8ae8dbc5a8 add situations where inheriting docs shouldn't happen 2021-05-11 08:38:24 -06:00
Alex Hoppen
921443e8ab [Refactoring] Support creation of async legacy bodies even if a parameter is not optional
If the parameter is not an `Optional`, add a placeholder instead that the user can fill with a sensible default value.
2021-05-11 15:49:55 +02:00
Alex Hoppen
dd978cca0b [Refactoring] Support refactoring calls to async if a variable or function is used as completion handler
Previously, we only supported  refactoring a function to call the async alternative if a closure was used for the callback parameter. With this change, we also support calling a arbitrary function (or variable with function type) that is passed to the completion handler argument.

The implementation basically re-uses the code we already have to create the legacy function’s body (which calls the newly created async version and then forwards the arguments to the legacy completion handler).

To describe the completion handler that the result is being forwarded to, I’m also using `AsyncHandlerDesc`, but since the completion handler may be a variable, it doesn’t necessarily have an `Index` within a function decl that declares it. Because of this, I split the `AsyncHandlerDesc` up into a context-free `AsyncHandlerDesc` (without an `Index`) and `AsyncHandlerParamDesc` (which includes the `Index`). It turns out that `AsyncHandlerDesc` is sufficient in most places.

Resolves rdar://77460524
2021-05-11 15:48:24 +02:00
Konrad `ktoso` Malawski
6b81674b71 Merge pull request #37340 from ktoso/wip-locals-sync
[TaskLocals] Enable sync functions to bind task-locals; Keep Storage in TLS
2021-05-11 17:07:46 +09:00
Robert Widmann
5af7b68070 Merge pull request #37338 from cltnschlosser/cs_sdkSettingsCanonicalName
Add CanonicalName to mock SDKSettings.json
2021-05-10 22:38:55 -07:00
Konrad `ktoso` Malawski
6cbb792f92 [TaskLocals] Propagate task-locals through async{} 2021-05-11 11:06:17 +09:00
Konrad `ktoso` Malawski
82e91b7785 [TaskLocals] Enable sync functions to bind task-locals; Keep Storage in TLS 2021-05-11 11:06:16 +09:00
swift-ci
7ee2a5c087 Merge pull request #37186 from Catfish-Man/missing-dependency 2021-05-10 17:35:34 -07:00
Pavel Yaskevich
2fdebccbd7 Merge pull request #37342 from xedin/rdar-77466241
[ResultBuilders] Diagnose pre-check errors inline
2021-05-10 15:53:26 -07:00
Victoria Mitchell
81bc80d565 add sourceOrigin field for symbols implementing remote protocol requirements
rdar://77626724
2021-05-10 16:41:50 -06:00
Rintaro Ishizaki
861bbcc5d6 Merge pull request #37330 from rintaro/ide-completion-rdar75620636
[CodeCompletion] Make object literals optional
2021-05-10 13:47:10 -07:00
David Smith
b16218660a Add missing _Concurrency dependency to the Dispatch overlay 2021-05-10 13:00:42 -07:00
Joe Groff
391a3bd42d Add test that exercises still overriding ObjC async methods as completion handlers 2021-05-10 12:53:32 -07:00
Pavel Yaskevich
a3fe65d87e [CSFix] Suppress ambiguity warning about non-Optional base with static member lookup
Disable non-Optional "assumption" warning for ambiguities related to a
static member lookup in generic context because it's possible to declare
a member with the same name on a concrete type and in an extension of a
protocol that type conforms to e.g.:

```swift
struct S : P { static var test: S { ... }

extension P where Self == S { static var test: { ... } }
```

And use that in an optional context e.g. passing `.test`
to a parameter of expecting `S?`.

Resolves: rdar://77700261
2021-05-10 12:52:26 -07:00
Slava Pestov
3beb3529b4 Move test/Generics/explicit_requirements_perf.swift to validation-test/compiler_scale
All other scale-tests are in validation-test, so move this one there
too to speed up non-validation test runs.

Also this fixes the failure on Windows, where we don't run validation
tests yet.
2021-05-10 14:08:16 -04:00
Pavel Yaskevich
4b0d9a2509 [ResultBuilders] Diagnose pre-check errors inline
Not all of the pre-check errors could be diagnosed by re-running
`PreCheckExpression` e.g. key path expressions are mutated to
a particular form after an error has been produced.

To make the behavior consistent, let's allow pre-check to emit
diagnostics and unify pre-check and constraint generation fixes.

Resolves: rdar://77466241
2021-05-10 11:06:58 -07:00
Alexis Laferrière
7487c12d05 Merge pull request #37269 from xymus/test-macro
[Concurrency] Define and use the SwiftStdlib 5.5 availability macro in tests
2021-05-10 10:46:53 -07:00
eeckstein
cf2c052628 Merge pull request #37315 from eeckstein/fix-abc-opt
ArrayBoundCheckOpts: introduce a limit for the maximum dominator tree recursion depth
2021-05-10 09:15:04 +02:00
Colton Schlosser
b01511832d Add CanonicalName to mock SDKSettings.json 2021-05-09 17:20:14 -05:00
Slava Pestov
e91b305b94 Merge pull request #37154 from slavapestov/new-redundant-requirements-algorithm-part-2
GSB: New algorithm for computing redundant requirements
2021-05-08 16:50:27 -04:00
Rintaro Ishizaki
5ea60e8044 Merge pull request #37300 from rintaro/ide-completion-rdar76355581
[CodeCompletion] Complete pattern introducer for 'for'
2021-05-07 18:41:04 -07:00
Rintaro Ishizaki
fc0e748d64 Merge pull request #37324 from rintaro/ide-completion-rdar75358153
[CodeCompletion] Reset 'hasSingleExpressionBody' when setting function body
2021-05-07 16:46:22 -07:00
Rintaro Ishizaki
da96ef1f51 [CodeCompletion] Make object literals optional
For example, non-Darwin platforms probably don't want
`#colorLiteral(red:green:blue":alpha:)` and `#imageLiteral(named:)`.
Add an completion option to include them, which is "on" by default.

rdar://75620636
2021-05-07 16:27:13 -07:00
Slava Pestov
e45b566642 GSB: Try harder to prove derivation via redundant requirements
Consider a signature with a conformance requirement, and two
identical superclass requirements, both of which make the
conformance requirement redundant.

The conformance will have two requirement sources, the explicit
source and a derived source based on one of the two superclass
requirements, whichever one was processed first.

If we end up marking the *other* superclass requirement as
redundant, we would incorrectly conclude that the conformance
was not redundant. Instead, if a derived source is based on a
redundant requirement, we can't just discard it right away;
instead, we have to check if that source could have been
derived some other way.
2021-05-07 18:43:57 -04:00
Slava Pestov
f6359e9d6f GSB: Replace 'self derived' check with a more sound notion of well-foundedness
Consider this example:

    protocol P1 {
      associatedtype A : P2
    }

    protocol P2 {
      associatedtype A
    }

    func foo<T : P2>(_: T) where T.A : P1, T.A.A == T {}

We cannot drop 'T : P2', even though it can be derived from
T.A.A == T and Self.A : P2 in protocol P1, because we actually
need the conformance T : P2 in order to recover the concrete
type for T.A.

This was handled via a hack which would ensure that the
conformance path (T.A : P1)(Self.A : P2) was not a candidate
derivation for T : P2, because T : P2 is one of the conformances
used to construct the subject type T.A in the conformance path.

This hack did not generalize to "cycles" of length greater than 1
however:

    func foo<T : P2, U : P2>(_: T, _: U)
      where T.A : P1, T.A.A == U, U.A : P1, U.A.A == T {}

We used to drop both T : P2 and U : P2, because each one had a
conformance path (U.A : P1)(Self.A : P2) and (T.A : P1)(Self.A : P2),
respectively; however, once we drop T : P2 and U : P2, these two
paths become invalid for the same reason that the concrete type
for T.A and U.A can no longer be recovered.

The correct fix is to recursively visit the subject type of each
base requirement when evaluating a conformance path, and not
consider any requirement whose subject type's parent type cannot
be recovered. This proceeds recursively.

In the worst case, this algorithm is exponential in the number of
conformance requirements, but it is not always exponential, and
a generic signature is not going to have a large number of
conformance requirements anyway (hopefully). Also, the old logic
in getMinimalConformanceSource() wasn't cheap either.

Perhaps some clever minimization can speed this up too, but I'm
going to focus on correctness first, before looking at performance
here.

Fixes rdar://problem/74890907.
2021-05-07 18:43:52 -04:00
Slava Pestov
aa865a2133 GSB: Stop computing 'derived via concrete' sources 2021-05-07 18:43:52 -04:00
Slava Pestov
710621c2eb GSB: Remove checkConformanceConstraints() 2021-05-07 18:43:52 -04:00
Slava Pestov
4bf239827e GSB: Fix off-by-one error when merging layout requirements of two equivalence classes
Literally an off-by-one error -- we were skipping over the first
requirement and not copying it over. I think this is because the
updateLayout() call used to be addLayoutRequirementDirect(),
which would add the first layout constraint, and I forgot to
remove the '+ 1' when I refactored this.
2021-05-07 18:43:52 -04:00
Slava Pestov
d311549246 GSB: Rebuild requirement signatures after dropping redundant conformance requirements
This fixes a regression from the new redundant requirements algorithm
and paves the way for removing the notion of 'derived via concrete'
requirements.
2021-05-07 18:43:52 -04:00
Slava Pestov
a49b93c61a GSB: New redundant requirements algorithm
This rewrites the existing redundant requirements algorithm
to be simpler, and fix an incorrect behavior in the case where
we're building a protocol requirement signature.

Consider the following example:

    protocol P {
      associatedtype A : P
      associatedtype B : P where A.B == B
    }

The requirement B : P has two conformance paths here:

    (B : P)
    (A : P)(B : P)

The naive redundancy algorithm would conclude that (B : P) is
redundant because it can be derived as (A : P)(B : P). However,
if we drop (B : P), we lose the derived conformance path
as well, since it involves the same requirement (B : P).

The above example actually worked before this change, because we
handled this case in getMinimalConformanceSource() by dropping any
derived conformance paths that involve the requirement itself
appearing in the "middle" of the path.

However, this is insufficient because you can have a "cycle"
here with length more than 1. For example,

    protocol P {
      associatedtype A : P where A == B.C
      associatedtype B : P where B == A.C
      associatedtype C : P where C == A.B
    }

The requirement A : P has two conformance paths here:

   (A : P)
   (B : P)(C : P)

Similarly, B : P has these two paths:

   (B : P)
   (A : P)(C : P)

And C : P has these two paths:

   (C : P)
   (A : P)(B : P)

Since each one of A : P, B : P and C : P has a derived conformance
path that does not involve itself, we would conclude that all three
were redundant. But this was wrong; while (B : P)(C : P) is a valid
derived path for A : P that allows us to drop A : P, once we commit to
dropping A : P, we can no longer use the other derived paths
(A : P)(C : P) for B : P, and (A : P)(B : P) for C : P, respectively,
because they involve A : P, which we dropped.

The problem is that we were losing information here. The explicit
requirement A : P can be derived as (B : P)(C : P), but we would
just say that it was implied by B : P alone.

For non-protocol generic signatures, just looking at the root is
still sufficient.

However, when building a requirement signature of a self-recursive
protocol, instead of looking at the root explicit requirement only,
we need to look at _all_ intermediate steps in the path that involve
the same protocol.

This is implemented in a new getBaseRequirements() method, which
generalizes the operation of getting the explicit requirement at
the root of a derived conformance path by returning a vector of
one or more explicit requirements that appear in the path.

Also the new algorithm computes redundancy online instead of building
a directed graph and then computing SCCs. This is possible by
recording newly-discovered redundant requirements immediately,
and then using the set of so-far-redundant requirements when
evaluating a path.

This commit introduces a small regression in an existing test case
involving a protocol with a 'derived via concrete' requirement.
Subsequent commits in this PR fix the regression and remove the
'derived via concrete' mechanism, since it is no longer necessary.

Fixes https://bugs.swift.org/browse/SR-14510 / rdar://problem/76883924.
2021-05-07 18:43:52 -04:00
fwcd
9f21b4a2f6 Fix remaining SourceKit tests 2021-05-08 00:40:53 +02:00
QuietMisdreavus
08d1c33e6f Merge pull request #37278 from apple/QuietMisdreavus/default-relation
[SymbolGraph] add "memberOf" relations for remote protocol implementations
2021-05-07 16:19:18 -06:00
Mishal Shah
a7f9e25080 Merge pull request #37319 from apple/shahmishal/drop-lit-incremental-flag
LIT argument --incremental is deprecated
2021-05-07 14:27:53 -07:00
Rintaro Ishizaki
72f16df99d [CodeCompletion] Reset 'hasSingleExpressionBody' when setting function body
Previously, completing inside non single expression body might cause a
crash if you had done any completion with single expression in the same
body.

e.g.

  func test() {
    test(#^HERE^#)
  }

after that:

  func test() {
    test(arg)
    if #^HERE^#
  }

That was because the `hasSingleExpressionBody` wasn't cleared when
reusing the function for subsequent completions.

This patch just clears it whenever a new parsed body is set to a
function.

rdar://75358153
2021-05-07 13:59:32 -07:00
Holly Borla
833a453c8a Merge pull request #37301 from hborla/wrapped-parameter-miscompile
[SILGen] Fix a miscompile when emitting the application of a wrapped parameter
2021-05-07 12:44:38 -07:00