File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -415,8 +415,13 @@ void AttributeEarlyChecker::visitIBOutletAttr(IBOutletAttr *attr) {
415
415
if (!VD->getDeclContext ()->getSelfClassDecl () || VD->isStatic ())
416
416
diagnoseAndRemoveAttr (attr, diag::invalid_iboutlet);
417
417
418
- if (!VD->isSettable (nullptr ))
419
- diagnoseAndRemoveAttr (attr, diag::iboutlet_only_mutable);
418
+ if (!VD->isSettable (nullptr )) {
419
+ // Allow non-mutable IBOutlet properties in module interfaces,
420
+ // as they may have been private(set)
421
+ SourceFile *Parent = VD->getDeclContext ()->getParentSourceFile ();
422
+ if (!Parent || Parent->Kind != SourceFileKind::Interface)
423
+ diagnoseAndRemoveAttr (attr, diag::iboutlet_only_mutable);
424
+ }
420
425
421
426
// Verify that the field type is valid as an outlet.
422
427
auto type = VD->getType ();
Original file line number Diff line number Diff line change
1
+ // REQUIRES: objc_interop
2
+
3
+ // RUN: %empty-directory(%t)
4
+ // RUN: %target-swift-frontend -typecheck -enable-library-evolution -disable-objc-attr-requires-foundation-module -emit-parseable-module-interface-path %t/Foo.swiftinterface %s
5
+ // RUN: %FileCheck %s -input-file %t/Foo.swiftinterface
6
+ // RUN: %target-swift-frontend -build-module-from-parseable-interface %t/Foo.swiftinterface -o %t/Foo.swiftmodule
7
+
8
+ // Test the interface we generate for @IBOutlet private(set) properties is
9
+ // consumable.
10
+
11
+ @objc public class MyType { }
12
+
13
+ open class Bar {
14
+ // CHECK: @objc @IBOutlet weak public var foo: MyType! {
15
+ // CHECK-NEXT: get
16
+ // CHECK-NEXT: }
17
+ @IBOutlet public private( set) weak var foo : MyType !
18
+ }
You can’t perform that action at this time.
0 commit comments