Commit Graph

9 Commits

Author SHA1 Message Date
Joe Groff
02e1f2ea15 IRGen: Fix key path generic environment marshalling for external property descriptors.
The layout of a computed key path component carries an argument buffer for captures, which has
the following layout:

```
---
captured values (subscript indices)
---
generic arguments
---
```

When we reference an externally-defined public property or subscript from a key path, and the
external declaration has a property descriptor, then the generic arguments for the external
declaration get appended to the end of this buffer, giving:

```
---
captured values (subscript indices)
---
generic arguments
---
external property's generic arguments
---
```

The convention for key path accessors to bind their generic environment is thus to unpack them
from the end of the argument buffer, so that the external keypath's accessors can find the
arguments to bind the external generic environment while still allowing the enclosing key path
to save the original captured generic environment (which may be necessary to capture the
appropriate conditional and/or retroactive `Equatable` and `Hashable` conformances for
subscript indices).

However, our code generation for binding the generic arguments out of the argument buffer
contained a flawed optimization: for a property, we know there are never any captured values,
so I had assumed that the generic parameters could always be bound from the beginning of the
argument buffer, assuming that the generic parameters make up the totality of the buffer. This
falls over for external property descriptor references when the key path itself captures a
generic environment, since the external property's expected generic environment appears after
the key path's original generic environment. We can fix this by removing the conditional
entirely, and always adjusting the offset we load the generic environment from to look at the
end of the buffer. Fixes rdar://125886333.
2024-04-25 10:36:13 -07:00
Arnold Schwaighofer
d2631c2cec SILGen: Fix property descriptor emission when enable-private-imports is enabled 2019-03-20 11:59:13 -07:00
Joe Groff
70c60e5186 KeyPaths: Make references to let properties properly immutable. 2018-08-17 10:59:36 -07:00
Joe Groff
c3eafcae0e IRGen: Use method dispatch thunks to identify resilient methods in key paths.
Client code doesn't necessarily know the dispatch table indexes (and in time, there may not even be such a thing), and the dispatch thunk is a stable ABI artifact that can reliably uniquely identify the thing.
2018-07-27 13:15:49 -07:00
Joe Groff
4098aa02c7 KeyPaths: Support instantiating property descriptors with captured arguments. 2018-07-25 14:28:33 -07:00
Joe Groff
fceea87bf4 KeyPaths: Support instantiating generic property descriptors from concrete contexts.
This is a bit easier than the fully general case where both the external descriptor and local pattern have captured arguments (because of generics or subscript indices) since we don't have to combine the two argument files in one component.
2018-07-25 11:09:04 -07:00
Joe Groff
3b9501a283 KeyPaths: Handle computed property descriptor instantiation w/o indexes or generics. 2018-07-25 11:09:04 -07:00
Joe Groff
e96472807f KeyPaths: Instantiate external property descriptors for stored properties. 2018-07-25 11:09:04 -07:00
Joe Groff
f1cd3122fc KeyPaths: Stub out support for instantiating external components with trivial descriptors. 2018-07-25 11:09:04 -07:00