Rather than getting ahold of the BitwiseCopyable protocol and doing a
pointer comparison to another ProtocolDecl, check whether the latter's
known protocol kind is ::BitwiseCopyable.
It makes sense to form an existential of a type that conforms to
`BitwiseCopyable` but such an existential is not itself trivial and
consequently not `BitwiseCopyable`.
Previously, the diagnostics for conforming a non-escaping or
non-copyable type to `_BitwiseCopyable` were emitted even in the case of
an implicit check for conformance. Here this is fixed to suppress the
diagnostics in the case of an implicit check as is done for other
diagnostics.
Functions can in fact conform to some protocols, notably,
marker protocols. Dynamically they have no influence on whether the cast
will succeed or not, as there is no way to tell if a type conforms to
such a protocol at runtime. But we should check them statically because
they otherwise can be cast to Any eventually.
There's no good reason to permit them. Conformances like Copyable and
Sendable are pervasive, so it's as though we are permitting extensions
of `Any`. Until there's a good argument in favor of such extensions,
remove the capability now.
Unify with `CTP_ReturnStmt`, and have the
SyntacticElementTarget carry the ReturnStmt for
regular type-checking, which we can use to record
implied returns.
Track the implied result exprs in the constraint
system, and allow arbitrary propagation of
implied results down if/switch expression
branches. This is required for allowing implied
results in non-single-expression closures.
Historically, we checked against a specific allowlist for a certain set
of types that were allowed to introduce an `_ObjectiveCBridgeable`
conformance in a different module that where the type was defined.
This rigid allow-list isn't really buying us much, but it's getting in
the way of some refactoring for swift-foundation that's changing
the layering. Remove this diagnostic, since it really isn't buying us
much nowadays, and we have the more general warnings about retroactive
conformances to make folks think twice.
An unbound generic type is not something that should end up in
`isNoncopyable` or `isEscapable` queries because there are no
conformances for such a type; it's unbound!
fixes test/Constraints/closures.swift
We let TypeCheckAttr diagnose illega uses of the attribute. In addition,
we need to exclude protocols from inferring a marking, because when we
build the StructuralRequirements for a protocol, we ignore the
"marking" this we'll miss this legacy attribute.
fixes Sema/moveonly_decl_attr.swift
Adding `move_value [lexical]` and `begin_borrow [lexical]` should happen
all the time at this point. Remove the ability to omit these
instructions and update the corresponding tests.