Skip to content

[GenericSig Builder] Track and canonicalize same-type-to-concrete constraints #7518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions include/swift/AST/GenericSignatureBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ class RequirementSource : public llvm::FoldingSetNode {
/// path.
bool isDerivedRequirement() const;

/// Whether the requirement is derived via some concrete conformance, e.g.,
/// a concrete type's conformance to a protocol or a superclass's conformance
/// to a protocol.
bool isDerivedViaConcreteConformance() const;

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

Expand Down Expand Up @@ -712,7 +717,8 @@ class GenericSignatureBuilder::PotentialArchetype {
/// constrained.
Type ConcreteType;

/// The source of the concrete type requirement.
/// The source of the concrete type requirement, if one was written
/// on this potential archetype.
const RequirementSource *ConcreteTypeSource = nullptr;

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

/// Retrieve the source of the same-type constraint that maps this potential
/// archetype to a concrete type.
const RequirementSource *getConcreteTypeSource() const {
if (Representative != this)
return Representative->getConcreteTypeSource();

/// Retrieve the concrete type source as written on this potential archetype.
const RequirementSource *getConcreteTypeSourceAsWritten() const {
return ConcreteTypeSource;
}

/// Find a source of the same-type constraint that maps this potential
/// archetype to a concrete type somewhere in the equivalence class of this
/// type.
const RequirementSource *findAnyConcreteTypeSourceAsWritten() const;

/// \brief Retrieve (or create) a nested type with the given name.
PotentialArchetype *getNestedType(Identifier Name,
GenericSignatureBuilder &builder);
Expand Down
4 changes: 3 additions & 1 deletion lib/AST/GenericEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ getSubstitutionMap(SubstitutionList subs) const {
continue;
}

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

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