20
20
#include " swift/AST/DiagnosticEngine.h"
21
21
#include " swift/AST/DiagnosticsSIL.h"
22
22
#include " swift/AST/Expr.h"
23
+ #include " swift/AST/FileUnit.h"
23
24
#include " swift/AST/GenericEnvironment.h"
24
25
#include " swift/AST/LazyResolver.h"
25
26
#include " swift/AST/Module.h"
28
29
#include " swift/AST/Pattern.h"
29
30
#include " swift/AST/PrettyStackTrace.h"
30
31
#include " swift/AST/PropertyWrappers.h"
32
+ #include " swift/AST/SourceFile.h"
31
33
#include " swift/AST/TypeDifferenceVisitor.h"
32
34
#include " swift/AST/Types.h"
33
35
#include " swift/ClangImporter/ClangModule.h"
@@ -3041,8 +3043,6 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3041
3043
AbstractionPattern origType,
3042
3044
CanType substType,
3043
3045
TypeExpansionContext forExpansion) {
3044
- if (!Context.LangOpts .hasFeature (Feature::BitwiseCopyable))
3045
- return ;
3046
3046
auto *bitwiseCopyableProtocol =
3047
3047
Context.getProtocol (KnownProtocolKind::BitwiseCopyable);
3048
3048
if (!bitwiseCopyableProtocol)
@@ -3057,10 +3057,20 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3057
3057
3058
3058
if (auto *nominal = substType.getAnyNominal ()) {
3059
3059
auto *module = nominal->getModuleContext ();
3060
- if (module && module->isBuiltFromInterface ()) {
3061
- // Don't verify for types in modules built from interfaces; the feature
3062
- // may not have been enabled in them.
3063
- return ;
3060
+ if (module) {
3061
+ if (module->isBuiltFromInterface ()) {
3062
+ // Don't verify for types in modules built from interfaces; the feature
3063
+ // may not have been enabled in them.
3064
+ return ;
3065
+ }
3066
+ auto *file = dyn_cast_or_null<FileUnit>(module->getModuleScopeContext ());
3067
+ if (file && file->getKind () == FileUnitKind::Source) {
3068
+ auto sourceFile = nominal->getParentSourceFile ();
3069
+ if (sourceFile && sourceFile->Kind == SourceFileKind::SIL) {
3070
+ // Don't verify for types in SIL files.
3071
+ return ;
3072
+ }
3073
+ }
3064
3074
}
3065
3075
}
3066
3076
@@ -3086,6 +3096,7 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3086
3096
// unconditionally but does in this case
3087
3097
// (8) being or containing the error type
3088
3098
// (9) explicitly suppressing conformance
3099
+ // (10) a layout constrained archetype
3089
3100
bool hasNoNonconformingNode = visitAggregateLeaves (
3090
3101
origType, substType, forExpansion,
3091
3102
/* isLeafAggregate=*/
@@ -3155,7 +3166,7 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3155
3166
3156
3167
// ModuleTypes are trivial but don't warrant being given a
3157
3168
// conformance to BitwiseCopyable (case (3)).
3158
- if (isa<ModuleType, SILTokenType>(ty)) {
3169
+ if (isa<ModuleType>(ty) || isa< SILTokenType>(ty)) {
3159
3170
// These types should never appear within aggregates.
3160
3171
assert (isTopLevel && " aggregate containing marker type!?" );
3161
3172
// If they did, though, they would not justify the aggregate's
@@ -3174,6 +3185,14 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3174
3185
return !isTopLevel;
3175
3186
}
3176
3187
3188
+ // Case (10): a layout-constrained archetype.
3189
+ if (auto archetype = dyn_cast<ArchetypeType>(ty)) {
3190
+ auto constraint = archetype->getLayoutConstraint ();
3191
+ if (constraint && constraint->isTrivial ()) {
3192
+ return false ;
3193
+ }
3194
+ }
3195
+
3177
3196
auto *nominal = ty.getAnyNominal ();
3178
3197
3179
3198
// Non-nominal types (besides case (3) handled above) are trivial iff
0 commit comments