@@ -2338,26 +2338,64 @@ static void synthesizeStubBody(AbstractFunctionDecl *fn, void *) {
2338
2338
return ;
2339
2339
}
2340
2340
2341
+ auto *staticStringDecl = ctx.getStaticStringDecl ();
2342
+ auto staticStringType = staticStringDecl->getDeclaredType ();
2343
+ auto staticStringInit = ctx.getStringBuiltinInitDecl (staticStringDecl);
2344
+
2345
+ auto *uintDecl = ctx.getUIntDecl ();
2346
+ auto uintType = uintDecl->getDeclaredType ();
2347
+ auto uintInit = ctx.getIntBuiltinInitDecl (uintDecl);
2348
+
2341
2349
// Create a call to Swift._unimplementedInitializer
2342
2350
auto loc = classDecl->getLoc ();
2343
2351
Expr *ref = new (ctx) DeclRefExpr (unimplementedInitDecl,
2344
2352
DeclNameLoc (loc),
2345
2353
/* Implicit=*/ true );
2354
+ ref->setType (unimplementedInitDecl->getInterfaceType ()
2355
+ ->removeArgumentLabels (1 ));
2346
2356
2347
2357
llvm::SmallString<64 > buffer;
2348
2358
StringRef fullClassName = ctx.AllocateCopy (
2349
2359
(classDecl->getModuleContext ()->getName ().str () +
2350
2360
" ." +
2351
2361
classDecl->getName ().str ()).toStringRef (buffer));
2352
2362
2353
- Expr *className = new (ctx) StringLiteralExpr (fullClassName, loc,
2363
+ auto *className = new (ctx) StringLiteralExpr (fullClassName, loc,
2354
2364
/* Implicit=*/ true );
2355
- Expr *call = CallExpr::createImplicit (ctx, ref, { className },
2356
- { ctx.Id_className });
2357
- ctor->setBody (BraceStmt::create (ctx, SourceLoc (),
2358
- ASTNode (call),
2359
- SourceLoc (),
2365
+ className->setBuiltinInitializer (staticStringInit);
2366
+ assert (isa<ConstructorDecl>(className->getBuiltinInitializer ().getDecl ()));
2367
+ className->setType (staticStringType);
2368
+
2369
+ auto *initName = new (ctx) MagicIdentifierLiteralExpr (
2370
+ MagicIdentifierLiteralExpr::Function, loc, /* Implicit=*/ true );
2371
+ initName->setType (staticStringType);
2372
+ initName->setBuiltinInitializer (staticStringInit);
2373
+
2374
+ auto *file = new (ctx) MagicIdentifierLiteralExpr (
2375
+ MagicIdentifierLiteralExpr::File, loc, /* Implicit=*/ true );
2376
+ file->setType (staticStringType);
2377
+ file->setBuiltinInitializer (staticStringInit);
2378
+
2379
+ auto *line = new (ctx) MagicIdentifierLiteralExpr (
2380
+ MagicIdentifierLiteralExpr::Line, loc, /* Implicit=*/ true );
2381
+ line->setType (uintType);
2382
+ line->setBuiltinInitializer (uintInit);
2383
+
2384
+ auto *column = new (ctx) MagicIdentifierLiteralExpr (
2385
+ MagicIdentifierLiteralExpr::Column, loc, /* Implicit=*/ true );
2386
+ column->setType (uintType);
2387
+ column->setBuiltinInitializer (uintInit);
2388
+
2389
+ Expr *call = CallExpr::createImplicit (
2390
+ ctx, ref, { className, initName, file, line, column }, {});
2391
+ call->setType (ctx.getNeverType ());
2392
+
2393
+ SmallVector<ASTNode, 2 > stmts;
2394
+ stmts.push_back (call);
2395
+ stmts.push_back (new (ctx) ReturnStmt (SourceLoc (), /* Result=*/ nullptr ));
2396
+ ctor->setBody (BraceStmt::create (ctx, SourceLoc (), stmts, SourceLoc (),
2360
2397
/* implicit=*/ true ));
2398
+ ctor->setBodyTypeCheckedIfPresent ();
2361
2399
}
2362
2400
2363
2401
static std::tuple<GenericEnvironment *, GenericParamList *, SubstitutionMap>
0 commit comments