2828#include " swift/AST/Pattern.h"
2929#include " swift/AST/PrettyStackTrace.h"
3030#include " swift/AST/PropertyWrappers.h"
31- #include " swift/AST/ProtocolConformance.h"
3231#include " swift/AST/TypeDifferenceVisitor.h"
3332#include " swift/AST/Types.h"
3433#include " swift/ClangImporter/ClangModule.h"
@@ -3010,21 +3009,6 @@ void TypeConverter::verifyLexicalLowering(const TypeLowering &lowering,
30103009 }
30113010}
30123011
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-
30283012void TypeConverter::verifyTrivialLowering (const TypeLowering &lowering,
30293013 AbstractionPattern origType,
30303014 CanType substType,
@@ -3058,17 +3042,10 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
30583042 if (!nominal)
30593043 return false ;
30603044
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 ()) {
30723049 return true ;
30733050 }
30743051
@@ -3082,12 +3059,10 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
30823059 // Return false to indicate seeing a leaf which justifies the type
30833060 // being trivial but not conforming to BitwiseCopyable.
30843061
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 ;
30913066
30923067 // ModuleTypes are trivial but don't warrant being given a conformance
30933068 // to BitwiseCopyable.
@@ -3124,15 +3099,15 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
31243099 return true ;
31253100 }
31263101
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 ()) {
31313106 return false ;
31323107 }
31333108
31343109 // 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.
31363111 return !nominal
31373112 ->getFormalAccessScope (
31383113 /* useDC=*/ nullptr ,
@@ -3173,7 +3148,6 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
31733148 llvm::errs () << " Non-trivial type with _BitwiseCopyable conformance!?:\n "
31743149 << substType << " \n " ;
31753150 conformance.print (llvm::errs ());
3176- llvm::errs () << " \n " ;
31773151 assert (false );
31783152 }
31793153 }
0 commit comments