Commit Graph

10 Commits

Author SHA1 Message Date
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