Skip to content

Commit db50701

Browse files
authored
Merge pull request #27212 from theblixguy/fix/SR-11478_5.1
[5.1] [PropertyWrapper] Fix a bug with static property wrapper being rejected in a class
2 parents a025ab4 + 239f32f commit db50701

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/Sema/CodeSynthesis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,8 +1779,8 @@ PropertyWrapperBackingPropertyInfoRequest::evaluate(Evaluator &evaluator,
17791779
pbdPattern->setType(storageType);
17801780
pbdPattern = TypedPattern::createImplicit(ctx, pbdPattern, storageType);
17811781
auto pbd = PatternBindingDecl::createImplicit(
1782-
ctx, backingVar->getCorrectStaticSpelling(), pbdPattern,
1783-
/*init*/nullptr, dc, SourceLoc());
1782+
ctx, var->getCorrectStaticSpelling(), pbdPattern,
1783+
/*init*/ nullptr, dc, SourceLoc());
17841784
addMemberToContextIfNeeded(pbd, dc, var);
17851785
pbd->setStatic(var->isStatic());
17861786

test/decl/var/property_wrappers.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,25 @@ struct UseNonMutatingProjectedValueSet {
11321132
}
11331133
}
11341134

1135+
// SR-11478
1136+
1137+
@propertyWrapper
1138+
struct SR_11478_W<Value> {
1139+
var wrappedValue: Value
1140+
}
1141+
1142+
class SR_11478_C1 {
1143+
@SR_11478_W static var bool1: Bool = true // Ok
1144+
@SR_11478_W class var bool2: Bool = true // expected-error {{class stored properties not supported in classes; did you mean 'static'?}}
1145+
@SR_11478_W class final var bool3: Bool = true // expected-error {{class stored properties not supported in classes; did you mean 'static'?}}
1146+
}
1147+
1148+
final class SR_11478_C2 {
1149+
@SR_11478_W static var bool1: Bool = true // Ok
1150+
@SR_11478_W class var bool2: Bool = true // expected-error {{class stored properties not supported in classes; did you mean 'static'?}}
1151+
@SR_11478_W class final var bool3: Bool = true // expected-error {{class stored properties not supported in classes; did you mean 'static'?}}
1152+
}
1153+
11351154
// SR-11381
11361155

11371156
@propertyWrapper

0 commit comments

Comments
 (0)