@@ -4770,6 +4770,21 @@ TypeResolver::resolveDeclRefTypeRepr(DeclRefTypeRepr *repr,
47704770 auto *dc = getDeclContext ();
47714771 auto &ctx = getASTContext ();
47724772
4773+ // Gate the 'Escapable' type behind a specific flag for now.
4774+ //
4775+ // NOTE: we do not return an ErrorType, though! We're just artificially
4776+ // preventing people from referring to the type without the feature.
4777+ if (auto proto = result->getAs <ProtocolType>()) {
4778+ if (auto known = proto->getKnownProtocol ()) {
4779+ if (*known == KnownProtocolKind::Escapable
4780+ && !isSILSourceFile ()
4781+ && !ctx.LangOpts .hasFeature (Feature::NonescapableTypes)) {
4782+ diagnoseInvalid (repr, repr->getLoc (),
4783+ diag::escapable_requires_feature_flag);
4784+ }
4785+ }
4786+ }
4787+
47734788 if (ctx.LangOpts .hasFeature (Feature::ImplicitSome) &&
47744789 options.isConstraintImplicitExistential ()) {
47754790 // Check whether this type is an implicit opaque result type.
@@ -5774,10 +5789,9 @@ NeverNullType TypeResolver::resolveInverseType(InverseTypeRepr *repr,
57745789 if (auto kind = getInvertibleProtocolKind (*kp)) {
57755790
57765791 // Gate the '~Escapable' type behind a specific flag for now.
5792+ // Uses of 'Escapable' itself are already diagnosed; return ErrorType.
57775793 if (*kind == InvertibleProtocolKind::Escapable &&
57785794 !getASTContext ().LangOpts .hasFeature (Feature::NonescapableTypes)) {
5779- diagnoseInvalid (repr, repr->getLoc (),
5780- diag::escapable_requires_feature_flag);
57815795 return wrapInExistential (ErrorType::get (getASTContext ()));
57825796 }
57835797
0 commit comments