@@ -280,21 +280,50 @@ bool GenericSignatureImpl::requiresClass(Type type) const {
280
280
assert (type->isTypeParameter () &&
281
281
" Only type parameters can have superclass requirements" );
282
282
283
- auto &builder = *getGenericSignatureBuilder ();
284
- auto equivClass =
285
- builder.resolveEquivalenceClass (
286
- type,
287
- ArchetypeResolutionKind::CompleteWellFormed);
288
- if (!equivClass) return false ;
283
+ auto computeViaGSB = [&]() {
284
+ auto &builder = *getGenericSignatureBuilder ();
285
+ auto equivClass =
286
+ builder.resolveEquivalenceClass (
287
+ type,
288
+ ArchetypeResolutionKind::CompleteWellFormed);
289
+ if (!equivClass) return false ;
289
290
290
- // If this type was mapped to a concrete type, then there is no
291
- // requirement.
292
- if (equivClass->concreteType ) return false ;
291
+ // If this type was mapped to a concrete type, then there is no
292
+ // requirement.
293
+ if (equivClass->concreteType ) return false ;
293
294
294
- // If there is a layout constraint, it might be a class.
295
- if (equivClass->layout && equivClass->layout ->isClass ()) return true ;
295
+ // If there is a layout constraint, it might be a class.
296
+ if (equivClass->layout && equivClass->layout ->isClass ()) return true ;
296
297
297
- return false ;
298
+ return false ;
299
+ };
300
+
301
+ auto computeViaRQM = [&]() {
302
+ auto *machine = getRequirementMachine ();
303
+ return machine->requiresClass (type);
304
+ };
305
+
306
+ auto &ctx = getASTContext ();
307
+ if (ctx.LangOpts .EnableRequirementMachine ) {
308
+ bool rqmResult = computeViaRQM ();
309
+
310
+ #ifndef NDEBUG
311
+ bool gsbResult = computeViaGSB ();
312
+
313
+ if (gsbResult != rqmResult) {
314
+ llvm::errs () << " RequirementMachine::requiresClass() is broken\n " ;
315
+ llvm::errs () << " Generic signature: " << GenericSignature (this ) << " \n " ;
316
+ llvm::errs () << " Dependent type: " ; type.dump (llvm::errs ());
317
+ llvm::errs () << " GenericSignatureBuilder says: " << gsbResult << " \n " ;
318
+ llvm::errs () << " RequirementMachine says: " << rqmResult << " \n " ;
319
+ abort ();
320
+ }
321
+ #endif
322
+
323
+ return rqmResult;
324
+ } else {
325
+ return computeViaGSB ();
326
+ }
298
327
}
299
328
300
329
// / Determine the superclass bound on the given dependent type.
0 commit comments