@@ -356,20 +356,22 @@ SILType::canUseExistentialRepresentation(SILModule &M,
356
356
357
357
auto layout = getASTType ().getExistentialLayout ();
358
358
359
+ switch (layout.getKind ()) {
360
+ // A class-constrained composition uses ClassReference representation;
361
+ // otherwise, we use a fixed-sized buffer.
362
+ case ExistentialLayout::Kind::Class:
363
+ return repr == ExistentialRepresentation::Class;
359
364
// The (uncomposed) Error existential uses a special boxed
360
- // representation. It can also adopt class references of bridged error types
361
- // directly.
362
- if (layout. isErrorExistential ())
365
+ // representation. It can also adopt class references of bridged
366
+ // error types directly.
367
+ case ExistentialLayout::Kind::Error:
363
368
return repr == ExistentialRepresentation::Boxed
364
369
|| (repr == ExistentialRepresentation::Class
365
370
&& isBridgedErrorClass (M, containedType));
366
-
367
- // A class-constrained composition uses ClassReference representation;
368
- // otherwise, we use a fixed-sized buffer.
369
- if (layout.requiresClass ())
370
- return repr == ExistentialRepresentation::Class;
371
-
372
- return repr == ExistentialRepresentation::Opaque;
371
+ case ExistentialLayout::Kind::Opaque:
372
+ return repr == ExistentialRepresentation::Opaque;
373
+ }
374
+ llvm_unreachable (" unknown existential kind!" );
373
375
}
374
376
case ExistentialRepresentation::Metatype:
375
377
return is<ExistentialMetatypeType>();
0 commit comments