File tree Expand file tree Collapse file tree 2 files changed +14
-22
lines changed Expand file tree Collapse file tree 2 files changed +14
-22
lines changed Original file line number Diff line number Diff line change @@ -820,6 +820,20 @@ bool SILDeclRef::isTransparent() const {
820
820
}
821
821
}
822
822
823
+ // To support using metatypes as type hints in Embedded Swift. A default
824
+ // argument generator might be returning a metatype, which we normally don't
825
+ // support in Embedded Swift, but to still allow metatypes as type hints, we
826
+ // make the generator always inline to the callee by marking it transparent.
827
+ if (getASTContext ().LangOpts .hasFeature (Feature::Embedded)) {
828
+ if (isDefaultArgGenerator () && hasDecl ()) {
829
+ auto *decl = getDecl ();
830
+ auto *param = getParameterAt (decl, defaultArgIndex);
831
+ Type paramType = param->getTypeOfDefaultExpr ();
832
+ if (paramType && paramType->is <MetatypeType>())
833
+ return true ;
834
+ }
835
+ }
836
+
823
837
if (hasDecl ()) {
824
838
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(getDecl ()))
825
839
return AFD->isTransparent ();
Original file line number Diff line number Diff line change @@ -1280,28 +1280,6 @@ void SILGenModule::postEmitFunction(SILDeclRef constant,
1280
1280
F->verifyIncompleteOSSA ();
1281
1281
1282
1282
emitDifferentiabilityWitnessesForFunction (constant, F);
1283
-
1284
- // To support using metatypes as type hints in Embedded Swift. A default
1285
- // argument generator might be returning a metatype, which we normally don't
1286
- // support in Embedded Swift, but to still allow metatypes as type hints, we
1287
- // make the generator always inline to the callee by marking it transparent.
1288
- if (M.getOptions ().EmbeddedSwift ) {
1289
- if (constant.isDefaultArgGenerator ()) {
1290
- bool isReturningMetatype = false ;
1291
- if (F->getLoweredFunctionType ()->getNumResults () == 1 ) {
1292
- if (F->getLoweredFunctionType ()
1293
- ->getSingleResult ()
1294
- .getSILStorageInterfaceType ()
1295
- .isMetatype ()) {
1296
- isReturningMetatype = true ;
1297
- }
1298
- }
1299
-
1300
- if (isReturningMetatype) {
1301
- F->setTransparent (IsTransparent);
1302
- }
1303
- }
1304
- }
1305
1283
}
1306
1284
1307
1285
void SILGenModule::emitDifferentiabilityWitnessesForFunction (
You can’t perform that action at this time.
0 commit comments