mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[GSB] Clean up and audit uses of ArchetypeResolutionKind.
Use ArchetypeResolutionKind::CompleteWellFormed whenever we need to ask questions about the potential archetype, and ArchetypeResolutionKind::WellFormed when we need only evaluate whether there is a legitimate type with that name (and possibly get a handle to it).
This commit is contained in:
@@ -3292,8 +3292,7 @@ void ProtocolDecl::computeRequirementSignature() {
|
||||
LookUpConformanceInModule(module));
|
||||
builder.addGenericParameter(selfType);
|
||||
auto selfPA =
|
||||
builder.resolveArchetype(selfType,
|
||||
ArchetypeResolutionKind::CompleteWellFormed);
|
||||
builder.resolveArchetype(selfType, ArchetypeResolutionKind::WellFormed);
|
||||
|
||||
builder.addRequirement(
|
||||
requirement,
|
||||
|
||||
@@ -488,21 +488,25 @@ bool GenericSignature::requiresClass(Type type, ModuleDecl &mod) {
|
||||
builder.resolveArchetype(type, ArchetypeResolutionKind::CompleteWellFormed);
|
||||
if (!pa) return false;
|
||||
|
||||
pa = pa->getRepresentative();
|
||||
if (pa->isConcreteType()) return false;
|
||||
|
||||
// If this type was mapped to a concrete type, then there is no
|
||||
// requirement.
|
||||
pa = pa->getRepresentative();
|
||||
|
||||
if (pa->isConcreteType()) return false;
|
||||
|
||||
// If there is a layout constraint, it might be a class.
|
||||
if (auto layout = pa->getLayout())
|
||||
if (layout->isClass())
|
||||
return true;
|
||||
if (auto layout = pa->getLayout()) {
|
||||
if (layout->isClass()) return true;
|
||||
}
|
||||
|
||||
// If there is a superclass bound, then obviously it must be a class.
|
||||
// FIXME: We shouldn't need this?
|
||||
if (pa->getSuperclass()) return true;
|
||||
|
||||
// If any of the protocols are class-bound, then it must be a class.
|
||||
// FIXME: We shouldn't need this?
|
||||
for (auto proto : pa->getConformsTo()) {
|
||||
if (proto->requiresClass()) return true;
|
||||
}
|
||||
@@ -519,8 +523,6 @@ Type GenericSignature::getSuperclassBound(Type type, ModuleDecl &mod) {
|
||||
builder.resolveArchetype(type, ArchetypeResolutionKind::CompleteWellFormed);
|
||||
if (!pa) return nullptr;
|
||||
|
||||
pa = pa->getRepresentative();
|
||||
|
||||
// If this type was mapped to a concrete type, then there is no
|
||||
// requirement.
|
||||
if (pa->isConcreteType()) return nullptr;
|
||||
@@ -540,8 +542,6 @@ SmallVector<ProtocolDecl *, 2> GenericSignature::getConformsTo(Type type,
|
||||
builder.resolveArchetype(type, ArchetypeResolutionKind::CompleteWellFormed);
|
||||
if (!pa) return { };
|
||||
|
||||
pa = pa->getRepresentative();
|
||||
|
||||
// If this type was mapped to a concrete type, then there are no
|
||||
// requirements.
|
||||
if (pa->isConcreteType()) return { };
|
||||
@@ -567,8 +567,6 @@ bool GenericSignature::conformsToProtocol(Type type, ProtocolDecl *proto,
|
||||
builder.resolveArchetype(type, ArchetypeResolutionKind::CompleteWellFormed);
|
||||
if (!pa) return false;
|
||||
|
||||
pa = pa->getRepresentative();
|
||||
|
||||
// FIXME: Deal with concrete conformances here?
|
||||
if (pa->isConcreteType()) return false;
|
||||
|
||||
@@ -596,9 +594,6 @@ Type GenericSignature::getConcreteType(Type type, ModuleDecl &mod) {
|
||||
builder.resolveArchetype(type, ArchetypeResolutionKind::CompleteWellFormed);
|
||||
if (!pa) return Type();
|
||||
|
||||
pa = pa->getRepresentative();
|
||||
if (!pa->isConcreteType()) return Type();
|
||||
|
||||
return pa->getConcreteType();
|
||||
}
|
||||
|
||||
@@ -611,7 +606,6 @@ LayoutConstraint GenericSignature::getLayoutConstraint(Type type,
|
||||
builder.resolveArchetype(type, ArchetypeResolutionKind::CompleteWellFormed);
|
||||
if (!pa) return LayoutConstraint();
|
||||
|
||||
pa = pa->getRepresentative();
|
||||
return pa->getLayout();
|
||||
}
|
||||
|
||||
@@ -882,7 +876,7 @@ ConformanceAccessPath GenericSignature::getConformanceAccessPath(
|
||||
auto pa =
|
||||
inProtoSigBuilder.resolveArchetype(
|
||||
storedType,
|
||||
ArchetypeResolutionKind::WellFormed);
|
||||
ArchetypeResolutionKind::CompleteWellFormed);
|
||||
auto equivClass = pa->getOrCreateEquivalenceClass();
|
||||
|
||||
// Find the conformance of this potential archetype to the protocol in
|
||||
|
||||
@@ -1960,13 +1960,9 @@ PotentialArchetype *PotentialArchetype::updateNestedTypeForConformance(
|
||||
}
|
||||
|
||||
case ArchetypeResolutionKind::AlreadyKnown:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If we still don't have a result potential archetype, we're done.
|
||||
if (!resultPA)
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a potential archetype that requires more processing, do so now.
|
||||
if (shouldUpdatePA) {
|
||||
|
||||
@@ -132,8 +132,9 @@ Type CompleteGenericTypeResolver::resolveDependentMemberType(
|
||||
assert(basePA && "Missing potential archetype for base");
|
||||
|
||||
// Retrieve the potential archetype for the nested type.
|
||||
auto nestedPA = basePA->getNestedType(ref->getIdentifier(),
|
||||
ArchetypeResolutionKind::WellFormed,
|
||||
auto nestedPA =
|
||||
basePA->getNestedType(ref->getIdentifier(),
|
||||
ArchetypeResolutionKind::CompleteWellFormed,
|
||||
Builder);
|
||||
|
||||
// If there was no such nested type, produce an error.
|
||||
|
||||
Reference in New Issue
Block a user