Skip to content

Commit ebdd126

Browse files
committed
[NFC] Remove more uses of <InOutType>
1 parent 706c08c commit ebdd126

File tree

6 files changed

+17
-25
lines changed

6 files changed

+17
-25
lines changed

lib/SIL/AbstractionPattern.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ AbstractionPattern TypeConverter::getAbstractionPattern(VarDecl *var) {
7272
if (auto sig = var->getDeclContext()->getGenericSignatureOfContext())
7373
genericSig = sig->getCanonicalSignature();
7474

75-
CanType swiftType = var->getInterfaceType()->getCanonicalType();
76-
if (auto inout = dyn_cast<InOutType>(swiftType))
77-
swiftType = inout.getObjectType();
75+
CanType swiftType = var->getInterfaceType()
76+
->getInOutObjectType()
77+
->getCanonicalType();
7878

7979
if (auto clangDecl = var->getClangDecl()) {
8080
auto clangType = getClangType(clangDecl);

lib/SILGen/SILGenMaterializeForSet.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -433,18 +433,14 @@ struct MaterializeForSetEmitter {
433433
return LValue::forValue(self, SubstSelfType);
434434
}
435435

436+
auto selfParam = computeSelfParam(Witness);
436437
CanType witnessSelfType =
437-
computeSelfParam(Witness).getType()->getCanonicalType(GenericSig);
438+
selfParam.getPlainType()->getCanonicalType(GenericSig);
438439
witnessSelfType = getSubstWitnessInterfaceType(witnessSelfType);
439440

440-
// Get the inout object type, but remember whether we needed to.
441-
auto witnessSelfInOutType = dyn_cast<InOutType>(witnessSelfType);
442-
if (witnessSelfInOutType)
443-
witnessSelfType = witnessSelfInOutType.getObjectType();
444-
445441
// If the witness wants an inout and the types match, just use
446442
// this value.
447-
if (witnessSelfInOutType && witnessSelfType == SubstSelfType) {
443+
if (selfParam.isInOut() && witnessSelfType == SubstSelfType) {
448444
return LValue::forValue(self, witnessSelfType);
449445
}
450446

@@ -462,7 +458,7 @@ struct MaterializeForSetEmitter {
462458
}
463459

464460
// Put the object back in memory if necessary.
465-
if (witnessSelfInOutType) {
461+
if (selfParam.isInOut()) {
466462
self = self.materialize(SGF, loc);
467463
}
468464

lib/Sema/CSGen.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,8 +1293,7 @@ namespace {
12931293
// Create an overload choice referencing this declaration and immediately
12941294
// resolve it. This records the overload for use later.
12951295
auto tv = CS.createTypeVariable(locator,
1296-
TVO_CanBindToLValue |
1297-
TVO_CanBindToInOut);
1296+
TVO_CanBindToLValue);
12981297
CS.resolveOverload(locator, tv,
12991298
OverloadChoice(Type(), E->getDecl(),
13001299
E->getFunctionRefKind()),
@@ -1635,8 +1634,9 @@ namespace {
16351634
SmallVector<TupleTypeElt, 4> elements;
16361635
elements.reserve(expr->getNumElements());
16371636
for (unsigned i = 0, n = expr->getNumElements(); i != n; ++i) {
1638-
auto ty = CS.getType(expr->getElement(i));
1639-
auto flags = ParameterTypeFlags().withInOut(ty->is<InOutType>());
1637+
auto *elt = expr->getElement(i);
1638+
auto ty = CS.getType(elt);
1639+
auto flags = ParameterTypeFlags().withInOut(elt->isSemanticallyInOutExpr());
16401640
elements.push_back(TupleTypeElt(ty->getInOutObjectType(),
16411641
expr->getElementName(i), flags));
16421642
}

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4444,11 +4444,8 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
44444444
// T <p U ===> T[] <a UnsafeMutablePointer<U>
44454445
case ConversionRestrictionKind::ArrayToPointer: {
44464446
addContextualScore();
4447-
auto obj1 = type1;
44484447
// Unwrap an inout type.
4449-
if (auto inout1 = obj1->getAs<InOutType>()) {
4450-
obj1 = inout1->getObjectType();
4451-
}
4448+
auto obj1 = type1->getInOutObjectType();
44524449

44534450
obj1 = getFixedTypeRecursive(obj1, false, false);
44544451

lib/Sema/CalleeCandidateInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ CalleeCandidateInfo::evaluateCloseness(UncurriedCandidate candidate,
370370
// Bindings specify the arguments that source the parameter. The only case
371371
// this returns a non-singular value is when there are varargs in play.
372372
auto &bindings = paramBindings[i];
373-
auto paramType = getParamResultType(candArgs[i]);
373+
auto param = candArgs[i];
374+
auto paramType = getParamResultType(param);
374375

375376
for (auto argNo : bindings) {
376377
auto argType = getParamResultType(actualArgs[argNo]);
@@ -392,7 +393,7 @@ CalleeCandidateInfo::evaluateCloseness(UncurriedCandidate candidate,
392393
auto matchType = paramType;
393394
// If the parameter is an inout type, and we have a proper lvalue, match
394395
// against the type contained therein.
395-
if (paramType->is<InOutType>() && argType->is<LValueType>())
396+
if (param.isInOut() && argType->is<LValueType>())
396397
matchType = matchType->getInOutObjectType();
397398

398399
if (candidate.substituted) {

lib/Sema/TypeCheckCaptures.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,8 @@ void TypeChecker::computeCaptures(AnyFunctionRef AFR) {
675675
unsigned inoutCount = 0;
676676
for (auto C : Captures) {
677677
if (auto PD = dyn_cast<ParamDecl>(C.getDecl()))
678-
if (PD->hasType())
679-
if (auto type = PD->getType())
680-
if (isa<InOutType>(type.getPointer()))
681-
inoutCount++;
678+
if (PD->isInOut())
679+
inoutCount++;
682680
}
683681

684682
if (inoutCount > 0) {

0 commit comments

Comments
 (0)