Skip to content

[NFC] Adjust return type of getTypeOfExpressionWithoutApplying #11048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/Sema/CSDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4650,9 +4650,9 @@ static bool diagnoseImplicitSelfErrors(Expr *fnExpr, Expr *argExpr,
ConcreteDeclRef ref = nullptr;
auto typeResult =
TC.getTypeOfExpressionWithoutApplying(el, CS.DC, ref);
if (!typeResult.hasValue())
if (!typeResult)
return false;
elts.push_back(typeResult.getValue());
elts.push_back(typeResult);
}

argType = TupleType::get(elts, CS.getASTContext());
Expand Down Expand Up @@ -6387,12 +6387,12 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
"unexpected declaration reference");

ConcreteDeclRef decl = nullptr;
Optional<Type> type = CS.TC.getTypeOfExpressionWithoutApplying(
Type type = CS.TC.getTypeOfExpressionWithoutApplying(
fnExpr, CS.DC, decl, FreeTypeVariableBinding::UnresolvedType,
&listener);

if (type.hasValue())
fnType = getFuncType(type.getValue());
if (type)
fnType = getFuncType(type);
} else {
fnExpr = typeCheckChildIndependently(callExpr->getFn(), Type(),
CTP_CalleeResult, TCC_ForceRecheck,
Expand Down Expand Up @@ -7336,7 +7336,7 @@ bool FailureDiagnosis::diagnoseClosureExpr(
auto type = CS.TC.getTypeOfExpressionWithoutApplying(
closure, CS.DC, decl, FreeTypeVariableBinding::Disallow);

if (type && resultTypeProcessor(*type, expectedResultType))
if (type && resultTypeProcessor(type, expectedResultType))
return true;
}

Expand Down Expand Up @@ -7821,7 +7821,7 @@ bool FailureDiagnosis::visitKeyPathExpr(KeyPathExpr *KPE) {
&listener);

if (derivedType) {
if (auto *BGT = (*derivedType)->getAs<BoundGenericClassType>()) {
if (auto *BGT = derivedType->getAs<BoundGenericClassType>()) {
auto derivedValueType = BGT->getGenericArgs().back();
if (!CS.TC.isConvertibleTo(valueType, derivedValueType, CS.DC)) {
diagnose(KPE->getLoc(),
Expand Down Expand Up @@ -8982,7 +8982,7 @@ diagnoseAmbiguousMultiStatementClosure(ClosureExpr *closure) {
auto type = CS.TC.getTypeOfExpressionWithoutApplying(
resultExpr, CS.DC, decl, FreeTypeVariableBinding::UnresolvedType);
if (type)
resultType = type.getValue();
resultType = type;
}

// If we found a type, presuppose it was the intended result and insert a
Expand Down
6 changes: 3 additions & 3 deletions lib/Sema/TypeCheckConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ Type TypeChecker::typeCheckExpression(Expr *&expr, DeclContext *dc,
return cs.getType(expr);
}

Optional<Type> TypeChecker::
Type TypeChecker::
getTypeOfExpressionWithoutApplying(Expr *&expr, DeclContext *dc,
ConcreteDeclRef &referencedDecl,
FreeTypeVariableBinding allowFreeTypeVariables,
Expand Down Expand Up @@ -1843,7 +1843,7 @@ getTypeOfExpressionWithoutApplying(Expr *&expr, DeclContext *dc,
allowFreeTypeVariables, listener, cs, viable,
TypeCheckExprFlags::SuppressDiagnostics)) {
recoverOriginalType();
return None;
return Type();
}

// Get the expression's simplified type.
Expand All @@ -1856,7 +1856,7 @@ getTypeOfExpressionWithoutApplying(Expr *&expr, DeclContext *dc,

if (exprType->hasError()) {
recoverOriginalType();
return None;
return Type();
}

// Dig the declaration out of the solution.
Expand Down
4 changes: 2 additions & 2 deletions lib/Sema/TypeChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -1593,9 +1593,9 @@ class TypeChecker final : public LazyResolver {
/// events in the type checking of this expression, and which can introduce
/// additional constraints.
///
/// \returns the type of \p expr on success, None otherwise.
/// \returns the type of \p expr on success, Type() otherwise.
/// FIXME: expr may still be modified...
Optional<Type> getTypeOfExpressionWithoutApplying(
Type getTypeOfExpressionWithoutApplying(
Expr *&expr, DeclContext *dc,
ConcreteDeclRef &referencedDecl,
FreeTypeVariableBinding allowFreeTypeVariables =
Expand Down