mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Introduce lazy computation of a BoundGenericType's substitutions.
Teach a BoundGenericType to compute its own substitutions, which allows AST clients to create new bound generic types without the aid of the type checker. This eliminates the TypeChecker::validateTypeSimple() abomination as well as the need for the BoundGenericType AST validation step. There is still more cleanup to do in this area. Note that BoundGenericType::getSubstitutions() now accepts a module parameter, which is the place from which we will look for conformances. This is a baby step toward properly modeling the conformances as part of the bound generic type, and is nowhere near complete. Swift SVN r8193
This commit is contained in:
@@ -366,6 +366,14 @@ void Module::getTopLevelDecls(SmallVectorImpl<Decl*> &Results) {
|
||||
ArrayRef<Substitution> BoundGenericType::getSubstitutions(
|
||||
Module *module,
|
||||
LazyResolver *resolver) {
|
||||
// FIXME: If there is no module, infer one. This is a hack for callers that
|
||||
// don't have access to the module. It will have to go away once we're
|
||||
// properly differentiating bound generic types based on the protocol
|
||||
// conformances visible from a given module.
|
||||
if (!module) {
|
||||
module = getDecl()->getParentModule();
|
||||
}
|
||||
|
||||
// If we already have a cached copy of the substitutions, return them.
|
||||
auto *canon = getCanonicalType()->castTo<BoundGenericType>();
|
||||
const ASTContext &ctx = canon->getASTContext();
|
||||
|
||||
Reference in New Issue
Block a user