mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SE-0258] Support initial values & explicit initialization arguments.
Allow both explicit initialization and initial values to work together, e.g., ``` @Clamping(min: 0, max: 255) var red: Int = 127 ``` gets initialized as ``` Clamping(initialValue: 127, min: 0, max: 255) ```
This commit is contained in:
@@ -1847,8 +1847,8 @@ PropertyWrapperBackingPropertyInfoRequest::evaluate(Evaluator &evaluator,
|
||||
}
|
||||
|
||||
// Get the property wrapper information.
|
||||
if (!var->allAttachedPropertyWrappersHaveInitialValueInit()) {
|
||||
assert(!originalInitialValue);
|
||||
if (!var->allAttachedPropertyWrappersHaveInitialValueInit() &&
|
||||
!originalInitialValue) {
|
||||
return PropertyWrapperBackingPropertyInfo(
|
||||
backingVar, storageVar, nullptr, nullptr, nullptr);
|
||||
}
|
||||
@@ -1859,9 +1859,10 @@ PropertyWrapperBackingPropertyInfoRequest::evaluate(Evaluator &evaluator,
|
||||
new (ctx) OpaqueValueExpr(var->getLoc(), var->getType(),
|
||||
/*isPlaceholder=*/true);
|
||||
Expr *initializer = buildPropertyWrapperInitialValueCall(
|
||||
var, storageType, origValue);
|
||||
typeCheckSynthesizedWrapperInitializer(pbd, backingVar, parentPBD,
|
||||
initializer);
|
||||
var, storageType, origValue,
|
||||
/*ignoreAttributeArgs=*/!originalInitialValue);
|
||||
typeCheckSynthesizedWrapperInitializer(
|
||||
pbd, backingVar, parentPBD, initializer);
|
||||
|
||||
return PropertyWrapperBackingPropertyInfo(
|
||||
backingVar, storageVar, originalInitialValue, initializer, origValue);
|
||||
|
||||
Reference in New Issue
Block a user