Type checking of closure bodies does not invoke `TypeChecker::typeCheckStmtConditionElement()` so use of availability macros inside closure bodies written in fragile (inlinable) functions was undiagnosed. Move the diagnostic logic to `MiscDiagnostics.cpp` which implements diagnostics that are emitted regardless of the typechecking model used.
Additionally, remove the `DC->getAsDecl() != nullptr` check from `diagnoseHasSymbolCondition()` which was preventing similar fragile function diagnostics for `if #_hasSymbol` from being emitted when a closure was involved.
Resolves rdar://100581013
Fixes rdar://100872195 ( error: 'move' can only be applied to lvalues
error: Can not use feature when experimental move only is disabled!)
Identifiers with a single underscore are not reserved for use by the
language implementation. It is perfectly valid for a library to define
its own '_move'.
The contextual _move keyword should only be parse when it is followed by an lvalue, so should *not* conflict with user-defined '_move' functions.
https://github.com/apple/swift-evolution/blob/main/proposals/0366-move-function.md#source-compatibility
Revert "Remove properties from AST nodes"
This reverts commit e4b8a829fe.
Revert "Suppress more false-positive 'self is unused' warnings"
This reverts commit 35e028e5c2.
Revert "fix warning annotation in test"
This reverts commit dfa1fda3d3.
Revert "Permit implicit self for weak self captures in nonescaping closures in Swift 5 (this is an error in Swift 6)"
This reverts commit 94ef6c4ab4.
It's possible that TypeChecker::typeCheckStmt has did not propagate
`HadError` properly while checking the body of a function, so opaque
result checker has to be careful about requesting types from expressions.
Resolves: rdar://100066109
Replace the use of bool and pointer returns for
`walkToXXXPre`/`walkToXXXPost`, and instead use
explicit actions such as `Action::Continue(E)`,
`Action::SkipChildren(E)`, and `Action::Stop()`.
There are also conditional variants, e.g
`Action::SkipChildrenIf`, `Action::VisitChildrenIf`,
and `Action::StopIf`.
There is still more work that can be done here, in
particular:
- SourceEntityWalker still needs to be migrated.
- Some uses of `return false` in pre-visitation
methods can likely now be replaced by
`Action::Stop`.
- We still use bool and pointer returns internally
within the ASTWalker traversal, which could likely
be improved.
But I'm leaving those as future work for now as
this patch is already large enough.
The completion handler async replacement moved from being its own
attribute to being an availability attribute. This patch moves the
checking from being its own pass to being part of the availability
checking under the async availability checking diagnostic pass.
Originally move when it was in the stdlib as _move was behind a keyword but we
moved it in front to allow for some testing. Now that we are going with a
keyword (which we can't leave in/deprecate) move it behind the move only
experimental flag until this gets through evolution.
I did this by requiring this in the typechecker. This will ensure that when we
emit a move, we are guaranteed to have a value decl ref that we can evaluate. It also ensures that we can't _move fields.
auto
This cannot be represented in the ABI because we expect that the
opaque return type can be instantiated from the generic arguments
of its declaring context. Reconstructing type metadata for the
DynamicSelfType would require opaque return type instantiation
to also take the self *value*.
Fixes rdar://72407668 / https://github.com/apple/swift/issues/56367