Commit Graph

46922 Commits

Author SHA1 Message Date
eeckstein
f53f80ff04 Merge pull request #36928 from eeckstein/module-build-error-message
ModuleInterfaceBuilder: give a more specific error message in case of a compiler mismatch
2021-04-16 08:55:32 +02:00
Holly Borla
0445ff91c5 Merge pull request #36934 from hborla/enclosing-self-availability
[Property Wrappers] Fix availability inference for enclosing self property wrappers.
2021-04-15 21:41:46 -07:00
Holly Borla
5bda9bd0c1 Merge pull request #36939 from hborla/wrapped-parameter-diagnostics
[ConstraintSystem] Fix a few diagnostic bugs for inferred property wrapper types.
2021-04-15 19:52:04 -07:00
Slava Pestov
c88c96778f AST: Fix issue where SIL type lowering did not commute with subst()
SIL type lowering uses ReplaceOpaqueTypesWithUnderlyingTypes to lower away
opaque result types when the current context can "see" the underlying type
of the opaque result type.

To determine if an opaque result type could be replaced with its
underlying type, we check if every nominal type declaration appearing
in the "fully substituted" underlying type is visible from the current
context.

To form the "fully substituted" type, we first apply the substitution map
stored in the opaque type decl, which replaces the 'Self' generic parameter
with the actual concrete result type.

Then, we apply the substitution map stored in the archetype itself.

However, calling subst() on an opaque archetype modifies the substitution
map stored in the archetype.

What this means in practice is that if I have an opaque type declaration
that depends on its outer generic parameters, the fully-substituted type
that I see here depends on whether subst() has been performed or not.

For example, suppose I have the following:

    protocol P {}
    struct S : P {}
    extension P {
      func foo() -> some Any { return [self] }
    }

The opaque result decl for P.foo() maps 'Self' to 'Array<Self>'. Now,
imagine someone calls foo() with the substitution 'Self := S'. The
fully-substituted underlying type is 'Array<S>'. If 'S' is private, we
will decide that we cannot replace the opaque result type with its
underlying type. However, if we had performed the opaque type replacement
_before_ substituting 'Self := S', then we will end up replacing the
opaque result type.

To re-state this in yet another form, we want the following identity to
hold here:

    getLoweredType(opaqueType).subst(subMap) == getLoweredType(opaqueType.subst(subMap))

We can ensure that this holds by only applying the archetype's
substitutions _after_ we check visibility.

Fixes rdar://problem/76556368.
2021-04-15 22:23:07 -04:00
Holly Borla
b11f465561 [ConstraintSystem] Fix a few diagnostic bugs when an inferred property
wrapper type is a hole or a structural type.
2021-04-15 16:49:25 -07:00
Luciano Almeida
f40b9b6c29 [Sema] Minor adjusting on RemoveExtraneousArguments record logic 2021-04-15 20:33:46 -03:00
swift-ci
c475105941 Merge pull request #36933 from nate-chandler/wrangle/test/IRGen/partial_apply_run_generic_method1.sil 2021-04-15 15:00:18 -07:00
swift-ci
b941835484 Merge pull request #35398 from kavon/async-initializers 2021-04-15 14:27:09 -07:00
Doug Gregor
c1328bd83f Merge pull request #36857 from DougGregor/import-concurrency-by-default-take-2
Enable import of the _Concurrency module by default.
2021-04-15 13:12:45 -07:00
Holly Borla
b774acd1f0 [Property Wrappers] If a property wrapper accessor is synthesized using the
enclosing-self subscript, infer availability from accessors on the subscript
declaration.
2021-04-15 12:44:16 -07:00
Nate Chandler
2bf2391759 [Test] Ease partial_apply_run_generic_method1.sil checks for arm64e. 2021-04-15 12:31:01 -07:00
Becca (née Brent) Royal-Gordon
6e710b2806 Merge pull request #36594 from beccadax/nonstandard-library
Preload standard library in ModuleInterfaceBuilder
2021-04-15 10:43:28 -07:00
Alex Hoppen
0bc679c6e9 Merge pull request #36927 from ahoppen/pr/fast-completion-bug
[CodeCompletion] Reset diagnostics when reusing an ASTContext for completion
2021-04-15 19:14:32 +02:00
Pavel Yaskevich
b245257716 Merge pull request #36893 from xedin/rdar-55369704
[Diagnostics] Filter operators if all their arguments are holes
2021-04-15 10:10:31 -07:00
Kavon Farvardin
4a32b06f8d add new tests for async initializers 2021-04-15 10:08:58 -07:00
Kavon Farvardin
be9890815a update existing regression tests after small diagnostics refactor
new phrasing in the error messages to match up with
other phrasing used in messages.
2021-04-15 10:08:58 -07:00
Kavon Farvardin
4f6eb85fe3 allow type initializers to be 'async'
implicit calls to an async super.init are not allowed
2021-04-15 10:08:53 -07:00
Alex Hoppen
931f3394d7 [Parse] Create SwitchStmt nodes for switch statements with errors
At the moment, if there is an error in the `switch` statement expression or if the `{` is missing, we return `nullptr` from `parseStmtSwitch`, but we consume tokens while trying to parse the `switch` statement. This causes the AST to not contain any nodes for the tokens that were consumed while trying to parse the `switch` statement.

While this doesn’t cause any issues during compilation (compiling fails anyway so not having the `switch` statement in the AST is not a problem) this causes issues when trying to complete inside an expression that was consumed while trying to parse the `switch` statement but doesn’t have a representation in the AST. The solver-based completion approach can’t find the expression that contains the completion token (because it’s not part of the AST) and thus return empty results.

To fix this, make sure we are always creating a `SwitchStmt` when consuming tokens for it.

Previously, one could always assume that a `SwitchStmt` had a valid `LBraceLoc` and `RBraceLoc`. This is no longer the case because of the recovery. In order to form the `SwitchStmt`’s `SourceRange`, I needed to add a `EndLoc` property to `SwitchStmt` that keeps track of the last token in the `SwitchStmt`. Theoretically we should be able to compute this location by traversing the right brace, case stmts, subject expression, … in reverse order until we find something that’s not missing. But if the `SubjectExpr` is an `ErrorExpr`, representing a missing expression, it might have a source range that points to one after the last token in the statement (this is due to the way the `ErrorExpr` is being constructed), therefore returning an invalid range. So overall I thought it was easier and safer to add another property.

Fixes rdar://76688441 [SR-14490]
2021-04-15 18:37:25 +02:00
Doug Gregor
b331c62ef9 Merge pull request #36926 from DougGregor/extract-executor-embarrassments 2021-04-15 07:40:01 -07:00
Erik Eckstein
d49de1a982 ModuleInterfaceBuilder: give a more specific error message in case of a compiler mismatch 2021-04-15 14:06:17 +02:00
Alex Hoppen
6085e1dca4 [CodeCompletion] Reset diagnostics when reusing an ASTContext for completion
The diagnosticc engine is keeping track of state which might modify parsing/typechecking behaviour. In the added test case the `fatalErrorOccurred` flag was during the first completion. The flag was still `true` for the second completion, causing parsing/typechecking to behave slightly differently. Because of this, the ExprRewriter failed when applying a constraint system solution, not properly cleaning up its `ExprStack`.

This PR tackles both issues:
1) Reset the `hadError` flags in the diagnostics engine
2) Clean up the `ExprRewriter`’s `ExprStack` when rewriting a target fails.

Either of these changes fixes the crash in the test case but I think both could manifest through different code paths in different scenarios.

Fixes rdar://76051976 [SR-14430]
2021-04-15 13:07:27 +02:00
Alex Hoppen
053a4d7ec8 [Index] Index generic parameters used inside extensions
Extensions redeclare all generic parameters of their extended type to add their additional restrictions. There are two issues with this model for indexing:
 - The generic paramter declarations of the extension are implicit so we wouldn't report them in the index. Any usage of the generic param in the extension references this implicit declaration so we don't include it in the index either.
 - The implicit re-declarations have their own USRs so any usage of a generic parameter inside an extension would use a different USR than declaration of the param in the extended type.

To fix these issues, we replace the reference to the implicit generic parameter defined in the extension by a reference to the generic paramter defined in the extended type.
2021-04-15 08:55:47 +02:00
Doug Gregor
4e306bb8ab Revert "[Test] Disable failing concurrency tests on Linux."
This reverts commit 766bf78eea.
2021-04-14 23:33:51 -07:00
Doug Gregor
8db916c973 Revert "[Tests] NFC: Disable concurrency data race detection test on all platforms"
This reverts commit 6139a4fea4.
2021-04-14 23:33:51 -07:00
Alex Hoppen
7123d2614b Merge pull request #36880 from ahoppen/pr/cursor-info-protocol-var
[ASTPrinter] Don't transform type if current type can't have members
2021-04-15 08:20:25 +02:00
swift-ci
367305b5b9 Merge pull request #36919 from ktoso/wip-detach-signature 2021-04-14 17:30:18 -07:00
Becca Royal-Gordon
28c260e38d Disable ModuleInterface/BadStdlib.swiftinterface on Windows (SR-14489) 2021-04-14 17:29:51 -07:00
Pavel Yaskevich
2de9053dae [Diagnostics] Filter operators if all their arguments are holes
Restrict filtering in `simplifyAppliedOverloadsImpl` to disable
overload set for operators only, because other calls e.g. regular
functions or subscripts could be filtered on labels and are less
overloaded.

Filtering non-operator calls could also lead to incorrect diagnostics
because first choice could have all sorts of different issues e.g.
incorrect labels and number of parameters.

Resolves: rdar://55369704
2021-04-14 15:44:13 -07:00
Evan Wilde
b4e6a9b2b0 Migrate remaining tests 2021-04-14 15:04:56 -07:00
Evan Wilde
51a36a6455 Move test/IRGen/async/throwing.swift to async-main
This patch migrates this test off of using runAsyncAndBlock so that we
can eventually delete that function.
2021-04-14 15:04:56 -07:00
Konrad `ktoso` Malawski
5e0593f1d3 [Concurrency] detach should not take Failure type param 2021-04-15 06:59:35 +09:00
Artem Chikin
b15f77db28 Merge pull request #36820 from artemcm/BetterModuleArchNotFoundMsg
Add location to the `sema_no_import_target` diagnostic
2021-04-14 13:29:19 -07:00
Pavel Yaskevich
6139a4fea4 [Tests] NFC: Disable concurrency data race detection test on all platforms 2021-04-14 13:22:45 -07:00
nate-chandler
3f6eb2f8a0 Merge pull request #36899 from nate-chandler/wrangle/76080265
[Test] Disabled Interpreter/SDK/cf_without_foundation.swift on watchos.
2021-04-14 10:56:38 -07:00
Holly Borla
766bf78eea [Test] Disable failing concurrency tests on Linux. 2021-04-14 10:44:46 -07:00
Doug Gregor
2e8689644b Disable _Concurrency import in one more test 2021-04-14 09:08:08 -07:00
Holly Borla
57aa7e4e0a Merge pull request #36900 from drodriguez/windows-unsupported-async_task_yield
[windows][test] Unsupport async_task_yield in OS=windows-msvc
2021-04-14 08:41:13 -07:00
David Zarzycki
b26e38e485 Merge pull request #36890 from davezarzycki/pr36890
Add missing `REQUIRES: concurrency`
2021-04-14 08:45:04 -04:00
Luciano Almeida
c1f43c8cc6 [tests] [SR-12483] Adding regression tests 2021-04-14 09:29:08 -03:00
Luciano Almeida
5db573326e Merge pull request #36904 from LucianoPAlmeida/destructure-fix-it
[Sema] Adding a space in closure parameter destructuring fix in cases closure body is empty
2021-04-14 09:09:09 -03:00
Erik Eckstein
6ec788ff09 SIL: remove the SILOpenedArchetypesTracker
Instead, put the archetype->instrution map into SIlModule.

SILOpenedArchetypesTracker tried to maintain and reconstruct the mapping locally, e.g. during a use of SILBuilder.
Having a "global" map in SILModule makes the whole logic _much_ simpler.

I'm wondering why we didn't do this in the first place.

This requires that opened archetypes must be unique in a module - which makes sense. This was the case anyway, except for keypath accessors (which I fixed in the previous commit) and in some sil test files.
2021-04-14 08:36:10 +02:00
Erik Eckstein
e5e28ff4c4 SILGen: avoid reusing the same opened archetype in keypath setter and getter functions. 2021-04-14 08:36:10 +02:00
Doug Gregor
568e943115 Enable import of the _Concurrency module by default. 2021-04-13 23:14:06 -07:00
Luciano Almeida
3d784687e4 [Sema] Adding a space in closure parameter destructuring fix in cases closure body is empty to avoid invalid inlet code 2021-04-13 23:46:54 -03:00
swift-ci
24bed82e19 Merge pull request #36898 from nate-chandler/wrangle/76611676 2021-04-13 19:37:18 -07:00
Doug Gregor
78cb4fff7e Fix iOS availability 2021-04-13 18:16:47 -07:00
swift-ci
fb55cedfbc Merge pull request #36892 from nate-chandler/wrangle/back_deployment_runtime 2021-04-13 18:00:54 -07:00
Daniel Rodríguez Troitiño
49be0b8829 [windows][test] Unsupport async_task_yield in OS=windows-msvc
The test crashes in both the VS2017 and VS2019 CI machines.

See https://bugs.swift.org/browse/SR-14333 for more of these problems.
2021-04-13 17:16:09 -07:00
Nate Chandler
b8b6d9cb39 [Test] Disabled Interpreter/SDK/cf_without_foundation.swift on watchos.
rdar://76080265
2021-04-13 16:59:27 -07:00
Nate Chandler
03678af9d3 [Test] Disabled Concurrency/Runtime/executor_deinit1.swift on iphonesimulator-x86_64.
rdar://76611676
2021-04-13 16:46:21 -07:00