Skip to content

Request-ify synthesis of the main function for the @main attribute #32767

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
merged 5 commits into from
Jul 9, 2020

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jul 8, 2020

Now that EmittedMembersRequest is cached, we need to synthesize it when collecting all the members of the class. Use a request for this, instead of just doing it from the AttributeChecker.

Also add some SILGen tests to ensure that the main function is actually emitted; previously we didn't test for this.

This fixes the regression from #32581.

@slavapestov slavapestov requested a review from nate-chandler July 8, 2020 23:21
@slavapestov
Copy link
Contributor Author

CC @compnerd

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

test/SILGen/` Outdated
@@ -0,0 +1,17 @@
// RUN: %target-swift-emit-silgen -parse-as-library %s
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is called (`), is this expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's a mistake. oops

This simplifies matters if checking an attribute adds members
to the nominal type or extension.
@slavapestov slavapestov force-pushed the requestify-main-attr branch from 188e0d5 to 7bc5088 Compare July 9, 2020 01:39
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@compnerd
Copy link
Member

compnerd commented Jul 9, 2020

@swift-ci please test Windows platform

@slavapestov slavapestov merged commit 3d6d186 into swiftlang:master Jul 9, 2020
auto &context = D->getASTContext();

MainTypeAttr *attr = D->getAttrs().getAttribute<MainTypeAttr>();
if (attr == nullptr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be an assert instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants