@@ -528,16 +528,21 @@ bool swift::isRepresentableInObjC(
528
528
Reason != ObjCReason::WitnessToObjC &&
529
529
Reason != ObjCReason::MemberOfObjCProtocol) {
530
530
if (Diagnose) {
531
- auto error = accessor->isGetter ()
532
- ? (isa<VarDecl>(storage)
533
- ? diag::objc_getter_for_nonobjc_property
534
- : diag::objc_getter_for_nonobjc_subscript)
535
- : (isa<VarDecl>(storage)
536
- ? diag::objc_setter_for_nonobjc_property
537
- : diag::objc_setter_for_nonobjc_subscript);
538
-
539
- accessor->diagnose (error);
540
- describeObjCReason (accessor, Reason);
531
+ if (accessor->isGetter ()) {
532
+ auto error = isa<VarDecl>(storage)
533
+ ? diag::objc_getter_for_nonobjc_property
534
+ : diag::objc_getter_for_nonobjc_subscript;
535
+
536
+ accessor->diagnose (error);
537
+ describeObjCReason (accessor, Reason);
538
+ } else if (accessor->isSetter ()) {
539
+ auto error = isa<VarDecl>(storage)
540
+ ? diag::objc_setter_for_nonobjc_property
541
+ : diag::objc_setter_for_nonobjc_subscript;
542
+
543
+ accessor->diagnose (error);
544
+ describeObjCReason (accessor, Reason);
545
+ }
541
546
}
542
547
return false ;
543
548
}
@@ -1443,19 +1448,9 @@ bool IsObjCRequest::evaluate(Evaluator &evaluator, ValueDecl *VD) const {
1443
1448
// Cannot be @objc.
1444
1449
}
1445
1450
1446
- // Perform some icky stateful hackery to mark this declaration as
1447
- // not being @objc.
1448
- auto makeNotObjC = [&] {
1449
- if (auto objcAttr = VD->getAttrs ().getAttribute <ObjCAttr>()) {
1450
- objcAttr->setInvalid ();
1451
- }
1452
- };
1453
-
1454
1451
// If this declaration should not be exposed to Objective-C, we're done.
1455
- if (!isObjC) {
1456
- makeNotObjC ();
1452
+ if (!isObjC)
1457
1453
return false ;
1458
- }
1459
1454
1460
1455
if (auto accessor = dyn_cast<AccessorDecl>(VD)) {
1461
1456
auto storage = accessor->getStorage ();
@@ -1479,23 +1474,17 @@ bool IsObjCRequest::evaluate(Evaluator &evaluator, ValueDecl *VD) const {
1479
1474
Optional<ForeignAsyncConvention> asyncConvention;
1480
1475
Optional<ForeignErrorConvention> errorConvention;
1481
1476
if (auto var = dyn_cast<VarDecl>(VD)) {
1482
- if (!isRepresentableInObjC (var, *isObjC)) {
1483
- makeNotObjC ();
1477
+ if (!isRepresentableInObjC (var, *isObjC))
1484
1478
return false ;
1485
- }
1486
1479
} else if (auto subscript = dyn_cast<SubscriptDecl>(VD)) {
1487
- if (!isRepresentableInObjC (subscript, *isObjC)) {
1488
- makeNotObjC ();
1480
+ if (!isRepresentableInObjC (subscript, *isObjC))
1489
1481
return false ;
1490
- }
1491
1482
} else if (isa<DestructorDecl>(VD)) {
1492
1483
// Destructors need no additional checking.
1493
1484
} else if (auto func = dyn_cast<AbstractFunctionDecl>(VD)) {
1494
1485
if (!isRepresentableInObjC (
1495
- func, *isObjC, asyncConvention, errorConvention)) {
1496
- makeNotObjC ();
1486
+ func, *isObjC, asyncConvention, errorConvention))
1497
1487
return false ;
1498
- }
1499
1488
}
1500
1489
1501
1490
// Note that this declaration is exposed to Objective-C.
0 commit comments