Commit Graph

5 Commits

Author SHA1 Message Date
Joe Groff
6f2811110d Sema: discard self should not be allowed in inlinable methods of non-frozen types.
`discard self` requires knowledge of the internal layout of the type in order to clean
up its fields while bypassing its public `deinit`. Inlinable code can get copied into
and run from outside of the defining module, so this is impossible to implement.
Fixes rdar://160815058.
2025-10-17 16:14:58 -07:00
Joe Groff
7dbab5e929 Enable MoveOnlyResilientTypes feature. 2023-10-19 11:46:08 -07:00
Kavon Farvardin
4e7e6f41cb remove support for _forget, the old spelling of discard
resolves rdar://112549258
2023-08-11 15:42:25 -07:00
Michael Gottesman
d0938a906f [move-only] Ban resilient noncopyable types.
One can still in resilient frameworks have noncopyable frozen types.

This means that one cannot make a noncopyable:

1. Full resilient public type.
2. @usableFromInline type.

NOTE: One can still use a frozen noncopyable type as a usableFromInline class
field. I validated in the attached tests that we get the correct code
generation.

I also eliminated a small bug in TypeCheckDeclPrimary where we weren't using a
requestified attr check and instead were checking directly.

rdar://111125845
2023-06-21 16:57:44 -07:00
Kavon Farvardin
3e4bc82aa8 rename _forget to discard; deprecate _forget
SE-390 concluded with choosing the keyword discard rather than forget for
the statement that disables the deinit of a noncopyable type. This commit
adds parsing support for `discard self` and adds a deprecation warning for
`_forget self`.

rdar://108859077
2023-05-08 21:42:19 -07:00