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.
This commit is contained in:
Slava Pestov
2017-04-13 01:27:44 -07:00
parent d58f049608
commit db58e02cb2
14 changed files with 96 additions and 68 deletions

View File

@@ -71,6 +71,8 @@ struct ExistentialLayout {
return multipleProtocols;
}
LayoutConstraint getLayoutConstraint() const;
private:
// Inline storage for 'protocols' member above when computing
// layout of a single ProtocolType

View File

@@ -434,11 +434,6 @@ public:
NominalTypeDecl *getAnyNominal() const;
GenericTypeDecl *getAnyGeneric() const;
/// Returns information about the layout constraint represented by
/// this type. If this type does not represent a layout constraint,
/// it returns an empty LayoutConstraint.
LayoutConstraint getLayoutConstraint() const;
CanType getAnyOptionalObjectType() const {
OptionalTypeKind kind;
return getAnyOptionalObjectTypeImpl(*this, kind);

View File

@@ -717,12 +717,6 @@ public:
/// concrete types to form the argument type.
bool isBindableTo(Type ty, LazyResolver *resolver);
/// \brief Retrieve the layout constraint of this type.
///
/// \returns The layout constraint of this type, or a null layout constraint
/// if it has no layout constraint.
LayoutConstraint getLayoutConstraint();
/// \brief Determines whether this type is permitted as a method override
/// of the \p other.
bool canOverride(Type other, OverrideMatchMode matchMode,