Skip to content

Commit 8ca5ec9

Browse files
authored
Merge pull request swiftlang#8812 from DougGregor/gsb-derived-from-concrete
2 parents 8969d1c + 4ed8bf5 commit 8ca5ec9

File tree

5 files changed

+253
-159
lines changed

5 files changed

+253
-159
lines changed

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,21 @@ class GenericSignatureBuilder::RequirementSource final
962962
PotentialArchetype *getRootPotentialArchetype() const;
963963

964964
/// Retrieve the potential archetype to which this source refers.
965-
PotentialArchetype *getAffectedPotentialArchetype(
966-
GenericSignatureBuilder &builder) const;
965+
PotentialArchetype *getAffectedPotentialArchetype() const;
966+
967+
/// Visit each of the potential archetypes along the path, from the root
968+
/// potential archetype to each potential archetype named via (e.g.) a
969+
/// protocol requirement or parent source.
970+
///
971+
/// \param visitor Called with each potential archetype along the path along
972+
/// with the requirement source that is being applied on top of that
973+
/// potential archetype. Can return \c true to halt the search.
974+
///
975+
/// \returns nullptr if any call to \c visitor returned true. Otherwise,
976+
/// returns the potential archetype to which the entire source refers.
977+
PotentialArchetype *visitPotentialArchetypesAlongPath(
978+
llvm::function_ref<bool(PotentialArchetype *,
979+
const RequirementSource *)> visitor) const;
967980

968981
/// Whether the requirement is inferred or derived from an inferred
969982
/// requirment.
@@ -979,22 +992,19 @@ class GenericSignatureBuilder::RequirementSource final
979992
/// path.
980993
bool isDerivedRequirement() const;
981994

982-
/// Whether the requirement is derived via some concrete conformance, e.g.,
983-
/// a concrete type's conformance to a protocol or a superclass's conformance
984-
/// to a protocol.
985-
bool isDerivedViaConcreteConformance() const;
986-
987995
/// Determine whether the given derived requirement \c source, when rooted at
988996
/// the potential archetype \c pa, is actually derived from the same
989997
/// requirement. Such "self-derived" requirements do not make the original
990998
/// requirement redundant, because without said original requirement, the
991999
/// derived requirement ceases to hold.
992-
bool isSelfDerivedSource(PotentialArchetype *pa) const;
1000+
bool isSelfDerivedSource(PotentialArchetype *pa,
1001+
bool &derivedViaConcrete) const;
9931002

9941003
/// Determine whether a requirement \c pa: proto, when formed from this
9951004
/// requirement source, is dependent on itself.
9961005
bool isSelfDerivedConformance(PotentialArchetype *pa,
997-
ProtocolDecl *proto) const;
1006+
ProtocolDecl *proto,
1007+
bool &derivedViaConcrete) const;
9981008

9991009
/// Retrieve a source location that corresponds to the requirement.
10001010
SourceLoc getLoc() const;

0 commit comments

Comments
 (0)