static void revertDependentTypeLoc(TypeLoc &tl) { // If there's no type representation, there's nothing to revert. if (!tl.getTypeRepr()) return; // Don't revert an error type; we've already complained. if (tl.wasValidated() && tl.isError()) return; // Make sure we validate the type again. tl.setType(Type()); }
void IterativeTypeChecker::processResolveInheritedClauseEntry( TypeCheckRequest::InheritedClauseEntryPayloadType payload, UnsatisfiedDependency unsatisfiedDependency) { TypeResolutionOptions options; DeclContext *dc; TypeLoc *inherited; std::tie(options, dc, inherited) = decomposeInheritedClauseEntry(payload); // FIXME: Declaration validation is overkill. Sink it down into type // resolution when it is actually needed. if (auto nominal = dyn_cast<NominalTypeDecl>(dc)) TC.validateDeclForNameLookup(nominal); else if (auto ext = dyn_cast<ExtensionDecl>(dc)) { TC.validateExtension(ext); } // Validate the type of this inherited clause entry. // FIXME: Recursion into existing type checker. ProtocolRequirementTypeResolver protoResolver; GenericTypeToArchetypeResolver archetypeResolver(dc); GenericTypeResolver *resolver; if (isa<ProtocolDecl>(dc)) { resolver = &protoResolver; } else { resolver = &archetypeResolver; } if (TC.validateType(*inherited, dc, options, resolver, &unsatisfiedDependency)) { inherited->setInvalidType(getASTContext()); } auto type = inherited->getType(); if (!type.isNull() && !isa<ProtocolDecl>(dc)) inherited->setType(type->mapTypeOutOfContext()); }