@@ -421,7 +421,7 @@ TypeChecker::getDynamicBridgedThroughObjCClass(DeclContext *dc,
421
421
422
422
Type TypeResolution::resolveTypeInContext (TypeDecl *typeDecl,
423
423
DeclContext *foundDC,
424
- bool isSpecialized) {
424
+ bool isSpecialized) const {
425
425
auto fromDC = getDeclContext ();
426
426
ASTContext &ctx = fromDC->getASTContext ();
427
427
@@ -680,7 +680,8 @@ static void diagnoseUnboundGenericType(Type ty, SourceLoc loc);
680
680
// / If the type is itself not generic, this does nothing.
681
681
// /
682
682
// / 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
684
685
// / to be in a correct and valid form.
685
686
// /
686
687
// / \param type The generic type to which to apply arguments.
@@ -692,7 +693,7 @@ static void diagnoseUnboundGenericType(Type ty, SourceLoc loc);
692
693
// / \returns A BoundGenericType bound to the given arguments, or null on
693
694
// / error.
694
695
// /
695
- // / \see applyUnboundGenericArguments
696
+ // / \see TypeResolution:: applyUnboundGenericArguments
696
697
static Type applyGenericArguments (Type type, TypeResolution resolution,
697
698
GenericParamList *silParams,
698
699
ComponentIdentTypeRepr *comp) {
@@ -826,8 +827,8 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
826
827
args.push_back (substTy);
827
828
}
828
829
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);
831
832
832
833
// Migration hack.
833
834
bool isMutablePointer;
@@ -883,10 +884,9 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
883
884
}
884
885
885
886
// / 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 {
890
890
assert (genericArgs.size () == decl->getGenericParams ()->size () &&
891
891
" invalid arguments, use applyGenericArguments for diagnostic emitting" );
892
892
@@ -926,9 +926,7 @@ Type TypeChecker::applyUnboundGenericArguments(GenericTypeDecl *decl,
926
926
auto genericSig = genericEnv->getGenericSignature ();
927
927
for (auto gp : genericSig->getGenericParams ()) {
928
928
subs[gp->getCanonicalType ()->castTo <GenericTypeParamType>()] =
929
- (resolution.usesArchetypes ()
930
- ? genericEnv->mapTypeIntoContext (gp)
931
- : gp);
929
+ (usesArchetypes () ? genericEnv->mapTypeIntoContext (gp) : gp);
932
930
}
933
931
}
934
932
@@ -952,21 +950,19 @@ Type TypeChecker::applyUnboundGenericArguments(GenericTypeDecl *decl,
952
950
953
951
// Check the generic arguments against the requirements of the declaration's
954
952
// generic signature.
955
- auto dc = resolution.getDeclContext ();
956
- auto *module = dc->getParentModule ();
953
+ auto *module = getDeclContext ()->getParentModule ();
957
954
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 ()),
963
959
genericSig->getGenericParams (), genericSig->getRequirements (),
964
960
QueryTypeSubstitutionMap{subs});
965
961
966
962
switch (result) {
967
963
case RequirementCheckResult::Failure:
968
964
case RequirementCheckResult::SubstitutionFailure:
969
- return ErrorType::get (dc-> getASTContext ());
965
+ return ErrorType::get (getASTContext ());
970
966
case RequirementCheckResult::Success:
971
967
break ;
972
968
}
@@ -3522,9 +3518,8 @@ TypeResolver::resolveDictionaryType(DictionaryTypeRepr *repr,
3522
3518
return ErrorType::get (getASTContext ());
3523
3519
}
3524
3520
3525
- if (!TypeChecker::applyUnboundGenericArguments (
3526
- dictDecl, nullptr , repr->getStartLoc (), resolution,
3527
- {keyTy, valueTy})) {
3521
+ if (!resolution.applyUnboundGenericArguments (
3522
+ dictDecl, nullptr , repr->getStartLoc (), {keyTy, valueTy})) {
3528
3523
assert (getASTContext ().Diags .hadAnyError ());
3529
3524
return ErrorType::get (getASTContext ());
3530
3525
}
0 commit comments