mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[generic-specializer] Move checkSpecializationRequirements around
This commit is contained in:
@@ -601,36 +601,6 @@ getSignatureWithRequirements(GenericSignature *OrigGenSig,
|
||||
return getGenericEnvironmentAndSignature(Builder, M);
|
||||
}
|
||||
|
||||
/// Perform some sanity checks for the requirements
|
||||
static void
|
||||
checkSpecializationRequirements(ArrayRef<Requirement> Requirements) {
|
||||
for (auto &Req : Requirements) {
|
||||
if (Req.getKind() == RequirementKind::SameType) {
|
||||
auto FirstType = Req.getFirstType();
|
||||
auto SecondType = Req.getSecondType();
|
||||
assert(FirstType && SecondType);
|
||||
assert(!FirstType->hasArchetype());
|
||||
assert(!SecondType->hasArchetype());
|
||||
|
||||
// Only one of the types should be concrete.
|
||||
assert(FirstType->hasTypeParameter() != SecondType->hasTypeParameter() &&
|
||||
"Only concrete type same-type requirements are supported by "
|
||||
"generic specialization");
|
||||
|
||||
(void) FirstType;
|
||||
(void) SecondType;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Req.getKind() == RequirementKind::Layout) {
|
||||
continue;
|
||||
}
|
||||
|
||||
llvm_unreachable("Unknown type of requirement in generic specialization");
|
||||
}
|
||||
}
|
||||
|
||||
ReabstractionInfo::ReabstractionInfo(SILFunction *OrigF,
|
||||
ArrayRef<Requirement> Requirements) {
|
||||
if (shouldNotSpecializeCallee(OrigF))
|
||||
@@ -1442,6 +1412,36 @@ void ReabstractionInfo::specializeConcreteAndGenericSubstitutions(
|
||||
}
|
||||
}
|
||||
|
||||
/// Perform some sanity checks for the requirements provided in @_specialize.
|
||||
static void
|
||||
checkSpecializationRequirements(ArrayRef<Requirement> Requirements) {
|
||||
for (auto &Req : Requirements) {
|
||||
if (Req.getKind() == RequirementKind::SameType) {
|
||||
auto FirstType = Req.getFirstType();
|
||||
auto SecondType = Req.getSecondType();
|
||||
assert(FirstType && SecondType);
|
||||
assert(!FirstType->hasArchetype());
|
||||
assert(!SecondType->hasArchetype());
|
||||
|
||||
// Only one of the types should be concrete.
|
||||
assert(FirstType->hasTypeParameter() != SecondType->hasTypeParameter() &&
|
||||
"Only concrete type same-type requirements are supported by "
|
||||
"generic specialization");
|
||||
|
||||
(void) FirstType;
|
||||
(void) SecondType;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Req.getKind() == RequirementKind::Layout) {
|
||||
continue;
|
||||
}
|
||||
|
||||
llvm_unreachable("Unknown type of requirement in generic specialization");
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// GenericFuncSpecializer
|
||||
// =============================================================================
|
||||
|
||||
Reference in New Issue
Block a user