forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 30
Merge main 2021-04-20 #3009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Merge main 2021-04-20 #3009
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rdar://75741632
…smatch involving tuple destructuring
Co-authored-by: Franklin Schrans <7278429+franklinsch@users.noreply.github.com>
This patch migrates this test off of using runAsyncAndBlock so that we can eventually delete that function.
This patch plumbs through the ability to run async code in the standard library unittests. The async start-point is `runAllTestsAsync` and must be called from an async context. For now, that means calling through async-main.
As suggested by @atrick in review feedback in swiftlang#36913.
implemenation -> implementation
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.
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]
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.
An older Swift compiler failed to account for the witnesses in a conformance with platform availability having their own availability, which causes that compiler to reject the Swift module's .swiftinterface file when it includes `AnyHashable` 's conformance to `_HasCustomAnyHashableRepresentation`. Work around the issue by making the one witness (`_toCustomAnyHashable`, which is trivial) always-emit-into-client, so it does not need any availability. Fixes rdar://76370138.
…qualified type. When referencing a function that is on a global actor, e.g., @mainactor func doSomething() -> Int the result of that reference is a global-actor-qualified function type, e.g., @mainactor () -> Int Part of rdar://76030136.
…references Check actor isolation of calls to functions with global-actor-qualified type. This closes a pre-existing loophole where a value of global-actor-qualified function type could be called from any context. Paired with this, references to global-actor-qualified function declarations will get global-actor-qualified function type whenever they are referenced within an experience, i.e., whenever we form a value of that type. Such references can occur anywhere (one does not need to be on the actor), and carrying the global actor along with the function type ensures that they can only be called from the right actor. For example: @mainactor func onlyOnMainActor() { ... } func callIt(_ fn: @mainactor () -> Void) { fn() // error: not on the main actor, so cannot synchronously call // this wasn't previously diagnosed } func passIt() { callIt(onlyOnMainActor) // okay to pass the function // used to be an error } While here, fix up some broken substitution logic for global-actor-qualified function types and "override" actor isolation.
We don't want the debugger stepping into these.
This saves us from needing to re-match args to params in CSApply and is also useful for a forthcoming change migrating code completion in argument position to use the solver-based typeCheckForCodeCompletion api. rdar://76581093
…ms-in-extensions [Index] Index generic parameters used inside extensions
…pr-in-closure [Parse] Create SwitchStmt nodes for `switch` statements with errors
Combine IsNotRecommended with NotRecommendedReason and improve the names of the existing cases to more clearly identify the cases they apply to. Now all not-recommended completions are required to have a reason.
[Sema] Fix stale reference passed to PlaceholderType::get
…42712db9c300fa9fbe3d98f [silmem2reg] Compute DomTreeLevels lazily.
…mprovement [completion] Clarify and simplify not-recommended state
…Pointer rdar://72164992
…o wip-cleaner-abi-asynclet
…heritance [SymbolGraph] Add information about "inherited docs" for synthesized symbols
ClangImporter: add some error-recovery code path for TypeBase::wrapInPointer
…rialization/android-modules.swift
[Concurrency] Store child record when async let child task spawned
…data flow diagnostics (swiftlang#36952) * [Diagnostics] Use DeclDescriptiveKind on data flow diagnostics to improve diagnostic message * [tests] Add regression tests to SILOptimizer/return.swift * [tests] Adapt other tests to changes of SR-14505 * [Diagnostics] Adapt message for missing return diagnostics, remove article * [Diagnostics] Adapt message for missing return diagnostics to have a note with fix * [tests] Adjust tests in validation suit
6fd3d0d
to
ef4b0e6
Compare
6d544c0
to
fde4ec9
Compare
MaxDesiatov
approved these changes
Apr 21, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.