mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SILGen: Cope with overloads when emitting artificial main for @UIApplicationMain.
The overlay may add overloads for UIApplicationMain for various reasons. When we generate the special `main` implementation for a `@UIApplicationMain` class, we want to call the original function from Objective-C, so pick that one where there are multiple overloads to choose from. Fixes rdar://problem/42352695.
This commit is contained in:
@@ -449,9 +449,24 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
|
||||
/*resolver*/nullptr,
|
||||
results);
|
||||
assert(!results.empty() && "couldn't find UIApplicationMain in UIKit");
|
||||
assert(results.size() == 1 && "more than one UIApplicationMain?");
|
||||
|
||||
auto mainRef = SILDeclRef(results.front()).asForeign();
|
||||
// We want the original UIApplicationMain() declaration from Objective-C,
|
||||
// not any overlay overloads.
|
||||
ValueDecl *UIApplicationMainDecl = nullptr;
|
||||
for (auto *result : results) {
|
||||
if (result->hasClangNode()) {
|
||||
assert(!UIApplicationMainDecl
|
||||
&& "more than one UIApplicationMain defined in ObjC?!");
|
||||
UIApplicationMainDecl = result;
|
||||
#ifndef NDEBUG
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
assert(UIApplicationMainDecl && "no UIApplicationMain defined in ObjC?!");
|
||||
|
||||
auto mainRef = SILDeclRef(UIApplicationMainDecl).asForeign();
|
||||
auto UIApplicationMainFn = SGM.M.getOrCreateFunction(mainClass, mainRef,
|
||||
NotForDefinition);
|
||||
auto fnTy = UIApplicationMainFn->getLoweredFunctionType();
|
||||
|
||||
Reference in New Issue
Block a user