Commit Graph

68066 Commits

Author SHA1 Message Date
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
Pavel Yaskevich
c9eac2215a Merge pull request #37292 from xedin/rdar-77022842
[CSBindings] Don't infer subtypes/supertype bindings for a closure type
2021-05-07 10:41:06 -07:00
QuietMisdreavus
4b068acf23 Merge pull request #37248 from apple/QuietMisdreavus/synthesized-sourceOrigin
[SymbolGraph] add sourceOrigin for synthesized symbols even if no docs exist
2021-05-07 10:20:40 -06:00
Slava Pestov
0bc6cfe84b Merge pull request #37296 from slavapestov/cleaner-conformance-access-path
GSB: Rewrite getConformanceAccessPath(), again
2021-05-07 12:16:02 -04:00
Erik Eckstein
2a17d9a480 ArrayBoundCheckOpts: introduce a limit for the maximum dominator tree recursion depth
This is a quick fix for a stack overflow in case of very large functions.
TODO: Ideally this algorithm would be implemented as an iterative worklist algorithm.

rdar://77563057
2021-05-07 18:13:08 +02:00
Alex Hoppen
b8ec77892c [Refactoring] Replace usage of constant strings with tok:: wherever possible
The code moved from `LegacyAlternativeBodyCreator` was using constant strings a lot. Use `tok::` instead to match the style of `AsyncConverter`.
2021-05-07 18:05:27 +02:00
Alex Hoppen
8903190bed [Refactoring] Merge LegacyAlternativeBodyCreator into AsyncConverter
This will later allow us to reuse parts of `LegacyAlternativeBodyCreator` from `AsyncConverter` when refactoring calls to an async alternative if they pass a variable as the completion handler.
2021-05-07 18:05:27 +02:00
Andrew Trick
05e1284852 Merge pull request #37285 from atrick/fix-self-capture
Fix an assert in exclusivity diagnostics when inouts escape.
2021-05-07 09:03:07 -07:00
Holly Borla
0999deac07 [SILGen] Don't pass down the context when emitting the r-value of the wrapped
or projected value in RValueEmitter::visitAppliedPropertyWrapperExpr
2021-05-07 08:51:47 -07:00
fwcd
8c0e0e2ef7 Add DiagnosticEngine::diagnosticIDStringFor 2021-05-07 17:45:21 +02:00
Doug Gregor
49edef8dd4 Merge pull request #37304 from DougGregor/revert-nonisolated
[Concurrency] Revert 'nonisolated let' change.
2021-05-07 07:49:03 -07:00
Doug Gregor
40c7341603 Merge pull request #37306 from DougGregor/async-let-family
Reinstate "async let", with "spawn let" as an alias.
2021-05-07 07:48:35 -07:00
Alex Hoppen
759419190e Merge pull request #36992 from ahoppen/pr/wrapping-lvalue
[TypeChecker] Clear param specifiers before re-typechecking expression for completion
2021-05-07 14:10:45 +02:00
Alex Hoppen
6f46ba6899 Merge pull request #36943 from ahoppen/pr/conforming-methods-in-closure
[Sema] Don’t allow unresolved type variables if `LeaveBraceStmtBodyUnchecked` is `true`
2021-05-07 14:08:25 +02:00
Hamish Knight
61be047b05 Merge pull request #37295 from hamishknight/extra-extensions
[IDE] Fix superclass constraint handling for extension merging
2021-05-07 10:49:53 +01:00
Doug Gregor
220e29d674 Reinstate "async let", with "spawn let" as an alias. 2021-05-07 00:13:56 -07:00
Doug Gregor
06dc77ddf3 Revert "[Concurrency] Resyntax 'async let' as 'spawn let'."
This reverts commit 41f42fabbf.
2021-05-06 22:18:36 -07:00
Dario Rexin
4486aac405 [Lexer] Avoid casting to signed char in switch statements (#37289)
This cast causes overflows on platforms that use unsigned char as default and at least on linux-aarch64 causes false negatives in the switch statements.
2021-05-06 18:41:46 -07:00
Rintaro Ishizaki
b348bf60e1 [CodeCompletion] Complete pattern introducer for 'for'
After 'for', suggest 'try', 'await', 'var' and 'case'.

rdar://76355581
2021-05-06 18:13:43 -07:00
Rintaro Ishizaki
df89d28e10 Merge pull request #37280 from rintaro/ide-completon-se0293-rdar76355405
[CodeCompletion] Update for SE-0293 Property Wrappers for func params
2021-05-06 18:10:14 -07:00
Doug Gregor
052cc7d022 [Concurrency] Revert 'nonisolated let' change.
The change made to SE-0306 to require 'nonisolated let' is undercutting
the effectiveness of the model. Revert while we work on a better
solution.
2021-05-06 17:30:11 -07:00
Ben Barham
8b3147c345 Merge pull request #37235 from bnbarham/async-refactoring-mixed-optional
[Refactoring] Only unwrap optionals if the handler has an optional error
2021-05-07 08:20:20 +10:00
Slava Pestov
e6ff771d59 GSB: Rewrite getConformanceAccessPath(), again
The new approach is to not look at RequirementSources at all. Instead,
we exhaustively enumerate all conformance access paths, beginning
from the root conformance requirements in the signature, then doing
all conformance requirements from those protocols' requirement
signatures, and so on.

We enumerate conformance access paths in breadth first order by
length until we find the one we want. The results are memoized.

This fixes a regression with another change I'm working on. The
test case does not fail with this PR alone, but I'm adding it now
anyway.
2021-05-06 17:55:43 -04:00
Hamish Knight
be39edfa7b [IDE] Fix superclass constraint handling for extension merging
For a case like:

```
public class C<T> {}
public class D {}

extension C where T : D {
  public func foo() {}
}
```

We would indadvertedly drop the extension for `C`
in the doc info, as the superclass constraint would
fail the `isBindableToSuperclassOf` check.
Instead, map the subject type of the constraint
into the context and check if it could be bound to
the superclass. In the example above, this is
trivially true, but for cases where we're mirroring
a protocol extension onto the type, this will
disregard those that don't fulfil the requirements.

Resolves rdar://76868074
2021-05-06 22:22:17 +01:00
Pavel Yaskevich
3c0388d945 [CSBindings] Don't infer subtypes/supertype bindings for a closure type
A type representing a closure expression is always bound to its
"inferred" type based on the body, so contextual bindings just
serve as a trigger to "resolve" a closure. Let's not attempt any
subtype/supertype inference for a type variable representing a
closure since if "direct" bindings have failed, it wouldn't be bound
to such types regardless.

Resolves: rdar://problem/77022842
2021-05-06 13:35:45 -07:00
Rintaro Ishizaki
a01a3ad530 [CodeCompletion] Update for SE-0293 Property Wrappers for func params
rdar://76355405
2021-05-06 13:21:27 -07:00
Pavel Yaskevich
187a43fea3 Merge pull request #37178 from xedin/rdar-75514153
[Diagnostics] Handle ambiguities related to use of `nil` literal
2021-05-06 11:52:56 -07:00
Alex Hoppen
3d1f9b6402 [CodeCompletion] Remove unresolved type from ParsedExpr during operator completion
When doing operator completion, we re-type-check the sequence expression. If we have an unresolve type already applied to `ParsedExpr`, which is the last element of the sequence, the type checker crashes in `validation-test/IDE/crashers_2_fixed/0008-must-conform-to-literal-protocol.swift`, because there are still inactive constraints in the constraint system when it finishes solving.

Previously, we would ignore because we allowed free type variables, which we no longer do since the last commit.
2021-05-06 18:35:00 +02:00
Victoria Mitchell
633ffece87 compare module names instead of pointers 2021-05-06 10:08:09 -06:00
Argyrios Kyrtzidis
c417464359 Merge pull request #37252 from ahoppen/pr/missing-module-map
[ClangImporter] Load the stdlib even if there is a `-fmodule-map-file` argument pointing to a missing file
2021-05-06 09:02:22 -07:00
Alex Hoppen
aef9d5147f [ClangImporter] Load the stdlib even if there is a -fmodule-map-file argument pointing to a missing file
If there is a `-fmodule-map-file` argument whose file doesn’t exist and SwiftShims is not in the module cache, we fail to build it, because clang throws an error about the missing module map. This causes SourceKit to drop all semantic functionality, even if the missing module map isn’t required.

To work around this, drop all `-fmodule-map-file` arguments with missing files from the clang importer’s arguments, reporting the eror that `clang` would throw manually.

Fixes rdar://77449671
2021-05-06 10:23:58 +02:00
Alex Hoppen
74ff6923a1 [Sema] Don’t allow unresolved type variables if LeaveBraceStmtBodyUnchecked is true
According to Pavel, we want to eliminate allowing unresolved variables as much as possible. Removing this flag doesn’t break any test cases (at least not in a meaningful way) and fixes a crasher, so it seems reasonable to remove it.

Fixes rdar://76686564
2021-05-06 10:19:05 +02:00
Alex Hoppen
b1a4708782 [TypeChecker] Clear param specifiers before re-typechecking expression for completion
Because we are completing inside a result builder, we are never calling into `typeCheckExpression` and thus never call into `typeCheckForCodeCompletion` before `fallbackTypeCheck` (SR-14601).

This works fine in most cases, but in the added test case, we are hitting an assertion because the specifiers are not correctly erased from the `ClosureExpr` before re-typechecking for completion. Erasing them before fixes the test case until the underlying issue described above is fixed.

Fixes rdar://76710904 [SR-14494]
2021-05-06 10:00:25 +02:00
Owen Voorhees
9c02fd1d58 Merge pull request #37236 from owenv/serialize-digester-diag-flag
[APIDigester] Provide a category when serializing diagnostics representing API/ABI breakage
2021-05-05 20:12:09 -07:00
Holly Borla
96b0cb545f [CSApply] NFC: Clean up some duplicated logic for propagating
`async` from contextual types to closure types.

This preserves the behavior that `async` is propagated to closures that
should inherit the surrounding actor context, even if the closure is an
argument to a reasync function.
2021-05-05 18:49:38 -07:00
Ben Barham
398124c61a [Refactoring] Only unwrap optionals if the handler has an optional error
Resolves rdar://73973459
2021-05-06 10:27:34 +10:00
Andrew Trick
b0dc18dd04 Fix an assert in exclusivity diagnostics when inouts escape.
An error found in DiagnoseInvalidEscapingCaptures can indicate invalid
SIL, which will cause DiagnoseStaticExclusivity to assert during SIL
verification. When the source-level closure captures an inout
argument, it appears in SIL to be a non-escaping closure. The SIL
verification then fails because the "nonescaping" closure actually
escapes.

Ensure that capture diagnostics run on closures before exclusivity
enforcement runs on the parent function. Bypass the SIL verification
assert if a diagnostic error was found.

Fixes rdar://75364904 (Crash with assertion `noescape partial_apply
has unexpected use`)
2021-05-05 17:06:30 -07:00
Holly Borla
6eb133b627 Merge pull request #37263 from hborla/async-closure-diagnostics
[Concurrency] Improve diagnostics for missing `await`
2021-05-05 16:43:45 -07:00
Victoria Mitchell
4b5045f25a add "memberOf" relations for remote protocol implementations
rdar://75729692
2021-05-05 15:44:28 -06:00
Pavel Yaskevich
29cb7ddbcb [Diagnostics] Handle ambiguities related to use of nil literal
When `nil` is passed as an argument to call with multiple overloads
it's possible that this would result in ambiguity where matched
expected argument type doesn't conform to `ExpressibleByNilLiteral`.

To handle situations like this locator for contextual mismatch
has to be adjusted to point to the call where `nil` is used, so
`diagnoseAmbiguityWithFixes` can identify multiple overloads and
produce a correct ambiguity diagnostic.

Resolves: rdar://75514153
2021-05-05 12:56:25 -07:00
Holly Borla
b6a3434851 [Concurrency] Emit a tailored note for a missing await if the call is implicitly
asynchronous due to actor isolation.
2021-05-05 11:35:40 -07:00
Holly Borla
8e78c8b35c [CSApply] Propagate 'async' from contextual types to closures, unless the closure
is an argument to a 'reasync' function.
2021-05-05 11:35:40 -07:00
Pavel Yaskevich
af3dcf0b12 [Diagnostics] Add a tailored note for passing nil to incompatible argument position
New note mentions both expected argument type and its position
and anchors to the affected overload choice.
2021-05-05 11:00:57 -07:00
Pavel Yaskevich
2f44f5bcd6 [ConstraintSystem] Extract logic that identifies application based on its argument node 2021-05-05 11:00:57 -07:00
Pavel Yaskevich
f5e672e985 Merge pull request #37216 from xedin/rdar-70610141
[Diagnostics] Improve diagnostics when passing `async` to a sync parameter
2021-05-05 10:10:05 -07:00
Pavel Yaskevich
0cca70b916 Merge pull request #37260 from xedin/rdar-76475495
[Sema] Suppress concurrency related diagnostics for invalid AST nodes
2021-05-05 10:09:51 -07:00
Saleem Abdulrasool
0771f1ec86 Merge pull request #37211 from compnerd/windows-static-linking
IRGen: support static linking on Windows
2021-05-05 07:26:36 -07:00
Alex Hoppen
d974373f05 Merge pull request #37240 from ahoppen/pr/syntax-parsing-context-debug-utils
[libSyntax] Add a `dumpStack` method to `SyntaxParsingContext`
2021-05-05 15:26:10 +02:00
Xi Ge
c24b693e8c Merge pull request #37264 from nkcsgexi/underscore_version_canimport
Use underscored syntax for versioned canImport condition
2021-05-05 04:23:46 -07:00