Skip to content
Merged
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
23 changes: 12 additions & 11 deletions lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "swift/Basic/StringExtras.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/Fixnum.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/SaveAndRestore.h"

Expand Down Expand Up @@ -1119,10 +1118,12 @@ namespace {
/// \param locator Locator used to describe where in this expression we are.
///
/// \returns the coerced expression, which will have type \c ToType.
Expr *coerceCallArguments(Expr *arg, Type paramType,
llvm::PointerUnion<ApplyExpr *, llvm::Fixnum<2>>
applyOrLevel,
ConstraintLocatorBuilder locator);
using LevelTy = llvm::PointerEmbeddedInt<unsigned, 2>;

Expr *
coerceCallArguments(Expr *arg, Type paramType,
llvm::PointerUnion<ApplyExpr *, LevelTy> applyOrLevel,
ConstraintLocatorBuilder locator);

/// \brief Coerce the given object argument (e.g., for the base of a
/// member expression) to the given type.
Expand Down Expand Up @@ -1191,9 +1192,9 @@ namespace {
}

// Coerce the index argument.
index = coerceCallArguments(index, indexTy, /*level=*/llvm::Fixnum<2>(1),
locator.withPathElement(
ConstraintLocator::SubscriptIndex));
index = coerceCallArguments(
index, indexTy, LevelTy(1),
locator.withPathElement(ConstraintLocator::SubscriptIndex));
if (!index)
return nullptr;

Expand Down Expand Up @@ -4545,7 +4546,7 @@ static bool isReferenceToMetatypeMember(Expr *expr) {

Expr *ExprRewriter::coerceCallArguments(
Expr *arg, Type paramType,
llvm::PointerUnion<ApplyExpr *, llvm::Fixnum<2>> applyOrLevel,
llvm::PointerUnion<ApplyExpr *, LevelTy> applyOrLevel,
ConstraintLocatorBuilder locator) {

bool allParamsMatch = arg->getType()->isEqual(paramType);
Expand All @@ -4556,9 +4557,9 @@ Expr *ExprRewriter::coerceCallArguments(

// Determine the level,
unsigned level = 0;
if (applyOrLevel.is<llvm::Fixnum<2>>()) {
if (applyOrLevel.is<LevelTy>()) {
// Level specified by caller.
level = applyOrLevel.get<llvm::Fixnum<2>>();
level = applyOrLevel.get<LevelTy>();
} else if (callee) {
// Determine the level based on the application itself.
auto apply = applyOrLevel.get<ApplyExpr *>();
Expand Down