Commit Graph

2 Commits

Author SHA1 Message Date
Chris Miles
f301746f52 Simplifies PlaygroundTransform tests by moving boilerplate code to a macro.
Defines the %target-playground-build-run-swift macro in the local lit config for PlaygroundTransform which contains all the boilerplate code used by most PlaygroundTransform tests:
* Build a PlaygroundSupport module
* Build the test source into an executable, linking PlaygroundSupport
* Codesign and run the executable
2024-12-07 13:15:09 -08:00
Anders Bertelrud
065eb832f8 [Playground] Missing playground results for init and deinit in a class wrapped in a struct (#77498)
The problem here is when wrapping a type that has constructors and destructors inside another type.

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 nested transformDecl() calls.  And that inner check was for too narrow of a type.

The problem in this case was that the `dyn_cast<FuncDecl>(D)` was too narrow and didn’t include constructors/destructors.  We want `dyn_cast<AbstractFunctionDecl>(D)`.

We should probably resolve this duality (using an `ASTWalker` to get to the top-level decls but then using directly nested calls below) at some point, but that’s a larger change, and so the specific problem covered by this commit is worth addressing with this safer short-term fix.

Changes:
- change a `dyn_cast<FuncDecl>` to a `dyn_cast<AbstractFunctionDecl>` in PlaygroundTransform.cpp
- add a unit test nested init and deinit (this test also tests the unnested case)

rdar://137316110
2024-12-04 11:55:28 -08:00