@@ -296,17 +296,53 @@ bool SILModule::isTypeMetadataForLayoutAccessible(SILType type) {
296
296
return ::isTypeMetadataForLayoutAccessible (*this , type);
297
297
}
298
298
299
- bool AbstractStorageDecl::exportsPropertyDescriptor () const {
300
- // The storage needs a descriptor if it sits at a module's ABI boundary,
301
- // meaning it has public linkage.
302
-
299
+ static bool isUnsupportedKeyPathValueType (Type ty) {
300
+ // Visit lowered positions.
301
+ if (auto tupleTy = ty->getAs <TupleType>()) {
302
+ for (auto eltTy : tupleTy->getElementTypes ()) {
303
+ if (eltTy->is <PackExpansionType>())
304
+ return true ;
305
+
306
+ if (isUnsupportedKeyPathValueType (eltTy))
307
+ return true ;
308
+ }
309
+
310
+ return false ;
311
+ }
312
+
313
+ if (auto objTy = ty->getOptionalObjectType ())
314
+ ty = objTy;
315
+
316
+ // FIXME: Remove this once isUnimplementableVariadicFunctionAbstraction()
317
+ // goes away in SILGenPoly.cpp.
318
+ if (auto funcTy = ty->getAs <FunctionType>()) {
319
+ for (auto param : funcTy->getParams ()) {
320
+ auto paramTy = param.getPlainType ();
321
+ if (paramTy->is <PackExpansionType>())
322
+ return true ;
323
+
324
+ if (isUnsupportedKeyPathValueType (paramTy))
325
+ return true ;
326
+ }
327
+
328
+ if (isUnsupportedKeyPathValueType (funcTy->getResult ()))
329
+ return true ;
330
+ }
331
+
303
332
// Noncopyable types aren't supported by key paths in their current form.
304
333
// They would also need a new ABI that's yet to be implemented in order to
305
334
// be properly supported, so let's suppress the descriptor for now if either
306
335
// the container or storage type of the declaration is non-copyable.
307
- if (getValueInterfaceType ()->isPureMoveOnly ()) {
308
- return false ;
309
- }
336
+ if (ty->isPureMoveOnly ())
337
+ return true ;
338
+
339
+ return false ;
340
+ }
341
+
342
+ bool AbstractStorageDecl::exportsPropertyDescriptor () const {
343
+ // The storage needs a descriptor if it sits at a module's ABI boundary,
344
+ // meaning it has public linkage.
345
+
310
346
if (!isStatic ()) {
311
347
if (auto contextTy = getDeclContext ()->getDeclaredTypeInContext ()) {
312
348
if (contextTy->isPureMoveOnly ()) {
@@ -362,6 +398,10 @@ bool AbstractStorageDecl::exportsPropertyDescriptor() const {
362
398
llvm_unreachable (" should be definition linkage?" );
363
399
}
364
400
401
+ if (isUnsupportedKeyPathValueType (getValueInterfaceType ())) {
402
+ return false ;
403
+ }
404
+
365
405
// Subscripts with inout arguments (FIXME)and reabstracted arguments(/FIXME)
366
406
// don't have descriptors either.
367
407
if (auto sub = dyn_cast<SubscriptDecl>(this )) {
0 commit comments