@@ -2612,6 +2612,23 @@ TypeResolver::resolveAttributedType(TypeAttributes &attrs, TypeRepr *repr,
2612
2612
}
2613
2613
}
2614
2614
2615
+ if (attrs.has (TAK_unchecked)) {
2616
+ ty = resolveType (repr, options);
2617
+ if (!ty || ty->hasError ()) return ty;
2618
+
2619
+ if (!options.is (TypeResolverContext::Inherited) ||
2620
+ getDeclContext ()->getSelfProtocolDecl ()) {
2621
+ diagnoseInvalid (repr, attrs.getLoc (TAK_unchecked),
2622
+ diag::unchecked_not_inheritance_clause);
2623
+ } else if (!ty->isConstraintType ()) {
2624
+ diagnoseInvalid (repr, attrs.getLoc (TAK_unchecked),
2625
+ diag::unchecked_not_existential, ty);
2626
+ }
2627
+
2628
+ // Nothing to record in the type. Just clear the attribute.
2629
+ attrs.clearAttribute (TAK_unchecked);
2630
+ }
2631
+
2615
2632
auto instanceOptions = options;
2616
2633
instanceOptions.setContext (None);
2617
2634
@@ -2778,20 +2795,6 @@ TypeResolver::resolveAttributedType(TypeAttributes &attrs, TypeRepr *repr,
2778
2795
}
2779
2796
}
2780
2797
2781
- if (attrs.has (TAK_unchecked)) {
2782
- if (!options.is (TypeResolverContext::Inherited) ||
2783
- getDeclContext ()->getSelfProtocolDecl ()) {
2784
- diagnoseInvalid (repr, attrs.getLoc (TAK_unchecked),
2785
- diag::unchecked_not_inheritance_clause);
2786
- } else if (!ty->isExistentialType ()) {
2787
- diagnoseInvalid (repr, attrs.getLoc (TAK_unchecked),
2788
- diag::unchecked_not_existential, ty);
2789
- }
2790
-
2791
- // Nothing to record in the type. Just clear the attribute.
2792
- attrs.clearAttribute (TAK_unchecked);
2793
- }
2794
-
2795
2798
for (unsigned i = 0 ; i != TypeAttrKind::TAK_Count; ++i)
2796
2799
if (attrs.has ((TypeAttrKind)i)) {
2797
2800
diagnoseInvalid (repr, attrs.getLoc ((TypeAttrKind)i),
0 commit comments