Skip to content

Commit 0bd7621

Browse files
authored
Merge pull request #27198 from theblixguy/fix/SR-11478
[PropertyWrapper] Fix a bug with static property wrapper being rejected in a class
2 parents 3ab346b + 7ff3fd1 commit 0bd7621

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/Sema/TypeCheckStorage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,8 +2349,8 @@ PropertyWrapperBackingPropertyInfoRequest::evaluate(Evaluator &evaluator,
23492349
pbdPattern->setType(storageType);
23502350
pbdPattern = TypedPattern::createImplicit(ctx, pbdPattern, storageType);
23512351
auto pbd = PatternBindingDecl::createImplicit(
2352-
ctx, backingVar->getCorrectStaticSpelling(), pbdPattern,
2353-
/*init*/nullptr, dc, SourceLoc());
2352+
ctx, var->getCorrectStaticSpelling(), pbdPattern,
2353+
/*init*/ nullptr, dc, SourceLoc());
23542354
addMemberToContextIfNeeded(pbd, dc, var);
23552355
pbd->setStatic(var->isStatic());
23562356

test/decl/var/property_wrappers.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,3 +1646,22 @@ struct UseNonMutatingProjectedValueSet {
16461646
x = 42 // expected-error{{cannot assign to property: 'self' is immutable}}
16471647
}
16481648
}
1649+
1650+
// SR-11478
1651+
1652+
@propertyWrapper
1653+
struct SR_11478_W<Value> {
1654+
var wrappedValue: Value
1655+
}
1656+
1657+
class SR_11478_C1 {
1658+
@SR_11478_W static var bool1: Bool = true // Ok
1659+
@SR_11478_W class var bool2: Bool = true // expected-error {{class stored properties not supported in classes; did you mean 'static'?}}
1660+
@SR_11478_W class final var bool3: Bool = true // expected-error {{class stored properties not supported in classes; did you mean 'static'?}}
1661+
}
1662+
1663+
final class SR_11478_C2 {
1664+
@SR_11478_W static var bool1: Bool = true // Ok
1665+
@SR_11478_W class var bool2: Bool = true // expected-error {{class stored properties not supported in classes; did you mean 'static'?}}
1666+
@SR_11478_W class final var bool3: Bool = true // expected-error {{class stored properties not supported in classes; did you mean 'static'?}}
1667+
}

0 commit comments

Comments
 (0)