@@ -3038,6 +3038,15 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3038
3038
3039
3039
auto conformance = M.checkConformance (substType, bitwiseCopyableProtocol);
3040
3040
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
+
3041
3050
if (lowering.isTrivial () && !conformance) {
3042
3051
// A trivial type can lack a conformance in a few cases:
3043
3052
// (1) containing or being a resilient type
@@ -3054,6 +3063,7 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3054
3063
// struct S {
3055
3064
// unowned(unsafe) var o: AnyObject
3056
3065
// }
3066
+ // (5) being defined in a different module
3057
3067
bool hasNoNonconformingNode = visitAggregateLeaves (
3058
3068
origType, substType, forExpansion,
3059
3069
/* isLeafAggregate=*/
@@ -3072,7 +3082,11 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3072
3082
}
3073
3083
3074
3084
// 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;
3076
3090
},
3077
3091
/* visit=*/
3078
3092
[&](auto ty, auto origTy, auto *field, auto index) -> bool {
@@ -3128,7 +3142,11 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3128
3142
}
3129
3143
3130
3144
// 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;
3132
3150
});
3133
3151
if (hasNoNonconformingNode) {
3134
3152
llvm::errs () << " Trivial type without a BitwiseCopyable conformance!?:\n "
0 commit comments