@@ -6903,14 +6903,14 @@ void GenericSignatureBuilder::checkLayoutConstraints(
6903
6903
namespace {
6904
6904
// / Retrieve the best requirement source from a set of constraints.
6905
6905
template <typename T>
6906
- Optional< const RequirementSource *>
6906
+ const RequirementSource *
6907
6907
getBestConstraintSource (ArrayRef<Constraint<T>> constraints,
6908
6908
llvm::function_ref<bool (const T&)> matches) {
6909
- Optional< const RequirementSource *> bestSource;
6909
+ const RequirementSource *bestSource = nullptr ;
6910
6910
for (const auto &constraint : constraints) {
6911
6911
if (!matches (constraint.value )) continue ;
6912
6912
6913
- if (!bestSource || constraint.source ->compare (* bestSource) < 0 )
6913
+ if (!bestSource || constraint.source ->compare (bestSource) < 0 )
6914
6914
bestSource = constraint.source ;
6915
6915
}
6916
6916
@@ -6999,18 +6999,17 @@ void GenericSignatureBuilder::enumerateRequirements(
6999
6999
continue ;
7000
7000
7001
7001
// If we have a superclass, produce a superclass requirement
7002
- if (equivClass->superclass && !equivClass->recursiveSuperclassType ) {
7002
+ if (equivClass->superclass &&
7003
+ !equivClass->recursiveSuperclassType &&
7004
+ !equivClass->superclass ->hasError ()) {
7003
7005
auto bestSource =
7004
7006
getBestConstraintSource<Type>(equivClass->superclassConstraints ,
7005
7007
[&](const Type &type) {
7006
7008
return type->isEqual (equivClass->superclass );
7007
7009
});
7008
7010
7009
- if (!bestSource)
7010
- bestSource = RequirementSource::forAbstract (*this , subjectType);
7011
-
7012
7011
f (RequirementKind::Superclass, subjectType, equivClass->superclass ,
7013
- * bestSource);
7012
+ bestSource);
7014
7013
}
7015
7014
7016
7015
// If we have a layout constraint, produce a layout requirement.
@@ -7020,10 +7019,9 @@ void GenericSignatureBuilder::enumerateRequirements(
7020
7019
[&](const LayoutConstraint &layout) {
7021
7020
return layout == equivClass->layout ;
7022
7021
});
7023
- if (!bestSource)
7024
- bestSource = RequirementSource::forAbstract (*this , subjectType);
7025
7022
7026
- f (RequirementKind::Layout, subjectType, equivClass->layout , *bestSource);
7023
+ f (RequirementKind::Layout, subjectType, equivClass->layout ,
7024
+ bestSource);
7027
7025
}
7028
7026
7029
7027
// Enumerate conformance requirements.
@@ -7037,7 +7035,7 @@ void GenericSignatureBuilder::enumerateRequirements(
7037
7035
7038
7036
protocolSources.insert (
7039
7037
{conforms.first ,
7040
- * getBestConstraintSource<ProtocolDecl *>(conforms.second ,
7038
+ getBestConstraintSource<ProtocolDecl *>(conforms.second ,
7041
7039
[&](ProtocolDecl *proto) {
7042
7040
return proto == conforms.first ;
7043
7041
})});
0 commit comments