@@ -1532,48 +1532,6 @@ class NominalOrBoundGenericNominalType : public AnyGenericType {
15321532};
15331533DEFINE_EMPTY_CAN_TYPE_WRAPPER (NominalOrBoundGenericNominalType, AnyGenericType)
15341534
1535- // / InverseType represents the "inverse" of a ProtocolType as a constraint.
1536- // / An inverse represents the _absence_ of an implicit constraint to the given
1537- // / protocol.
1538- // /
1539- // / Otherwise, an inverse is not a real type! It's an annotation for other types
1540- // / to signal whether an implicit requirement on that type should be omitted.
1541- // / Because that annotation is expressed in the surface language as if it _were_
1542- // / a type (that is, as a type constraint) we still model it as a Type through
1543- // / typechecking.
1544- class InverseType final : public TypeBase {
1545- Type protocol;
1546-
1547- InverseType (Type type,
1548- const ASTContext *canonicalContext,
1549- RecursiveTypeProperties properties)
1550- : TypeBase(TypeKind::Inverse, canonicalContext, properties),
1551- protocol (type) {
1552- assert (protocol->is <ProtocolType>());
1553- }
1554-
1555- public:
1556- // / Produce an inverse constraint type for the given protocol type.
1557- static Type get (Type protocolType);
1558-
1559-
1560- // / Obtain the underlying \c ProtocolType that was inverted.
1561- Type getInvertedProtocol () const {
1562- return protocol;
1563- }
1564-
1565- // / Get known kind of inverse this type represents.
1566- InvertibleProtocolKind getInverseKind () const ;
1567-
1568- // Implement isa/cast/dyncast/etc.
1569- static bool classof (const TypeBase *T) {
1570- return T->getKind () == TypeKind::Inverse;
1571- }
1572- };
1573- BEGIN_CAN_TYPE_WRAPPER (InverseType, Type)
1574- PROXY_CAN_TYPE_SIMPLE_GETTER(getInvertedProtocol)
1575- END_CAN_TYPE_WRAPPER(InverseType, Type)
1576-
15771535// / ErrorType - Represents the type of an erroneously constructed declaration,
15781536// / expression, or type. When creating ErrorTypes, an associated error
15791537// / diagnostic should always be emitted. That way when later stages of
@@ -5813,6 +5771,9 @@ class ProtocolCompositionType final : public TypeBase,
58135771 // / Constructs a protocol composition corresponding to the `AnyObject` type.
58145772 static Type theAnyObjectType (const ASTContext &C);
58155773
5774+ // / Constructs a protocol composition corresponding to the `~IP` type.
5775+ static Type getInverseOf (const ASTContext &C, InvertibleProtocolKind IP);
5776+
58165777 // / Canonical protocol composition types are minimized only to a certain
58175778 // / degree to preserve ABI compatibility. This routine enables performing
58185779 // / slower, but stricter minimization at need (e.g. redeclaration checking).
@@ -7296,8 +7257,7 @@ inline bool TypeBase::isConstraintType() const {
72967257inline bool CanType::isConstraintTypeImpl (CanType type) {
72977258 return (isa<ProtocolType>(type) ||
72987259 isa<ProtocolCompositionType>(type) ||
7299- isa<ParameterizedProtocolType>(type) ||
7300- isa<InverseType>(type));
7260+ isa<ParameterizedProtocolType>(type));
73017261}
73027262
73037263inline bool TypeBase::isExistentialType () {
@@ -7313,7 +7273,6 @@ inline bool CanType::isExistentialTypeImpl(CanType type) {
73137273 isa<ProtocolCompositionType>(type) ||
73147274 isa<ExistentialType>(type) ||
73157275 isa<ParameterizedProtocolType>(type);
7316- // TODO(kavon): treat InverseType as an existential, etc?
73177276}
73187277
73197278inline bool CanType::isAnyExistentialTypeImpl (CanType type) {
0 commit comments