Skip to content

Commit f1231a4

Browse files
authored
Merge pull request swiftlang#7518 from DougGregor/concrete-archetype-anchors
2 parents ec90e4a + 485ed7b commit f1231a4

File tree

5 files changed

+291
-153
lines changed

5 files changed

+291
-153
lines changed

include/swift/AST/GenericSignatureBuilder.h

+14-7
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ class RequirementSource : public llvm::FoldingSetNode {
296296
/// path.
297297
bool isDerivedRequirement() const;
298298

299+
/// Whether the requirement is derived via some concrete conformance, e.g.,
300+
/// a concrete type's conformance to a protocol or a superclass's conformance
301+
/// to a protocol.
302+
bool isDerivedViaConcreteConformance() const;
303+
299304
/// Retrieve a source location that corresponds to the requirement.
300305
SourceLoc getLoc() const;
301306

@@ -712,7 +717,8 @@ class GenericSignatureBuilder::PotentialArchetype {
712717
/// constrained.
713718
Type ConcreteType;
714719

715-
/// The source of the concrete type requirement.
720+
/// The source of the concrete type requirement, if one was written
721+
/// on this potential archetype.
716722
const RequirementSource *ConcreteTypeSource = nullptr;
717723

718724
/// Whether this is an unresolved nested type.
@@ -936,15 +942,16 @@ class GenericSignatureBuilder::PotentialArchetype {
936942
SameTypeConstraints.end());
937943
}
938944

939-
/// Retrieve the source of the same-type constraint that maps this potential
940-
/// archetype to a concrete type.
941-
const RequirementSource *getConcreteTypeSource() const {
942-
if (Representative != this)
943-
return Representative->getConcreteTypeSource();
944-
945+
/// Retrieve the concrete type source as written on this potential archetype.
946+
const RequirementSource *getConcreteTypeSourceAsWritten() const {
945947
return ConcreteTypeSource;
946948
}
947949

950+
/// Find a source of the same-type constraint that maps this potential
951+
/// archetype to a concrete type somewhere in the equivalence class of this
952+
/// type.
953+
const RequirementSource *findAnyConcreteTypeSourceAsWritten() const;
954+
948955
/// \brief Retrieve (or create) a nested type with the given name.
949956
PotentialArchetype *getNestedType(Identifier Name,
950957
GenericSignatureBuilder &builder);

lib/AST/GenericEnvironment.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,9 @@ getSubstitutionMap(SubstitutionList subs) const {
412412
continue;
413413
}
414414

415-
assert(contextTy->hasError());
415+
// FIXME: getAllDependentTypes() includes generic type parameters that
416+
// have been made concrete.
417+
assert(contextTy->hasError() || depTy->is<GenericTypeParamType>());
416418
}
417419

418420
assert(subs.empty() && "did not use all substitutions?!");

0 commit comments

Comments
 (0)