File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -1794,9 +1794,15 @@ bool ValueDecl::canInferObjCFromRequirement(ValueDecl *requirement) {
1794
1794
1795
1795
SourceLoc ValueDecl::getAttributeInsertionLoc (bool forModifier) const {
1796
1796
if (auto var = dyn_cast<VarDecl>(this )) {
1797
- if (auto pbd = var->getParentPatternBinding ()) {
1798
- SourceLoc resultLoc = pbd->getAttrs ().getStartLoc (forModifier);
1799
- return resultLoc.isValid () ? resultLoc : pbd->getStartLoc ();
1797
+ // [attrs] var ...
1798
+ // The attributes are part of the VarDecl, but the 'var' is part of the PBD.
1799
+ SourceLoc resultLoc = var->getAttrs ().getStartLoc (forModifier);
1800
+ if (resultLoc.isValid ()) {
1801
+ return resultLoc;
1802
+ } else if (auto pbd = var->getParentPatternBinding ()) {
1803
+ return pbd->getStartLoc ();
1804
+ } else {
1805
+ return var->getStartLoc ();
1800
1806
}
1801
1807
}
1802
1808
Original file line number Diff line number Diff line change @@ -224,6 +224,7 @@ protocol optErrorProtocol {
224
224
225
225
@objc protocol optObjcAttributeProtocol {
226
226
optional func foo( _ x: Int ) // expected-error{{'optional' requirements are an Objective-C compatibility feature; add '@objc'}}{{3-3=@objc }}
227
+ optional var bar : Int { get } // expected-error{{'optional' requirements are an Objective-C compatibility feature; add '@objc'}}{{3-3=@objc }}
227
228
optional associatedtype Assoc // expected-error{{'optional' modifier cannot be applied to this declaration}} {{3-12=}}
228
229
}
229
230
You can’t perform that action at this time.
0 commit comments