28
28
#include " swift/AST/Pattern.h"
29
29
#include " swift/AST/PrettyStackTrace.h"
30
30
#include " swift/AST/PropertyWrappers.h"
31
- #include " swift/AST/ProtocolConformance.h"
32
31
#include " swift/AST/TypeDifferenceVisitor.h"
33
32
#include " swift/AST/Types.h"
34
33
#include " swift/ClangImporter/ClangModule.h"
@@ -3010,21 +3009,6 @@ void TypeConverter::verifyLexicalLowering(const TypeLowering &lowering,
3010
3009
}
3011
3010
}
3012
3011
3013
- static bool isUnchecked (ProtocolConformanceRef conformance) {
3014
- if (!conformance)
3015
- return false ;
3016
- if (!conformance.isConcrete ())
3017
- return false ;
3018
- auto concrete = conformance.getConcrete ();
3019
- assert (concrete);
3020
- auto *root = concrete->getRootConformance ();
3021
- assert (root);
3022
- auto *normal = dyn_cast<NormalProtocolConformance>(root);
3023
- if (!normal)
3024
- return false ;
3025
- return normal->isUnchecked ();
3026
- }
3027
-
3028
3012
void TypeConverter::verifyTrivialLowering (const TypeLowering &lowering,
3029
3013
AbstractionPattern origType,
3030
3014
CanType substType,
@@ -3058,17 +3042,10 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3058
3042
if (!nominal)
3059
3043
return false ;
3060
3044
3061
- // Don't walk into types whose conformance is unchecked--such
3062
- // conformances obstruct automatic inference of BitwiseCopyable.
3063
- auto conformance = M.checkConformance (ty, bitwiseCopyableProtocol);
3064
- if (isUnchecked (conformance)) {
3065
- return true ;
3066
- }
3067
-
3068
- // Nominals with fields that conditionally conform to BitwiseCopyable
3069
- // must be explicitly conditionally conformed. Such a field must be a
3070
- // generic context.
3071
- if (nominal->isGenericContext ()) {
3045
+ // Nominals with generic parameters must be explicitly conformed to
3046
+ // BitwiseCopyable.
3047
+ auto *generic = ty.getAnyGeneric ();
3048
+ if (generic && generic->isGenericContext ()) {
3072
3049
return true ;
3073
3050
}
3074
3051
@@ -3082,12 +3059,10 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3082
3059
// Return false to indicate seeing a leaf which justifies the type
3083
3060
// being trivial but not conforming to BitwiseCopyable.
3084
3061
3085
- // A BitwiseCopyable conformer appearing within its layout explains a
3086
- // non-conformance iff the conformance is @unchecked.
3087
- auto conformance = M.checkConformance (ty, bitwiseCopyableProtocol);
3088
- if (conformance) {
3089
- return !isUnchecked (conformance);
3090
- }
3062
+ // A BitwiseCopyable conformer appearing within its layout doesn't
3063
+ // explain why substType doesn't itself conform.
3064
+ if (M.checkConformance (ty, bitwiseCopyableProtocol))
3065
+ return true ;
3091
3066
3092
3067
// ModuleTypes are trivial but don't warrant being given a conformance
3093
3068
// to BitwiseCopyable.
@@ -3124,15 +3099,15 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3124
3099
return true ;
3125
3100
}
3126
3101
3127
- // / A field of conditionally-BitwiseCopyable type justifies the
3128
- // / aggregate not conforming because the aggregate must be conformed
3129
- // / explicitly in that case.
3130
- if (nominal ->isGenericContext ()) {
3102
+ // / A non-conforming generic nominal type justifies substType not
3103
+ // / conforming.
3104
+ auto *generic = ty. getAnyGeneric ();
3105
+ if (generic && generic ->isGenericContext ()) {
3131
3106
return false ;
3132
3107
}
3133
3108
3134
3109
// The field is trivial and the whole type is nonconforming. That's
3135
- // legal iff the field's type is public.
3110
+ // legal iff the type is public.
3136
3111
return !nominal
3137
3112
->getFormalAccessScope (
3138
3113
/* useDC=*/ nullptr ,
@@ -3173,7 +3148,6 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
3173
3148
llvm::errs () << " Non-trivial type with _BitwiseCopyable conformance!?:\n "
3174
3149
<< substType << " \n " ;
3175
3150
conformance.print (llvm::errs ());
3176
- llvm::errs () << " \n " ;
3177
3151
assert (false );
3178
3152
}
3179
3153
}
0 commit comments