@@ -4770,6 +4770,21 @@ TypeResolver::resolveDeclRefTypeRepr(DeclRefTypeRepr *repr,
4770
4770
auto *dc = getDeclContext ();
4771
4771
auto &ctx = getASTContext ();
4772
4772
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
+
4773
4788
if (ctx.LangOpts .hasFeature (Feature::ImplicitSome) &&
4774
4789
options.isConstraintImplicitExistential ()) {
4775
4790
// Check whether this type is an implicit opaque result type.
@@ -5774,10 +5789,9 @@ NeverNullType TypeResolver::resolveInverseType(InverseTypeRepr *repr,
5774
5789
if (auto kind = getInvertibleProtocolKind (*kp)) {
5775
5790
5776
5791
// Gate the '~Escapable' type behind a specific flag for now.
5792
+ // Uses of 'Escapable' itself are already diagnosed; return ErrorType.
5777
5793
if (*kind == InvertibleProtocolKind::Escapable &&
5778
5794
!getASTContext ().LangOpts .hasFeature (Feature::NonescapableTypes)) {
5779
- diagnoseInvalid (repr, repr->getLoc (),
5780
- diag::escapable_requires_feature_flag);
5781
5795
return wrapInExistential (ErrorType::get (getASTContext ()));
5782
5796
}
5783
5797
0 commit comments