@@ -421,7 +421,7 @@ TypeChecker::getDynamicBridgedThroughObjCClass(DeclContext *dc,
421421
422422Type TypeResolution::resolveTypeInContext (TypeDecl *typeDecl,
423423 DeclContext *foundDC,
424- bool isSpecialized) {
424+ bool isSpecialized) const {
425425 auto fromDC = getDeclContext ();
426426 ASTContext &ctx = fromDC->getASTContext ();
427427
@@ -680,7 +680,8 @@ static void diagnoseUnboundGenericType(Type ty, SourceLoc loc);
680680// / If the type is itself not generic, this does nothing.
681681// /
682682// / This function emits diagnostics about an invalid type or the wrong number
683- // / of generic arguments, whereas applyUnboundGenericArguments requires this
683+ // / of generic arguments, whereas
684+ // / \c TypeResolution::applyUnboundGenericArguments requires this
684685// / to be in a correct and valid form.
685686// /
686687// / \param type The generic type to which to apply arguments.
@@ -692,7 +693,7 @@ static void diagnoseUnboundGenericType(Type ty, SourceLoc loc);
692693// / \returns A BoundGenericType bound to the given arguments, or null on
693694// / error.
694695// /
695- // / \see applyUnboundGenericArguments
696+ // / \see TypeResolution:: applyUnboundGenericArguments
696697static Type applyGenericArguments (Type type, TypeResolution resolution,
697698 GenericParamList *silParams,
698699 ComponentIdentTypeRepr *comp) {
@@ -826,8 +827,8 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
826827 args.push_back (substTy);
827828 }
828829
829- const auto result = TypeChecker:: applyUnboundGenericArguments (
830- decl, unboundType->getParent (), loc, resolution, args);
830+ const auto result = resolution. applyUnboundGenericArguments (
831+ decl, unboundType->getParent (), loc, args);
831832
832833 // Migration hack.
833834 bool isMutablePointer;
@@ -883,10 +884,9 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
883884}
884885
885886// / Apply generic arguments to the given type.
886- Type TypeChecker::applyUnboundGenericArguments (GenericTypeDecl *decl,
887- Type parentTy, SourceLoc loc,
888- TypeResolution resolution,
889- ArrayRef<Type> genericArgs) {
887+ Type TypeResolution::applyUnboundGenericArguments (
888+ GenericTypeDecl *decl, Type parentTy, SourceLoc loc,
889+ ArrayRef<Type> genericArgs) const {
890890 assert (genericArgs.size () == decl->getGenericParams ()->size () &&
891891 " invalid arguments, use applyGenericArguments for diagnostic emitting" );
892892
@@ -926,9 +926,7 @@ Type TypeChecker::applyUnboundGenericArguments(GenericTypeDecl *decl,
926926 auto genericSig = genericEnv->getGenericSignature ();
927927 for (auto gp : genericSig->getGenericParams ()) {
928928 subs[gp->getCanonicalType ()->castTo <GenericTypeParamType>()] =
929- (resolution.usesArchetypes ()
930- ? genericEnv->mapTypeIntoContext (gp)
931- : gp);
929+ (usesArchetypes () ? genericEnv->mapTypeIntoContext (gp) : gp);
932930 }
933931 }
934932
@@ -952,21 +950,19 @@ Type TypeChecker::applyUnboundGenericArguments(GenericTypeDecl *decl,
952950
953951 // Check the generic arguments against the requirements of the declaration's
954952 // generic signature.
955- auto dc = resolution.getDeclContext ();
956- auto *module = dc->getParentModule ();
953+ auto *module = getDeclContext ()->getParentModule ();
957954
958- if (!skipRequirementsCheck &&
959- resolution.getStage () > TypeResolutionStage::Structural) {
960- auto result = checkGenericArguments (
961- dc, loc, noteLoc,
962- UnboundGenericType::get (decl, parentTy, dc->getASTContext ()),
955+ if (!skipRequirementsCheck && getStage () > TypeResolutionStage::Structural) {
956+ auto result = TypeChecker::checkGenericArguments (
957+ getDeclContext (), loc, noteLoc,
958+ UnboundGenericType::get (decl, parentTy, getASTContext ()),
963959 genericSig->getGenericParams (), genericSig->getRequirements (),
964960 QueryTypeSubstitutionMap{subs});
965961
966962 switch (result) {
967963 case RequirementCheckResult::Failure:
968964 case RequirementCheckResult::SubstitutionFailure:
969- return ErrorType::get (dc-> getASTContext ());
965+ return ErrorType::get (getASTContext ());
970966 case RequirementCheckResult::Success:
971967 break ;
972968 }
@@ -3522,9 +3518,8 @@ TypeResolver::resolveDictionaryType(DictionaryTypeRepr *repr,
35223518 return ErrorType::get (getASTContext ());
35233519 }
35243520
3525- if (!TypeChecker::applyUnboundGenericArguments (
3526- dictDecl, nullptr , repr->getStartLoc (), resolution,
3527- {keyTy, valueTy})) {
3521+ if (!resolution.applyUnboundGenericArguments (
3522+ dictDecl, nullptr , repr->getStartLoc (), {keyTy, valueTy})) {
35283523 assert (getASTContext ().Diags .hadAnyError ());
35293524 return ErrorType::get (getASTContext ());
35303525 }
0 commit comments