@@ -438,30 +438,25 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
438
438
// we're getting away with it because the types are guaranteed to already
439
439
// be imported.
440
440
ASTContext &ctx = getASTContext ();
441
- ModuleDecl *UIKit = ctx.getLoadedModule (ctx.getIdentifier (" UIKit" ));
441
+
442
+ std::pair<Identifier, SourceLoc> UIKitName =
443
+ {ctx.getIdentifier (" UIKit" ), SourceLoc ()};
444
+
445
+ ModuleDecl *UIKit = ctx
446
+ .getClangModuleLoader ()
447
+ ->loadModule (SourceLoc (), UIKitName);
448
+ assert (UIKit && " couldn't find UIKit objc module?!" );
442
449
SmallVector<ValueDecl *, 1 > results;
443
450
UIKit->lookupQualified (UIKit->getInterfaceType (),
444
451
ctx.getIdentifier (" UIApplicationMain" ),
445
452
NL_QualifiedDefault,
446
453
/* resolver*/ nullptr ,
447
454
results);
448
- assert (!results.empty () && " couldn't find UIApplicationMain in UIKit" );
449
-
450
- // We want the original UIApplicationMain() declaration from Objective-C,
451
- // not any overlay overloads.
452
- ValueDecl *UIApplicationMainDecl = nullptr ;
453
- for (auto *result : results) {
454
- if (result->hasClangNode ()) {
455
- assert (!UIApplicationMainDecl
456
- && " more than one UIApplicationMain defined in ObjC?!" );
457
- UIApplicationMainDecl = result;
458
- #ifndef NDEBUG
459
- break ;
460
- #endif
461
- }
462
- }
463
-
464
- assert (UIApplicationMainDecl && " no UIApplicationMain defined in ObjC?!" );
455
+ assert (results.size () == 1
456
+ && " couldn't find a unique UIApplicationMain in the UIKit ObjC "
457
+ " module?!" );
458
+
459
+ ValueDecl *UIApplicationMainDecl = results.front ();
465
460
466
461
auto mainRef = SILDeclRef (UIApplicationMainDecl).asForeign ();
467
462
auto UIApplicationMainFn = SGM.M .getOrCreateFunction (mainClass, mainRef,
0 commit comments