Commit Graph

46922 Commits

Author SHA1 Message Date
Pavel Yaskevich
f36ecf2fa1 [CSSimplify] Allow overload choices with missing labels to be considered for diagnostics
Let's make use of a newly added "disable for performance" flag to
allow solver to consider overload choices where the only issue is
missing one or more labels - this makes it for a much better
diagnostic experience without any performance impact for valid code.
2021-04-28 12:04:57 -07:00
Artem Chikin
1e44ed00eb Revert "Always build SwiftDriver and use it as default compiler driver" 2021-04-28 11:20:21 -07:00
Pavel Yaskevich
d448a7702a Merge pull request #37098 from xedin/rdar-77233864-testcase
[TypeChecker] NFC: Add a test-case for rdar://77233864
2021-04-28 09:59:13 -07:00
Rintaro Ishizaki
f6d49baa36 Merge pull request #37095 from rintaro/sourcekit-completion-rdar77164709
[SourceKit] Adjust result sorting in complete.open/update
2021-04-28 09:31:31 -07:00
swift-ci
50373c57c1 Merge pull request #37107 from aschwaighofer/typeref_decoding_imported_unsupported_arm64e 2021-04-28 08:26:14 -07:00
swift-ci
1ae5b029e2 Merge pull request #37106 from aschwaighofer/fix_pic_test_arm64e 2021-04-28 08:17:31 -07:00
Robert Widmann
b80ecb3eba Merge pull request #37100 from CodaFi/the-cross-i-bear 2021-04-28 08:16:18 -07:00
Yuta Saito
1719148588 Add test case to ensure working static link with concurrency module 2021-04-28 23:52:11 +09:00
Joe Groff
bc271ab5e3 Merge pull request #37094 from jckarter/reenable-test-on-simulator
Reenable test/Concurrency/Runtime/executor_deinit1.swift on iOS simulator.
2021-04-28 07:15:09 -07:00
Konrad `ktoso` Malawski
d9a952abcc [Concurrency] Harden async_task_async_let_child_cancel so it does not need sleep 2021-04-28 22:20:10 +09:00
Arnold Schwaighofer
87f5d97070 Re-mark typeref_decoding_imported.swift as unsupported on arm64e
It fails on the  bot. And used to be marked unsupported.
2021-04-28 05:55:45 -07:00
Arnold Schwaighofer
5967dbcd15 Fix pic.swift test on arm64e 2021-04-28 05:45:47 -07:00
Ben Barham
02b5be7047 Merge pull request #37032 from bnbarham/loc-tests
[Diagnostics] Add tests to check diagnostic locations across modules
2021-04-28 21:07:40 +10:00
Alex Hoppen
1bd6086cbf Merge pull request #37071 from ahoppen/pr/block-convention-to-async
[Refactoring] Support refactoring to async if callback is `@convention(block)`
2021-04-28 11:40:19 +02:00
Ben Barham
54b80f82c2 [Diagnostics] Add tests to check diagnostic locations across modules 2021-04-28 18:38:22 +10:00
Rintaro Ishizaki
75ff9480c2 [CodeCompletion] Boost exact case-sensitive prefix match
When there are symbols 'Label' and 'label', if a user type 'Lab',
'Label' should be prioritized.

rdar://77164709
2021-04-27 22:32:37 -07:00
Robert Widmann
43a9f54b0f Repair Fingerprint Lookup Across Modules
Cross-module incremental builds require a stable source of fingerprint
information for iterable decl contexts. This is provided by the
incremental frontends when they produce partial swift module files.
Embedded in these files is a table of fingerprints, which are consumed
by merge-modules to construct a module-wide dependency graph that is
then serialized into the final merged swift module file. Unfortunately,
the implementation here iterated through the files in the module and
asked for the first fingerprint that would load for a particular
iterable decl context. If (more likely, when) the DeclID for that
serialized iterable decl context collided with another DeclID in the
wrong file, we would load that fingerprint instead.

Locate up to the module-scope context for an iterable decl context and
only load the fingerprint from there. This ensures that the fingerprints
in the partial modules matches the fingerprints in the merged modules.

rdar://77005039
2021-04-27 21:39:25 -07:00
Holly Borla
2327f1004c Merge pull request #37093 from hborla/property-wrapper-diagnostic-crash
[Property Wrappers] Fix a diagnostic crash when a parameter has a wrapped value mismatch.
2021-04-27 18:36:07 -07:00
Pavel Yaskevich
40a32dc39a [TypeChecker] NFC: Add a test-case for rdar://77233864 2021-04-27 15:57:55 -07:00
swift-ci
8447424efa Merge pull request #37091 from DougGregor/se-0306-actors-by-default 2021-04-27 15:03:06 -07:00
Joe Groff
cd6823f83b Reenable test/Concurrency/Runtime/executor_deinit1.swift on iOS simulator.
The failure no longer reproduces. rdar://76611676
2021-04-27 14:30:47 -07:00
Artem Chikin
841f761af1 Merge pull request #37089 from artemcm/DisableImplicitConcurrencyOnBatchScanTest
Test Only - Do not load Concurrency modile in `batch_module_scan_versioned`
2021-04-27 13:47:10 -07:00
Alex Hoppen
f17fe868c6 [Refactoring] Support refactoring to async if callback is @convention(block)
We already have special logic to extrac the closure for closures with capture lists, add the same kind of logic for closures that are marked `@convention(block)` etc.

Resolves rdar://75301524 [SR-14328]
2021-04-27 22:25:57 +02:00
Ben Barham
c8c2fd5fe4 Merge pull request #37029 from bnbarham/read-swiftsourceinfo
[Tests] Do not ignore swiftsourceinfo by default in lit tests
2021-04-28 06:17:19 +10:00
Holly Borla
0248250a51 [Property Wrappers] Fix a diagnostic crash when a parameter has a wrapped value
mismatch.

If there's an error in property wrapper application, the backing property
wrapper type request will return a null type, which would cause the compiler
to crash because most error recovery code expects ErrorType. If the wrapper
application has an error, use the interface type of the parameter instead.
2021-04-27 12:56:52 -07:00
Doug Gregor
a2cdef73a6 [SE-0306] Enable actors by default.
With the acceptance of SE-0306, enable actors by default and add a
ChangeLog entry.

Tracked by rdar://77223763.
2021-04-27 12:25:41 -07:00
Artem Chikin
c3ead5addc Test Only - Do not load Concurrency modile in batch_module_scan_versioned
It has a specific target (`x86_64`) and on other platforms, Concurrency will not be found with this architecture by default.
e.g. Apple Silicon failure:
https://ci.swift.org/job/swift-PR-macos-apple-silicon/78
2021-04-27 11:09:23 -07:00
Artem Chikin
23452d5bad Merge pull request #36377 from artemcm/NewDriverDefault
Always build SwiftDriver and use it as default compiler driver
2021-04-27 09:53:06 -07:00
Alex Hoppen
ae21abaead Merge pull request #37034 from ahoppen/pr/subst-generic-params-mismatch
[Sema] Fix crash when retrieving typeContextInfo for a partially bound generic type
2021-04-27 17:19:06 +02:00
Alex Hoppen
af789d508e Merge pull request #37065 from ahoppen/pr/complete-from-constrained-extensions
[CodeComplete] Show completions from constrained protocol extension
2021-04-27 08:14:35 +02:00
Alex Hoppen
b70e91fbff [Sema] Fix crash when retrieving typeContextInfo for a partially bound generic type
In the following test case, we are crashing while building the generic signature of `someGenericFunc`, potentially invoked on `model` in line 11.

```swift
struct MyBinding<BindingOuter> {
  func someGenericFunc<BindingInner>(x: BindingInner) {}
}

struct MyTextField<TextFieldOuter> {
  init<TextFieldInner>(text: MyBinding<TextFieldInner>) {}
}

struct EncodedView {
    func foo(model: MyBinding<String>) {
        let _ = MyTextField<String>(text: model)
    }
}
```

Because we know that `model` has type `MyBinding<TextFieldInner>`, we substitute the `BindingOuter` generic parameter by `TextFieldInner`. Thus, `someGenericFunc` has the signature `<TextFieldInner /* substitutes BindingOuter */, BindingInner>`. `TextFieldInner` and `BindingOuter` both have `depth = 1`, `index = 0`. Thus the verification in `GenericSignatureBuilder` is failing.

After discussion with Slava, the root issue appears to be that we shouldn’t be calling `subst` on a `GenericFunctionType` at all. Instead we should be using `substGenericArgs` which doesn’t attempt to rebuild a generic signature, but instead builds a non-generic function type.

--------------------------------------------------------------------------------

We slightly regress in code completion results by showing two `collidingGeneric` twice in the following case.

```swift
protocol P1 {
  func collidingGeneric<T>(x: T)
}
protocol P2 {
  func collidingGeneric<T>(x: T)
}
class C : P1, P2 {
  #^COMPLETE^#
}
```

Previously, we were representing the type of `collidingGeneric` by a generic function type with generic param `T` that doesn’t have any restrictions. Since we are now using `substGenericArgs` instead of `subst`, we receive a non-generic function type that represents `T` as an archetype. And since that archetype is different for the two function signatures, we show the result twice in code completion.

One could also argue that showing the result twice is intended (or at least acceptable) behaviour since, the two protocol may name their generic params differently. E.g. in

```swift
protocol P1 {
  func collidingGeneric<S>(x: S)
}
protocol P2 {
  func collidingGeneric<T>(x: T)
}
class C : P1, P2 {
  #^COMPLETE^#
}
```

we might be expected to show the following two results
```
func collidingGeneric<S>(x: S)
func collidingGeneric<T>(x: T)
```

Resolves rdar://76711477 [SR-14495]
2021-04-27 08:13:54 +02:00
Alex Hoppen
4a98a29d0d Merge pull request #36989 from ahoppen/pr/check-may-have-members
[SourceKit] Don’t transform type when printing if CurrentType can’t have members
2021-04-27 07:48:13 +02:00
swift-ci
17440ad3fb Merge pull request #37077 from apple/unsupported-back_deployment_runtime-async_initializer-and-async_task_async_let_child_cancel 2021-04-26 22:35:49 -07:00
Michael Gottesman
5900a0fdac Merge pull request #37016 from gottesmm/pr-eb1b4b484d8990f6f5cb6706dba952b3e27cdc59
[sil-optimizer] Make InstructionDeleter and related APIs to use an InstModCallback instead of a notification callback.
2021-04-26 21:03:26 -07:00
Mishal Shah
a0d10e77a8 Concurrency/Runtime/async_initializer.swift and Concurrency/Runtime/async_task_async_let_child_cancel.swift unsupported on older OS 2021-04-26 20:05:46 -07:00
Michael Gottesman
7b55cbc669 [sil-optimizer] Make InstructionDeleter and related APIs to use an InstModCallback instead of a notification callback.
I recently have been running into the issue that many of these APIs perform the
deletion operation themselves and notify the caller it is going to delete
instead of allowing the caller to specify how the instruction is deleted. This
causes interesting semantic issues (see the loop in deleteInstruction I
simplified) and breaks composition since many parts of the optimizer use
InstModCallbacks for this purpose.

To fix this, I added a notify will be deleted construct to InstModCallback. In a
similar way to the rest of it, if the notify is not set, we do not call any code
implying that we should have good predictable performance in loops since we will
always skip the function call.

I also changed InstModCallback::deleteInst() to notify before deleting so we
have a default safe behavior. All previous use sites of this API do not care
about being notified and the only new use sites of this API are in
InstructionDeleter that perform special notification behavior (it notifies for
certain sets of instructions it is going to delete before it deletes any of
them). To work around this, I added a bool to deleteInst to control this
behavior and defaulted to notifying. This should ensure that all other use sites
still compose correctly.
2021-04-26 16:37:43 -07:00
Rintaro Ishizaki
848031825e [CodeCompletion] Peform complete filterSolutions in code completion
Not-filtering solutions causes unacceptable slownesses in some cases.
For now, filter solutions as normal typechecking does to restore the
performance.

rdar://76714968
2021-04-26 13:03:32 -07:00
Artem Chikin
c2dc8e3d07 Always build (and use) the new SwiftDriver as the default compiler driver.
This will make sure that compiler developers are using the new driver when they build the compiler locally and use it.

- Adds a new build-script product category: before_build_script_impl for products we wish to build before the impl products.
- Adds a new EarlySwiftDriver product to that category, which gets built with the host toolchain.
- Adds an escape hatch: --skip-early-swift-driver
- Adjusts the swift CMake configuration with an additional step: swift_create_early_driver_symlinks which (if one was built) creates symlinks in the swift build bin directory to the EarlySwiftDriver swift-driver and swift-help executables.
- Adds a new test subset : only_early_swiftdriver, which will get built into a corresponding CMake test target: check-swift-only_early_swiftdriver-* which runs a small subset of driver-related tests against the Early SwiftDriver.
  - This subset is run always when the compiler itself is tested (--test is specified)
  - With an escape disable-switch: --skip-test-early-swift-driver
  - All tests outside of only_early_swiftdriver are forced to run using the legacy C++ driver (to ensure it gets tested, still).

NOTE: SwiftDriver product (no 'Early') is still the main product used to build the driver for toolchain installation into and for executing the product's own tests. This change does not affect that.
2021-04-26 12:17:32 -07:00
Alex Hoppen
b99ca7cae9 [CodeComplete] Show completions from constraint protocol extension
Consider the following example.

```swift
protocol FontStyle {}
struct FontStyleOne: FontStyle {}

extension FontStyle where Self == FontStyleOne {
    static var one: FontStyleOne { FontStyleOne() }
}

func foo<T: FontStyle>(x: T) {}
func case1() {
    foo(x: .#^COMPLETE^#)
}
```

With SE-0299 accepted, we should be suggesting `.one`.

For that, we need to consider the extension applied when performing the unresolved dot code completion with a primary archetype that conforms to `FontStyle`.

However, in the following case, which performs an unresolved dot completion on the same base type, we don't want to suggest `.one` because that would require `T == FontStyleOne`, which we can’t assume.

```swift
func case2<T: FontStyle>(x: T) {
    x.#^COMPLETE_2^#
}
```

Since the constraint system cannot tell us how it came up with the archetype, we need to apply a heuristic to differentiate between the two cases.

What seems to work fine in most cases, is to determine if `T` referes to a generic parameter that is visible from the decl context we are completing in (i.e. the decl context we are completing in is a child context of the context that `T` is declared in). If it is not, then `T` cannot be the type of a variable we are completing on. Thus, we are in the first case and we should consider all extensions of `FontStyle` because we can further specialize `T` by picking a more concrete type.
Otherwise `T` may be the type of a variable we are completing on and we should be conservative and only suggest those extensions whose requirements are fulfilled by `T`.

Since this is just a heuristic, there are some corner cases, where we aren’t suggesting constrainted extensions although we should. For example, in the following example the call to `testRecursive` doesn’t use `T` and we should thus suggest `one`. But by the rules described above we detect that `T` is accessible at the call and thus don’t apply extension whose requirements aren’t satisfied.

```swift
func testRecursive<T: FontStyle>(_ style: T) {
  testRecursive(.#^COMPLETE_RECURSIVE_GENERIC^#)
}
```

Similar completion issues also occurred without SE-0299 in more complicated, generic scenarios.

Resolves rdar://74958497 and SR-12973
2021-04-26 20:03:07 +02:00
swift-ci
9df8944bf3 Merge pull request #37063 from aschwaighofer/reenable_class_resilience_objc_arm64e 2021-04-26 09:03:46 -07:00
Evan Wilde
d0d9bef703 Merge pull request #37056 from etcwilde/ewilde/fix-await-fixits
[Concurrency] Fix await fix-it placement
2021-04-26 08:12:50 -07:00
Arnold Schwaighofer
f3e14970c6 Un-XFAIL IRGen test class_resilience_objc.swift 2021-04-26 06:36:48 -07:00
Konrad `ktoso` Malawski
fd8ec39f69 Merge branch 'main' into wip-main-remove-task-current 2021-04-26 17:39:50 +09:00
Konrad `ktoso` Malawski
e0eb940027 [Concurrency] Remove Task.current because it prevents task-local alloc #36993 2021-04-26 17:37:45 +09:00
Luciano Almeida
c15dde4265 Merge pull request #37057 from LucianoPAlmeida/placeholder-checkedcast-warn
[Sema] Do not attempt warn extraneous checked cast for placeholder types
2021-04-25 08:03:18 -03:00
Doug Gregor
02821fd0f4 Merge pull request #37053 from DougGregor/disable-actor-inheritance 2021-04-24 22:31:09 -07:00
Luciano Almeida
b851974424 [Sema] Do not attempt warn extraneous checked cast for placeholder types 2021-04-24 23:52:58 -03:00
Evan Wilde
3da0a540eb Update tests
This patch updates all the tests to accept the new error messages.
*Gack* so many things needed cleaning up.
2021-04-24 07:51:18 -07:00
swift-ci
16532e3a0a Merge pull request #35759 from 3405691582/DispatchTestsUnsupported 2021-04-23 22:33:28 -07:00
Mishal Shah
3116eed2e4 Update the branch to build with Xcode 12.5 (#37046) 2021-04-23 16:24:11 -07:00