Making sure we can use custom runtime attributes on a `distributed actor` even if only on distributed methods.
It seems we can't do this on non distributed methods, as the call is made cross actor so the distributed isolation prevents it. Not sure if that should be possible anyway -- as long as distributed funcs can be annotated the most important part works <3
Diagnose situations where a sub-class or a protocol do not have all
of the reflection metadata attributes required by a superclass.
Resolves: rdar://103990788
This is just a way to opt-out a type from use of the attribute,
there is no code generation for such cases because the attribute
could never be reached.
For instance methods type is going to require a value of type,
for static methods its metatype, which means it possible to
distinguish between instance and static methods and global functions.
Most of the diagnostics for extra/missing/mislabeled arguments refer
to argument to a "call". Some (but not call) would substitute in
"subscript". None would refer to an argument to a macro expansion
properly.
Rework all of these to refer to the argument in a call, subscript, or
macro expansion as appropriate. Fix up lots of tests that now say
"subscript" instead, and add tests for macro expansions.
Add support for global async functions and actor-isolated methods
by determining isolation context of the method attribute is associated
with and injecting try/await when appropriate.
Instead of passing an unapplied reference to a (either static or
instance) method, let's form a thunk and use it to forward arguments
to the underlying method invocation. This way it's possible to
get a uniform type for all instance methods that always starts
with `self` type and supports `mutating` methods by marking
`self` as `inout`.
The availability checker cannot handle purely synthesized code without
any source locations and declaration environment, so we have to disable
availability checking and synthesize `if #available` with correct
condition during body synthesis.
Make sure that:
- Functions/methods with the same name do not cause ambiguities
- New section is emitted that contains correct number of
attributes (with correct number of trailing entries)
- Accessible function is emitted per runtime attribute generator
- All generator definitions are emitted
The runtime discoverable attribute generator just like a default
argument or a property wrapper doesn't have a distinct name or
a declaration. Sema should synthesize a call that could be used
to obtain a value of an attribute type and everything else is
going to be synthesized in SILGen.
@<runtime-metadata-type> attribute is applicable to:
- Non-generic types
- global (non-generic) functions
- static and instance (non-generic) methods
- instance properties in concrete type context
- Infer type wrappers only from direct (declared on type) protocols
- Inferences from protocol to protocol is not allowed
- If type specifies a type wrapper attribute explicitly it has to
match the one associated with a declared protocol, otherwise the
declaration is going to be rejected as having multiple wrappers.
Adding a type wrapper attribute on a protocol does two things:
- Synthesizes `associatedtype $Storage` declaration with `internal` access
- Synthesizes `var $storage: <#Wrapper#><Self, Self.$Storage>` value requirement