@@ -1321,6 +1321,34 @@ class ExistentialTypeRepr: public TypeRepr {
13211321 friend class TypeRepr ;
13221322};
13231323
1324+ // / A type repr represeting the inverse of some constraint. For example,
1325+ // / ~Copyable
1326+ // / where `Copyable` is the constraint type.
1327+ class InverseTypeRepr : public TypeRepr {
1328+ TypeRepr *Constraint;
1329+ SourceLoc TildeLoc;
1330+
1331+ public:
1332+ InverseTypeRepr (SourceLoc tildeLoc, TypeRepr *constraint)
1333+ : TypeRepr(TypeReprKind::Inverse), Constraint(constraint),
1334+ TildeLoc (tildeLoc) {}
1335+
1336+ TypeRepr *getConstraint () const { return Constraint; }
1337+ SourceLoc getTildeLoc () const { return TildeLoc; }
1338+
1339+ static bool classof (const TypeRepr *T) {
1340+ return T->getKind () == TypeReprKind::Inverse;
1341+ }
1342+ static bool classof (const InverseTypeRepr *T) { return true ; }
1343+
1344+ private:
1345+ SourceLoc getStartLocImpl () const { return TildeLoc; }
1346+ SourceLoc getEndLocImpl () const { return Constraint->getEndLoc (); }
1347+ SourceLoc getLocImpl () const { return TildeLoc; }
1348+ void printImpl (ASTPrinter &Printer, const PrintOptions &Opts) const ;
1349+ friend class TypeRepr ;
1350+ };
1351+
13241352// / TypeRepr for a user-specified placeholder (essentially, a user-facing
13251353// / representation of an anonymous type variable.
13261354// /
@@ -1459,6 +1487,7 @@ inline bool TypeRepr::isSimple() const {
14591487 case TypeReprKind::Dictionary:
14601488 case TypeReprKind::Optional:
14611489 case TypeReprKind::ImplicitlyUnwrappedOptional:
1490+ case TypeReprKind::Inverse:
14621491 case TypeReprKind::Vararg:
14631492 case TypeReprKind::PackExpansion:
14641493 case TypeReprKind::Pack:
0 commit comments