Skip to content

Prevent crash with -playground when -experimental-skip-non-inlinable-function-bodies-without-types also passed #71171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
2 changes: 1 addition & 1 deletion lib/Sema/PlaygroundTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ void swift::performPlaygroundTransform(SourceFile &SF, PlaygroundOptionSet Opts)

PreWalkAction walkToDeclPre(Decl *D) override {
if (auto *FD = dyn_cast<AbstractFunctionDecl>(D)) {
if (!FD->isImplicit()) {
if (!FD->isImplicit() && !FD->isBodySkipped()) {
if (BraceStmt *Body = FD->getBody()) {
const ParameterList *PL = FD->getParameters();
Instrumenter I(ctx, FD, RNG, Options, TmpNameIndex);
Expand Down
14 changes: 14 additions & 0 deletions test/PlaygroundTransform/skip_bodies_without_types.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -whole-module-optimization -module-name PlaygroundSupport -emit-module-path %t/PlaygroundSupport.swiftmodule -parse-as-library -c -o %t/PlaygroundSupport.o %S/Inputs/SilentPCMacroRuntime.swift %S/Inputs/PlaygroundsRuntime.swift
// RUN: %target-build-swift -emit-module -Xfrontend -experimental-skip-non-inlinable-function-bodies-without-types -Xfrontend -playground -I=%t %s
// REQUIRES: executable_test

import PlaygroundSupport

struct Foo {
func Bar() {
print("hello")
}
}

// This test will cause the frontend to crash without the fix for skipping playground transformation of functions that have skipped type information. If it doesn't crash, it passes.