Missing playground results for property accessors in a class wrapped in a struct #77530
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a decl that has properties with accessors (
get
,set
,willSet
,didSet
, etc) is nested inside another type, those accessor implementations aren't playground-transformed.Details
The reason is that the playground transform uses an
ASTWalker
to get to the top-level structure, but then once it’s inside a type, it does directly nestedtransformDecl()
calls. And that inner check is missing a case for accessors.This is a follow-on fix to #77498.
Future work
It's unfortunate that the playground transform reaches decls in two different ways (using an
ASTWalker
to get to the top-level decls but then using directly nested calls below). This seems to be worth resolving at some point (perhaps by using theASTWalker
for the whole traversal?), but that’s a larger change, and so this is worth addressing with a safer short-term fix.Changes
VarDecl
, and if so, callstransformDecl()
on each accessor in PlaygroundTransform.cpprdar://139656464