@@ -2484,10 +2484,16 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
24842484
24852485 // @_staticExclusiveOnly types cannot be put into 'var's, only 'let'.
24862486 if (auto SD = VD->getInterfaceType ()->getStructOrBoundGenericStruct ()) {
2487- if (SD->getAttrs ().hasAttribute <StaticExclusiveOnlyAttr>() &&
2487+ if (getASTContext ().LangOpts .hasFeature (Feature::StaticExclusiveOnly) &&
2488+ SD->getAttrs ().hasAttribute <StaticExclusiveOnlyAttr>() &&
24882489 !VD->isLet ()) {
2489- VD->diagnose (diag::attr_static_exclusive_only_let_only,
2490- VD->getInterfaceType ());
2490+ SD->getASTContext ().Diags .diagnoseWithNotes (
2491+ VD->diagnose (diag::attr_static_exclusive_only_let_only,
2492+ VD->getInterfaceType ()),
2493+ [&]() {
2494+ SD->diagnose (diag::attr_static_exclusive_only_type_nonmutating,
2495+ SD->getDeclaredInterfaceType ());
2496+ });
24912497 }
24922498 }
24932499 }
@@ -4236,10 +4242,16 @@ void TypeChecker::checkParameterList(ParameterList *params,
42364242 // @_staticExclusiveOnly types cannot be passed as 'inout', only as either
42374243 // a borrow or as consuming.
42384244 if (auto SD = param->getInterfaceType ()->getStructOrBoundGenericStruct ()) {
4239- if (SD->getAttrs ().hasAttribute <StaticExclusiveOnlyAttr>() &&
4245+ if (SD->getASTContext ().LangOpts .hasFeature (Feature::StaticExclusiveOnly) &&
4246+ SD->getAttrs ().hasAttribute <StaticExclusiveOnlyAttr>() &&
42404247 param->isInOut ()) {
4241- param->diagnose (diag::attr_static_exclusive_only_let_only_param,
4242- param->getInterfaceType ());
4248+ SD->getASTContext ().Diags .diagnoseWithNotes (
4249+ param->diagnose (diag::attr_static_exclusive_only_let_only_param,
4250+ param->getInterfaceType ()),
4251+ [&]() {
4252+ SD->diagnose (diag::attr_static_exclusive_only_type_nonmutating,
4253+ SD->getDeclaredInterfaceType ());
4254+ });
42434255 }
42444256 }
42454257 }
0 commit comments