Skip to content

Commit 4b8747e

Browse files
committed
[Sema] Made $main non-dynamic.
Previously, it was possible for $main to be made dynamic by passing -enable-implicit-dynamic. That has always been a problem in asserts builds because a direct function_ref to $main is created in the main function. More recently, it has become a problem in non-asserts builds because the dynamic replacements are now in the IR module but are not in the TBD file. Here, the function is marked as not dynamic. rdar://84962693
1 parent 17f1cf9 commit 4b8747e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,6 +2093,9 @@ SynthesizeMainFunctionRequest::evaluate(Evaluator &evaluator,
20932093
/*GenericParams=*/nullptr, ParameterList::createEmpty(context),
20942094
/*FnRetType=*/TupleType::getEmpty(context), declContext);
20952095
func->setSynthesized(true);
2096+
// It's never useful to provide a dynamic replacement of this function--it is
2097+
// just a pass-through to MainType.main.
2098+
func->setIsDynamic(false);
20962099

20972100
auto *params = context.Allocate<MainTypeAttrParams>();
20982101
params->mainFunction = mainFunction;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-swift-frontend -c -parse-as-library %s -enable-implicit-dynamic
2+
3+
@main
4+
struct BasicAppApp {
5+
static func main() {}
6+
}

0 commit comments

Comments
 (0)