Commit Graph

22 Commits

Author SHA1 Message Date
Slava Pestov
5e1e18424b AST: Clean up ExistentialLayout for ParameterizedProtocolType 2024-10-22 20:14:44 -04:00
Slava Pestov
79e9b96835 AST: Fix ExistentialLayout::isObjC() handling of marker protocols
Fixes rdar://problem/119541554.
2023-12-15 15:33:44 -05:00
Kavon Farvardin
63b3e7624d [NCGenerics] fold InverseType into PCT
We already need to track the inverses separate from the members in a
ProtocolCompositionType, since inverses aren't real types. Thus, the
only purpose being served by InverseType is to be eliminated by
RequirementLowering when it appears in a conformance requirement.

Instead, we introduce separate type InverseRequirement just to keep
track of which inverses we encounter to facilitate cancelling-out
defaults and ensuring that the inverses are respected after running
the RequirementMachine.
2023-12-07 22:14:23 -08:00
Kavon Farvardin
2cd298926f [NCGenerics] fix existential conformances
I was not expanding default requirements in
AbstractGenericSignatureRequest or ExistentialLayout.

Also fixes printing of composition types.
2023-11-15 15:43:11 -08:00
Pavel Yaskevich
b39947967b [AST] Add a missing check for Sendable in single protocol existential case
`any Sendable` should be considered Objective-C capable just like
it's protocol composition with other Objective-C capable types.

Resolves: rdar://102728938
2023-10-30 10:21:41 -07:00
Kavon Farvardin
1d75960da7 [Sema] lay groundwork for noncopyable existentials 2023-10-27 15:01:10 -07:00
Kavon Farvardin
a92181827a [Sema] handle inverses everywhere
Previously, inverses were only accounted-for in inheritance clauses.

This batch of changes handles inverses appearing in other places, like:

- Protocol compositions
- `some ~Copyable`
- where clauses

with proper attribution of default requirements in their absence.
2023-10-27 15:01:10 -07:00
John McCall
5519749ade [NFC] Collect protocol decls, not type, in ExistentialLayout
Another thing that will be necessary for correctness with
compositions of parameterized protocols.
2022-04-11 22:15:16 -04:00
John McCall
524ef5daa9 [NFC] Make ExistentialLayout store the presence of parameterized protocols
This is preparation for supporting parameterized protocols in
protocol compositions.  The `sameTypeRequirements` field will
probably have to go; it's just not general enough to capture
what we want.  That's assuming that we keep ExistentialLayout
in the long term at all, of course.
2022-04-11 22:14:21 -04:00
Slava Pestov
7e5d6f4cb0 AST: Rework ParameterizedProtocolTypes to store multiple argument types
For now, this is NFC since we still assume one argument elsewhere.
2022-02-18 18:22:20 -05:00
Slava Pestov
aa67c8bf8a Parametrized => parameterized 2022-02-03 13:27:24 -05:00
Slava Pestov
8f2e11a6a8 AST: ExistentialLayout support for ParametrizedProtocolType 2022-01-26 00:11:38 -05:00
Varun Gandhi
96a332e865 [NFC] Remove redundant includes for llvm/ADT/SmallVector.h. 2020-05-31 13:07:45 -07:00
Davide Italiano
7934190598 [ExistentialLayout] Introduce getKind() and use it.
Suggested by John McCall.
2018-07-26 19:41:58 -07:00
Slava Pestov
45fb11ce3c AST: Add ExistentialLayout::getSuperclass(), rename superclass to explicitSuperclass
More groundwork for protocols with superclass constraints.
In several places we need to distinguish between existential
types that have a superclass term (MyClass & Proto) and
existential types containing a protocol with a superclass
constraint.

This is similar to how I can write 'AnyObject & Proto', or
write 'Proto1 & Proto2' where Proto1 has an ': AnyObject'
in its inheritance clause.

Note that some of the usages will be revisited later as
I do more refactoring and testing. This is just a first pass.
2018-07-02 22:06:33 -07:00
Huon Wilson
ef8d71b01e [AST] Avoid getProtocols on a temporary ExistentialLayout now and forever.
Also, make ExistentialLayout non-self-referential, by moving that logic to the
point where it is used. The construction of the one-element-ArrayRef is so cheap
that it doesn't need to be cached.
2018-04-04 19:40:38 +10:00
Sho Ikeda
cea6c03eb2 [gardening] Use !empty() over size() > 0 2018-03-08 09:21:09 +09:00
David Zarzycki
2f95fc4459 [AST] NFC: Do not reinterpret_cast 'Type'
Found while doing a performance experiment with the 'Type' type wall.
2018-01-30 10:42:21 -05:00
Slava Pestov
4fd870b81d AST: Change ExistentialLayout::requiresClass from a field to a method
We need to compute it lazily to avoid calling
ProtocolDecl::requiresClass() before the protocol's
inheritance clause has been type checked.
2017-05-01 15:49:03 -07:00
Slava Pestov
db58e02cb2 Sema: Hook up layout constraints to the solver
There were various problems with layout constraints either
being ignored or handled incorrectly. Now that I've exercised
this support with an upcoming patch, there are some fixes
here.

Also, introduce a new ExistentialLayout::getLayoutConstriant()
which returns a value for existentials which are class-constrained
but don't have a superclass or any class-constrained protocols;
an example would be AnyObject, or AnyObject & P for some
non-class protocol P.

NFC for now, since these layout-constrained existentials cannot
be constructed yet.
2017-04-13 21:17:05 -07:00
Slava Pestov
c38f53d128 AST: Add ExistentialLayout::isErrorExistential() 2017-04-12 00:07:29 -07:00
Slava Pestov
9c3b514c7e AST: New getExistentialLayout() method on TypeBase and CanType
This consolidates calculations which need to look at every
protocol in an existential type. Soon we will also have to
deal with superclass constrained existentials, so start
updating call sites that look at all protocols to use the
new ExistentialLayout and correctly handle a class constraint
as well.

Also, eventually I will kill off the AnyObject protocol and
model it as a protocol composition with no protocols or
superclass, but the requiresClass() flag set.

This is not quite modeled this way yet and AnyObject still
exists, but the new abstraction is a step in the right
direction.
2017-04-10 17:04:37 -07:00