Skip to content

Commit 779bf8e

Browse files
committed
[Property Wrappers] Ignore IBOutlet optionality diagnostics if the property
has an attached wrapper.
1 parent 6bd387e commit 779bf8e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,11 @@ void AttributeChecker::visitIBOutletAttr(IBOutletAttr *attr) {
828828
diagnoseAndRemoveAttr(attr, isError.getValue(),
829829
/*array=*/isArray, type);
830830

831+
// Skip remaining diagnostics if the property has an
832+
// attached wrapper.
833+
if (VD->hasAttachedPropertyWrapper())
834+
return;
835+
831836
// If the type wasn't optional, an array, or unowned, complain.
832837
if (!wasOptional && !isArray) {
833838
diagnose(attr->getLocation(), diag::iboutlet_non_optional, type);

test/attr/attr_iboutlet.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,16 @@ class NonObjC {}
171171
@IBOutlet weak var something: OX
172172
init() { }
173173
}
174+
175+
@propertyWrapper
176+
struct MyWrapper {
177+
var wrappedValue: AnyObject {
178+
get { fatalError() }
179+
set { }
180+
}
181+
}
182+
183+
@objc class WrappedIBOutlet {
184+
// Non-optional types are okay with property wrappers.
185+
@IBOutlet @MyWrapper var value: AnyObject
186+
}

0 commit comments

Comments
 (0)