Commit Graph

4 Commits

Author SHA1 Message Date
Slava Pestov
19d283d9dc AST: Replace ImplicitlyUnwrappedOptionalAttr with Decl::{is,set}ImplicitlyUnwrappedOptional() 2019-08-15 18:41:41 -04:00
Slava Pestov
2e635e9603 Sema: Add @_hasInitialValue and @_hasStorage in typeCheckDecl() not validateDecl()
We only ever use this in TBDGen and interface printing, and we only ever
generate TBD files or print interfaces for declarations in primary files,
so let's avoid unnecessary work in validateDecl().

Eventually we want validateDecl() to be replaced with a getInterfaceType()
request, so adding new attributes in this path (or other side effects in
general) is a big no-no.
2019-01-02 15:12:02 -05:00
Harlan Haskins
a1c23be91a [ParseableInterface] Standardize printing for accessors
We want to make sure we are consistent when printing accessors.
@jrose-apple and I landed on the following table for disambiguating all
the possible combinations of accessors:

\### Computed Properties

| Semantics  | Syntax                 |
|------------|------------------------|
| Read-only  | var x: T { get }       |
| Read-write | var x: T { get set }   |

\### Stored Properties

| Semantics                | Syntax                              |
|--------------------------|-------------------------------------|
| Immutable                | let x: T                            |
| Mutable (trivial setter) | var x: T                            |
| Mutable (custom setter)  | @_hasStorage var x: T { get set }   |
| Private(set)             | @_hasStorage var x: T { get }       |

This first commit enables printing @_hasStorage outside of SIL mode.
2018-11-26 18:40:37 -08:00
Huon Wilson
7753383223 [AST] Add @_hasInitialValue to var/lets that have initializers.
The information about whether a variable/property is initialized is lost in the
public interface, but is, unfortunately, required because it results in a symbol
for the initializer (if a class/struct `init` is inlined, it will call
initializers for properties that it doesn't initialize itself). This is
important to preserve for TBD file generation.

Using an attribute rather than just a bit on the VarDecl means this fits into
the scheme for module interfaces: textual/valid Swift.
2018-08-07 09:54:35 +10:00