@@ -3038,6 +3038,15 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
30383038
30393039 auto conformance = M.checkConformance (substType, bitwiseCopyableProtocol);
30403040
3041+ if (auto *nominal = substType.getAnyNominal ()) {
3042+ auto *module = nominal->getModuleContext ();
3043+ if (module && module ->isBuiltFromInterface ()) {
3044+ // Don't verify for types in modules built from interfaces; the feature
3045+ // may not have been enabled in them.
3046+ return ;
3047+ }
3048+ }
3049+
30413050 if (lowering.isTrivial () && !conformance) {
30423051 // A trivial type can lack a conformance in a few cases:
30433052 // (1) containing or being a resilient type
@@ -3054,6 +3063,7 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
30543063 // struct S {
30553064 // unowned(unsafe) var o: AnyObject
30563065 // }
3066+ // (5) being defined in a different module
30573067 bool hasNoNonconformingNode = visitAggregateLeaves (
30583068 origType, substType, forExpansion,
30593069 /* isLeafAggregate=*/
@@ -3072,7 +3082,11 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
30723082 }
30733083
30743084 // Resilient trivial types may not conform (case (1)).
3075- return nominal->isResilient ();
3085+ if (nominal->isResilient ())
3086+ return true ;
3087+
3088+ // Trivial types from other modules may not conform (case (5)).
3089+ return nominal->getModuleContext () != &M;
30763090 },
30773091 /* visit=*/
30783092 [&](auto ty, auto origTy, auto *field, auto index) -> bool {
@@ -3128,7 +3142,11 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
31283142 }
31293143
31303144 // Resilient trivial types may not conform (case (1)).
3131- return !nominal->isResilient ();
3145+ if (nominal->isResilient ())
3146+ return false ;
3147+
3148+ // Trivial types from other modules may not conform (case (5)).
3149+ return nominal->getModuleContext () == &M;
31323150 });
31333151 if (hasNoNonconformingNode) {
31343152 llvm::errs () << " Trivial type without a BitwiseCopyable conformance!?:\n "
0 commit comments