@@ -2612,6 +2612,23 @@ TypeResolver::resolveAttributedType(TypeAttributes &attrs, TypeRepr *repr,
26122612 }
26132613 }
26142614
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+
26152632 auto instanceOptions = options;
26162633 instanceOptions.setContext (None);
26172634
@@ -2778,20 +2795,6 @@ TypeResolver::resolveAttributedType(TypeAttributes &attrs, TypeRepr *repr,
27782795 }
27792796 }
27802797
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-
27952798 for (unsigned i = 0 ; i != TypeAttrKind::TAK_Count; ++i)
27962799 if (attrs.has ((TypeAttrKind)i)) {
27972800 diagnoseInvalid (repr, attrs.getLoc ((TypeAttrKind)i),
0 commit comments