Skip to content

Commit d62be44

Browse files
committed
[CSSolver] Split `getType(ValueDecl*) into three - getType{OrNull, OrInterfaceType}
1 parent 398abdf commit d62be44

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
10171017
// Determine the type of the value, opening up that type if necessary.
10181018
bool wantInterfaceType = !varDecl->getDeclContext()->isLocalContext();
10191019
Type valueType = TC.getUnopenedTypeOfReference(
1020-
varDecl, Type(), DC, getType(varDecl, false), base, wantInterfaceType);
1020+
varDecl, Type(), DC, getTypeOrNull(varDecl), base, wantInterfaceType);
10211021

10221022
assert(!valueType->hasUnboundGenericType() &&
10231023
!valueType->hasTypeParameter());
@@ -1338,8 +1338,8 @@ ConstraintSystem::getTypeOfMemberReference(
13381338
AnyFunctionType::ExtInfo());
13391339
} else {
13401340
refType = TC.getUnopenedTypeOfReference(cast<VarDecl>(value), baseTy,
1341-
useDC, getType(value, false),
1342-
base, /*wantInterfaceType=*/true);
1341+
useDC, getTypeOrNull(value), base,
1342+
/*wantInterfaceType=*/true);
13431343
}
13441344

13451345
auto selfTy = outerDC->getSelfInterfaceType();

lib/Sema/ConstraintSystem.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,17 +1649,23 @@ class ConstraintSystem {
16491649
return TypeLocTypes.find(&L)->second;
16501650
}
16511651

1652-
Type getType(const ValueDecl *P, bool queryDeclOnMiss = true) const {
1653-
if (auto *PD = dyn_cast<ParamDecl>(P)) {
1654-
assert(hasType(PD) && "Expected type to have been set!");
1655-
return ParamTypes.find(PD)->second;
1656-
}
1652+
Type getType(const ParamDecl *P) const {
1653+
assert(hasType(P) && "Expected type to have been set!");
1654+
return ParamTypes.find(P)->second;
1655+
}
1656+
1657+
Type getTypeOrNull(const ValueDecl *D) const {
1658+
if (auto *P = dyn_cast<ParamDecl>(D))
1659+
return getType(P);
1660+
return Type();
1661+
}
16571662

1658-
if (!queryDeclOnMiss)
1659-
return Type();
1663+
Type getTypeOrInterfaceType(const ValueDecl *D) const {
1664+
if (auto *P = dyn_cast<ParamDecl>(D))
1665+
return getType(P);
16601666

1661-
assert(P->hasValidSignature());
1662-
return P->getInterfaceType();
1667+
assert(D->hasValidSignature());
1668+
return D->getInterfaceType();
16631669
}
16641670

16651671
/// Cache the type of the expression argument and return that same

0 commit comments

Comments
 (0)