Commit Graph

526 Commits

Author SHA1 Message Date
Pavel Yaskevich
5dded3da73 [Tests] NFC: Remove test-cases associated with TypeWrappers feature 2023-02-08 10:14:34 -08:00
Pavel Yaskevich
dd24033017 Merge pull request #63417 from xedin/attach-source-info-to-reflection-metadata-inits
[Sema] RuntimeMetadata: Attach source information to synthesized initializers
2023-02-06 09:37:09 -08:00
Konrad `ktoso` Malawski
12d1ebc4e7 fix the linkage of async func ptr to distributed accessors 2023-02-06 18:39:58 +09:00
Konrad `ktoso` Malawski
28e700d0c1 move tests 2023-02-06 14:19:46 +09:00
Konrad `ktoso` Malawski
a629fed157 [Distributed][CustomRuntimeAttrs] Add distributed actor test cases
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
2023-02-06 14:19:46 +09:00
Angela Laar
cba738961b [Sema] Prevent duplicate diagnostics in oqaque types 2023-02-03 18:12:07 -08:00
Angela Laar
c837baa313 [Sema] Diagnose DisallowedExistential in type resolution 2023-02-03 14:40:50 -08:00
Angela Laar
2c9ada1cef Test Explicit Existential with Implicit Some 2023-02-03 14:40:50 -08:00
Pavel Yaskevich
50c1f97656 [Sema] RuntimeMetadata: Attach source information to synthesized initializers
All the locations point to the attribute itself, expect to the custom arguments
they all have real locations.
2023-02-03 12:36:37 -08:00
Pavel Yaskevich
7a81eb3810 Merge pull request #63274 from xedin/runtime-metadata-impl-alignment
[AST/Sema] RuntimeMetadata: Align implementation with proposal
2023-02-01 12:37:24 -08:00
Anthony Latsis
3302b27df8 Merge pull request #62775 from AnthonyLatsis/sugar-type-members-2
Parser: Support member types with non-identifier qualifiers
2023-02-01 02:07:12 +03:00
Pavel Yaskevich
67b74a0633 [Sema] RuntimeMetadata: Diagnose missing explicit reflection metadata attributes
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
2023-01-30 14:14:47 -08:00
Sophia Poirier
7016679fa5 Merge pull request #63208 from sophiapoirier/require-pack-reference-within-pack-expansion
[Variadic Generics] require pack ident type within a pack expansion t…
2023-01-30 12:43:09 -08:00
Pavel Yaskevich
ec3534b9a5 [Sema] RuntimeMetadata: Make reflection metadata attribute a conformance requirement
If conforming type doesn't declare required set of reflection metadata
attributes (based on the protocol declaration) fail conformance via
extension.
2023-01-30 10:11:28 -08:00
Pavel Yaskevich
ffd5d9661e [AST] RuntimeMetadata: Reject attributes with custom arguments on protocol declarations 2023-01-30 10:11:28 -08:00
Pavel Yaskevich
42694d867c [AST] RuntimeMetadata: Allow use of reflection metadata attrs on unavailable extensions
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.
2023-01-30 10:11:21 -08:00
Anthony Latsis
792a9cf7c0 [DiagnosticsQoI] Sema: Use 'underlying' instead of 'concrete' in opaque result type diagnostic 2023-01-28 20:51:40 +03:00
Sophia Poirier
e8361dd8cd [Variadic Generics] fix tests incorrect pack expansion syntax in some tests, but also disable them due to triggering a constraints checker assertion 2023-01-27 16:50:40 -08:00
Anthony Latsis
9898fca5e2 Parser: Parse 'simple' types, not just identifiers, in obsoleted protocol composition syntax 2023-01-26 21:10:39 +03:00
Anthony Latsis
c46b7c1bd0 Parser: Parse member types with non-identifier qualifiers in type context 2023-01-26 20:49:33 +03:00
Pavel Yaskevich
477a54a145 [AST] RuntimeMetadata: Allow using enums as custom runtime metadata types 2023-01-24 14:16:36 -08:00
Luciano Almeida
f441e271a8 Merge pull request #62924 from LucianoPAlmeida/opaque-diags
[Diagnostics] Improving diagnostics for inference of opaque result concrete type
2023-01-18 08:38:26 -03:00
Pavel Yaskevich
b15e9aaf7a [AST] RuntimeMetadata: Generator context should match that of the decl its attached to
This makes it possible to to reference to `Self` if attribute is
attached to a method or a property of a nominal type.

Resolves: rdar://104210108
2023-01-16 15:07:27 -08:00
John McCall
55b72d4eb7 Fix the pretty-printing of pack expansion types to match the current design 2023-01-11 03:11:30 -05:00
Luciano Almeida
c6ea1f6611 [Diagnostics] Improving diagnostics for inference of opaque result concrete type 2023-01-09 09:41:54 -03:00
Holly Borla
6725f365ba [Variadic Generics] Update tests for syntax changes. 2023-01-07 09:50:14 -08:00
Pavel Yaskevich
099c643ff7 [Sema] RuntimeMetadata: Require "self" for both static and instance methods
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.
2023-01-03 13:34:14 -08:00
Pavel Yaskevich
1052a607d0 Merge pull request #62738 from xedin/runtime_attr_method_thunks
[Sema] RuntimeMetadata: Add support for mutating/async methods and functions via a thunk
2023-01-03 10:44:01 -08:00
Doug Gregor
af49a90dde Customize diagnostic text for extra/missing/mislabeled arguments for callee kind
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.
2023-01-02 21:22:04 -08:00
Pavel Yaskevich
23cf6a155c [Sema] RuntimeMetadata: Add support for async functions and actor methods
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.
2022-12-21 16:14:18 -08:00
Pavel Yaskevich
699ef07bae [Sema] RuntimeMetadata: Add support for mutating methods via a thunk
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`.
2022-12-21 16:11:14 -08:00
Pavel Yaskevich
932c6eb64d [Tests] RuntimeMetadata: Add test-cases for attributes on methods of inner types 2022-12-20 09:45:02 -08:00
Pavel Yaskevich
4a918324ce [Sema] RuntimeMetadata: Allow declaring init(attachedTo:) overloads in extensions 2022-12-20 09:45:02 -08:00
Pavel Yaskevich
02937a7165 [Sema] RuntimeMetadata: Supress attr inference for local types 2022-12-20 09:45:02 -08:00
Pavel Yaskevich
a98a35e2b3 [Sema] RuntimeMetadata: Verify that runtime attribute has a valid initializer 2022-12-20 09:45:01 -08:00
Pavel Yaskevich
5a1f197d9b [Sema] RuntimeMetadata: Workaround for availability checking of generator expressions
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.
2022-12-20 09:45:01 -08:00
Pavel Yaskevich
618b9d943a [Sema] RuntimeMetadata: Use CustomAttrTypeRequest while synthesizing generator expression
This would make sure that:

- CustomAttr gets a type set
- All of the explicitly provided generic arguments are respected
2022-12-20 09:45:01 -08:00
Pavel Yaskevich
76f352db3d [Sema/IRGen] NFC: add IRGen test for runtime discoverable attributes
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
2022-12-20 09:45:01 -08:00
Pavel Yaskevich
8a930095fe [AST/Sema] RuntimeMetadata: Switch generator synthesis to produce an expression
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.
2022-12-20 09:45:01 -08:00
Pavel Yaskevich
8e66f193c1 [AST/Sema] RuntimeMetadata: Add a way to retrieve runtime metadata attrs
Adds `ValueDecl::getRuntimeDiscoverableAttrs` which returns all
valid runtime discoverable attributes associated with the given
declaration.
2022-12-20 09:33:44 -08:00
Pavel Yaskevich
01fb1f8298 [Sema] RuntimeMetadata: Implement custom attribute placement validation
@<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
2022-12-20 09:33:44 -08:00
Holly Borla
29f6c0d9a9 [Parser] Parse 'each' as a contextual keyword applied to pack references. 2022-12-10 22:17:59 -08:00
Angela Laar
3b8cfca027 [test] Add more opaque return tests 2022-11-17 11:54:44 -08:00
Pavel Yaskevich
e762d20568 Merge pull request #61982 from xedin/type-wrappers-on-protocols
[Sema] TypeWrappers: Allow type wrappers on protocols and inference from them
2022-11-14 12:46:48 -08:00
Slava Pestov
8caeaa2f9e Sema: Ensure that generic parameters appearing in pack expansion patterns all have the same shape 2022-11-12 02:13:54 -05:00
Holly Borla
ee04cea679 [Sema] Fix an issue with existential return types when implicit some is enabled. 2022-11-11 15:16:06 -08:00
Holly Borla
c1dcb9c6f1 [FrontendOptions] Remove bespoke experimental feature flags for ImplicitSome and
VariadicGenerics in favor of -enable-experimental-feature X.
2022-11-11 10:14:08 -08:00
Holly Borla
7bf344e682 [TypeResolver] Enable 'some' elision for opaque result types. 2022-11-09 08:15:36 -08:00
Pavel Yaskevich
c003e69d6b [Sema] TypeWrappers: Allow type wrapper inference from protocol conformances
- 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.
2022-11-08 16:15:56 -08:00
Pavel Yaskevich
db4b6a5c0f [AST/Sema] TypeWrappers: Implement type wrappers on protocols
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
2022-11-07 14:55:05 -08:00