Skip to content

Commit 32e6846

Browse files
committed
Remove TypeChecker from parameter default checking
1 parent b7d94e4 commit 32e6846

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4787,7 +4787,7 @@ getCallerDefaultArg(ConstraintSystem &cs, DeclContext *dc,
47874787
// Convert the literal to the appropriate type.
47884788
auto defArgType =
47894789
param->getInterfaceType().subst(owner.getSubstitutions());
4790-
auto resultTy = cs.getTypeChecker().typeCheckParameterDefault(
4790+
auto resultTy = TypeChecker::typeCheckParameterDefault(
47914791
init, dc, defArgType,
47924792
/*isAutoClosure=*/param->isAutoClosure(),
47934793
/*canFail=*/false);

lib/Sema/TypeCheckDecl.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ static void checkInheritedDefaultValueRestrictions(ParamDecl *PD) {
20262026
}
20272027

20282028
/// Check the default arguments that occur within this pattern.
2029-
static void checkDefaultArguments(TypeChecker &tc, ParameterList *params) {
2029+
static void checkDefaultArguments(ParameterList *params) {
20302030
for (auto *param : *params) {
20312031
checkInheritedDefaultValueRestrictions(param);
20322032
if (!param->getDefaultValue() ||
@@ -2038,8 +2038,8 @@ static void checkDefaultArguments(TypeChecker &tc, ParameterList *params) {
20382038
auto *initContext = param->getDefaultArgumentInitContext();
20392039

20402040
auto resultTy =
2041-
typeCheckParameterDefault(e, initContext, param->getType(),
2042-
/*isAutoClosure=*/param->isAutoClosure());
2041+
TypeChecker::typeCheckParameterDefault(e, initContext, param->getType(),
2042+
param->isAutoClosure());
20432043

20442044
if (resultTy) {
20452045
param->setDefaultValue(e);
@@ -2658,9 +2658,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
26582658

26592659
TypeChecker::checkParameterAttributes(SD->getIndices());
26602660

2661-
// FIXME: Remove TypeChecker dependency.
2662-
auto &TC = *Ctx.getLegacyGlobalTypeChecker();
2663-
checkDefaultArguments(TC, SD->getIndices());
2661+
checkDefaultArguments(SD->getIndices());
26642662

26652663
if (SD->getDeclContext()->getSelfClassDecl()) {
26662664
checkDynamicSelfType(SD, SD->getValueInterfaceType());
@@ -3282,7 +3280,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
32823280
if (FD->getDeclContext()->getSelfClassDecl())
32833281
checkDynamicSelfType(FD, FD->getResultInterfaceType());
32843282

3285-
checkDefaultArguments(TC, FD->getParameters());
3283+
checkDefaultArguments(FD->getParameters());
32863284

32873285
// Validate 'static'/'class' on functions in extensions.
32883286
auto StaticSpelling = FD->getStaticSpelling();
@@ -3342,9 +3340,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
33423340
if (auto *PL = EED->getParameterList()) {
33433341
TypeChecker::checkParameterAttributes(PL);
33443342

3345-
// FIXME: Remove TypeChecker dependency.
3346-
auto &TC = *Ctx.getLegacyGlobalTypeChecker();
3347-
checkDefaultArguments(TC, PL);
3343+
checkDefaultArguments(PL);
33483344
}
33493345

33503346
auto &DE = getASTContext().Diags;
@@ -3608,7 +3604,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
36083604
TC.definedFunctions.push_back(CD);
36093605
}
36103606

3611-
checkDefaultArguments(TC, CD->getParameters());
3607+
checkDefaultArguments(CD->getParameters());
36123608
}
36133609

36143610
void visitDestructorDecl(DestructorDecl *DD) {

lib/Sema/TypeChecker.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,9 +966,10 @@ class TypeChecker final {
966966

967967
bool typeCheckTapBody(TapExpr *expr, DeclContext *DC);
968968

969-
Type typeCheckParameterDefault(Expr *&defaultValue, DeclContext *DC,
970-
Type paramType, bool isAutoClosure = false,
971-
bool canFail = true);
969+
static Type typeCheckParameterDefault(Expr *&defaultValue, DeclContext *DC,
970+
Type paramType,
971+
bool isAutoClosure = false,
972+
bool canFail = true);
972973

973974
void typeCheckTopLevelCodeDecl(TopLevelCodeDecl *TLCD);
974975

0 commit comments

Comments
 (0)