Skip to content

[Associated type inference] Allow _Default_Foo typealias guides for inference. #13567

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
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
7 changes: 7 additions & 0 deletions lib/Sema/TypeCheckGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,13 @@ RequirementCheckResult TypeChecker::checkGenericArguments(
secondType = req.getSecondType();
}

// Don't do further checking on error types.
if (firstType->hasError() || (secondType && secondType->hasError())) {
// Another requirement will fail later; just continue.
valid = false;
continue;
}

bool requirementFailure = false;
if (listener && !listener->shouldCheck(kind, firstType, secondType))
continue;
Expand Down
28 changes: 26 additions & 2 deletions lib/Sema/TypeCheckProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ struct InferredTypeWitnessesSolution {
#ifndef NDEBUG
LLVM_ATTRIBUTE_USED
#endif
void dump();
void dump() const;
};

class RequirementEnvironment;
Expand Down Expand Up @@ -707,6 +707,12 @@ class AssociatedTypeInference {
const llvm::SetVector<AssociatedTypeDecl *> &allUnresolved,
ValueDecl *req);

/// Infer associated type witnesses for the given associated type.
InferredAssociatedTypesByWitnesses inferTypeWitnessesViaAssociatedType(
ConformanceChecker &checker,
const llvm::SetVector<AssociatedTypeDecl *> &allUnresolved,
AssociatedTypeDecl *assocType);

/// Infer associated type witnesses for all relevant value requirements.
///
/// \param assocTypes The set of associated types we're interested in.
Expand All @@ -728,12 +734,30 @@ class AssociatedTypeInference {
/// known to the compiler.
Type computeDerivedTypeWitness(AssociatedTypeDecl *assocType);

/// Compute a type witness without using a specific potential witness,
/// e.g., using a fixed type (from a refined protocol), default type
/// on an associated type, or deriving the type.
///
/// \param allowDerived Whether to allow "derived" type witnesses.
Type computeAbstractTypeWitness(AssociatedTypeDecl *assocType,
bool allowDerived);

/// Substitute the current type witnesses into the given interface type.
Type substCurrentTypeWitnesses(Type type);

/// Retrieve substitution options with a tentative type witness
/// operation that queries the current set of type witnesses.
SubstOptions getSubstOptionsWithCurrentTypeWitnesses();

/// Check whether the current set of type witnesses meets the
/// requirements of the protocol.
bool checkCurrentTypeWitnesses();
bool checkCurrentTypeWitnesses(
const SmallVectorImpl<std::pair<ValueDecl *, ValueDecl *>>
&valueWitnesses);

/// Check the current type witnesses against the
/// requirements of the given constrained extension.
bool checkConstrainedExtension(ExtensionDecl *ext);

/// Top-level operation to find solutions for the given unresolved
/// associated types.
Expand Down
Loading