Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/Sema/TypeCheckDeclPrimary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2706,6 +2706,15 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
if (!PBD->isInitialized(i))
continue;

if (PBD->isInitializerSubsumed(i)) {
auto *var = PBD->getSingleVar();
// The initializer of a property wrapped variable gets transferred
// the synthesized backing storage property, let have it contextualized
// there.
if (var && var->hasAttachedPropertyWrapper())
continue;
}

if (!PBD->isInitializerChecked(i)) {
TypeCheckExprOptions options;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// RUN: %target-typecheck-verify-swift

enum CustomError: Error {
}

struct ValidationError: Error {
}

func parseOption(_: String) throws -> Int {
42
}

@propertyWrapper
public struct Option<Value> {
public var wrappedValue: Value

public init(
wrappedValue: Value,
transform: @Sendable @escaping (String) throws -> Value
) {
self.wrappedValue = wrappedValue
}
}

struct Test {
@Option(transform: {
do {
return try parseOption($0)
} catch let error as CustomError {
throw ValidationError()
}
})
var prop: Int = 0
}