mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Diagnose when @UIApplicationMain tries to coexist with a main.swift file.
Swift SVN r18072
This commit is contained in:
@@ -290,7 +290,10 @@ void SourceLookupCache::lookupClassMember(AccessPathTy accessPath,
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Module::Module(Identifier name, ASTContext &ctx)
|
||||
: DeclContext(DeclContextKind::Module, nullptr), Ctx(ctx), Name(name) {
|
||||
: DeclContext(DeclContextKind::Module, nullptr), Ctx(ctx), Name(name),
|
||||
DiagnosedMultipleMainClasses(false),
|
||||
DiagnosedMainClassWithScript(false)
|
||||
{
|
||||
ctx.addDestructorCleanup(*this);
|
||||
}
|
||||
|
||||
@@ -1090,6 +1093,20 @@ bool Module::registerMainClass(ClassDecl *mainClass, SourceLoc diagLoc) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Complain if there is also a script file in this module.
|
||||
if (!DiagnosedMainClassWithScript) {
|
||||
DiagnosedMainClassWithScript = true;
|
||||
for (auto file : getFiles()) {
|
||||
auto sf = dyn_cast<SourceFile>(file);
|
||||
if (!sf)
|
||||
continue;
|
||||
if (sf->isScriptMode()) {
|
||||
getASTContext().Diags.diagnose(diagLoc, diag::attr_UIApplicationMain_with_script);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MainClass = mainClass;
|
||||
MainClassDiagLoc = diagLoc;
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user