Skip to content

Commit 047f51f

Browse files
committed
[Sema] TypeWrappers: Make sure that synthesized accessors for wrapped vars are not transparent
Type wrapped variables loose their storage and are accessed through `$Storage` and synthesized accessors cannot be transparent.
1 parent d341c41 commit 047f51f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: lib/Sema/TypeCheckStorage.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -2475,6 +2475,12 @@ IsAccessorTransparentRequest::evaluate(Evaluator &evaluator,
24752475

24762476
switch (accessor->getAccessorKind()) {
24772477
case AccessorKind::Get:
2478+
// Synthesized getter for a type wrapped variable is never transparent.
2479+
if (auto var = dyn_cast<VarDecl>(storage)) {
2480+
if (var->isAccessedViaTypeWrapper())
2481+
return false;
2482+
}
2483+
24782484
break;
24792485

24802486
case AccessorKind::Set:
@@ -2493,6 +2499,10 @@ IsAccessorTransparentRequest::evaluate(Evaluator &evaluator,
24932499
PropertyWrapperSynthesizedPropertyKind::Projection)) {
24942500
break;
24952501
}
2502+
2503+
// Synthesized setter for a type wrapped variable is never transparent.
2504+
if (var->isAccessedViaTypeWrapper())
2505+
return false;
24962506
}
24972507

24982508
if (auto subscript = dyn_cast<SubscriptDecl>(storage)) {

0 commit comments

Comments
 (0)