@@ -8453,34 +8453,32 @@ void GenericSignatureBuilder::verifyGenericSignature(ASTContext &context,
8453
8453
llvm::errs () << " \n " ;
8454
8454
8455
8455
// Try building a new signature having the same requirements.
8456
- auto genericParams = sig.getGenericParams ();
8457
- auto requirements = sig.getRequirements ();
8456
+ SmallVector<GenericTypeParamType *, 2 > genericParams;
8457
+ for (auto *genericParam : sig.getGenericParams ())
8458
+ genericParams.push_back (genericParam);
8459
+
8460
+ SmallVector<Requirement, 2 > requirements;
8461
+ for (auto requirement : sig.getRequirements ())
8462
+ requirements.push_back (requirement);
8458
8463
8459
8464
{
8460
8465
PrettyStackTraceGenericSignature debugStack (" verifying" , sig);
8461
8466
8462
- // Form a new generic signature builder.
8463
- GenericSignatureBuilder builder (context);
8464
-
8465
- // Add the generic parameters.
8466
- for (auto gp : genericParams)
8467
- builder.addGenericParameter (gp);
8468
-
8469
- // Add the requirements.
8470
- auto source = FloatingRequirementSource::forAbstract ();
8471
- for (auto req : requirements)
8472
- builder.addRequirement (req, source, nullptr );
8467
+ auto newSigWithError = evaluateOrDefault (
8468
+ context.evaluator ,
8469
+ AbstractGenericSignatureRequest{
8470
+ nullptr ,
8471
+ genericParams,
8472
+ requirements},
8473
+ GenericSignatureWithError ());
8473
8474
8474
8475
// If there were any errors, the signature was invalid.
8475
- if (builder. Impl -> HadAnyError ) {
8476
+ if (newSigWithError. getInt () ) {
8476
8477
context.Diags .diagnose (SourceLoc (), diag::generic_signature_not_valid,
8477
8478
sig->getAsString ());
8478
8479
}
8479
8480
8480
- // Form a generic signature from the result.
8481
- auto newSig =
8482
- std::move (builder).computeGenericSignature (
8483
- /* allowConcreteGenericParams=*/ true );
8481
+ auto newSig = newSigWithError.getPointer ();
8484
8482
8485
8483
// The new signature should be equal.
8486
8484
if (!newSig->isEqual (sig)) {
@@ -8493,28 +8491,27 @@ void GenericSignatureBuilder::verifyGenericSignature(ASTContext &context,
8493
8491
for (unsigned victimIndex : indices (requirements)) {
8494
8492
PrettyStackTraceGenericSignature debugStack (" verifying" , sig, victimIndex);
8495
8493
8496
- // Form a new generic signature builder.
8497
- GenericSignatureBuilder builder (context);
8498
-
8499
- // Add the generic parameters.
8500
- for (auto gp : genericParams)
8501
- builder.addGenericParameter (gp);
8502
-
8503
8494
// Add the requirements *except* the victim.
8504
- auto source = FloatingRequirementSource::forAbstract () ;
8495
+ SmallVector<Requirement, 2 > newRequirements ;
8505
8496
for (unsigned i : indices (requirements)) {
8506
8497
if (i != victimIndex)
8507
- builder. addRequirement (requirements[i], source, nullptr );
8498
+ newRequirements. push_back (requirements[i]);
8508
8499
}
8509
8500
8501
+ auto newSigWithError = evaluateOrDefault (
8502
+ context.evaluator ,
8503
+ AbstractGenericSignatureRequest{
8504
+ nullptr ,
8505
+ genericParams,
8506
+ newRequirements},
8507
+ GenericSignatureWithError ());
8508
+
8510
8509
// If there were any errors, we formed an invalid signature, so
8511
8510
// just continue.
8512
- if (builder.Impl ->HadAnyError ) continue ;
8511
+ if (newSigWithError.getInt ())
8512
+ continue ;
8513
8513
8514
- // Form a generic signature from the result.
8515
- auto newSig =
8516
- std::move (builder).computeGenericSignature (
8517
- /* allowConcreteGenericParams=*/ true );
8514
+ auto newSig = newSigWithError.getPointer ();
8518
8515
8519
8516
// If the new signature once again contains the removed requirement, it's
8520
8517
// not redundant.
0 commit comments