Skip to content

Commit 9a4fb8c

Browse files
authored
Merge pull request #10790 from CodaFi/disjunction-junction
[Gardening] Rename getInOutOrLValueObjectType to getWithoutSpecifierType
2 parents be204f2 + 957d633 commit 9a4fb8c

18 files changed

+63
-61
lines changed

include/swift/AST/Type.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ class CanType : public Type {
381381
static CanType getAnyOptionalObjectTypeImpl(CanType type,
382382
OptionalTypeKind &kind);
383383
static CanType getReferenceStorageReferentImpl(CanType type);
384-
static CanType getLValueOrInOutObjectTypeImpl(CanType type);
384+
static CanType getWithoutSpecifierTypeImpl(CanType type);
385385

386386
public:
387387
explicit CanType(TypeBase *P = 0) : Type(P) {
@@ -459,8 +459,8 @@ class CanType : public Type {
459459
return getReferenceStorageReferentImpl(*this);
460460
}
461461

462-
CanType getLValueOrInOutObjectType() const {
463-
return getLValueOrInOutObjectTypeImpl(*this);
462+
CanType getWithoutSpecifierType() const {
463+
return getWithoutSpecifierTypeImpl(*this);
464464
}
465465

466466
// Direct comparison is allowed for CanTypes - they are known canonical.

include/swift/AST/Types.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,10 @@ class alignas(1 << TypeAlignInBits) TypeBase {
838838
/// type. Otherwise, returns the type itself.
839839
Type getInOutObjectType();
840840

841-
/// getLValueOrInOutObjectType - For an @lvalue or inout type, retrieves the
842-
/// underlying object type. Otherwise, returns the type itself.
843-
Type getLValueOrInOutObjectType();
841+
/// getWithoutSpecifierType - For a non-materializable type
842+
/// e.g. @lvalue or inout, retrieves the underlying object type.
843+
/// Otherwise, returns the type itself.
844+
Type getWithoutSpecifierType();
844845

845846
/// Retrieves the rvalue instance type, looking through single-element
846847
/// tuples, inout types, and metatypes.
@@ -4655,9 +4656,10 @@ inline Type TypeBase::getRValueObjectType() {
46554656
return type->getWithoutImmediateLabel();
46564657
}
46574658

4658-
/// getLValueOrInOutObjectType - For an @lvalue or inout type, retrieves the
4659-
/// underlying object type. Otherwise, returns the type itself.
4660-
inline Type TypeBase::getLValueOrInOutObjectType() {
4659+
/// getWithoutSpecifierType - For a non-materializable type
4660+
/// e.g. @lvalue or inout, retrieves the underlying object type.
4661+
/// Otherwise, returns the type itself.
4662+
inline Type TypeBase::getWithoutSpecifierType() {
46614663
if (auto iot = getAs<InOutType>())
46624664
return iot->getObjectType();
46634665
if (auto lv = getAs<LValueType>())
@@ -4679,7 +4681,7 @@ inline CanType CanType::getReferenceStorageReferentImpl(CanType type) {
46794681
return type;
46804682
}
46814683

4682-
inline CanType CanType::getLValueOrInOutObjectTypeImpl(CanType type) {
4684+
inline CanType CanType::getWithoutSpecifierTypeImpl(CanType type) {
46834685
if (auto refType = dyn_cast<InOutType>(type))
46844686
return refType.getObjectType();
46854687
if (auto refType = dyn_cast<LValueType>(type))

include/swift/SIL/AbstractionPattern.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ class AbstractionPattern {
895895

896896
/// Given that the value being abstracted is an l-value or inout type,
897897
/// return the abstraction pattern for its object type.
898-
AbstractionPattern getLValueOrInOutObjectType() const;
898+
AbstractionPattern getWithoutSpecifierType() const;
899899

900900
/// Given that the value being abstracted is a function, return the
901901
/// abstraction pattern for its result type.

lib/AST/ASTVerifier.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,7 @@ class Verifier : public ASTWalker {
15971597
}
15981598

15991599
// The base of a member reference cannot be an existential type.
1600-
if (E->getBase()->getType()->getLValueOrInOutObjectType()
1600+
if (E->getBase()->getType()->getWithoutSpecifierType()
16011601
->isAnyExistentialType()) {
16021602
Out << "Member reference into an unopened existential type\n";
16031603
E->dump(Out);
@@ -1627,7 +1627,7 @@ class Verifier : public ASTWalker {
16271627

16281628
// The base of a dynamic member reference cannot be an
16291629
// existential type.
1630-
if (E->getBase()->getType()->getLValueOrInOutObjectType()
1630+
if (E->getBase()->getType()->getWithoutSpecifierType()
16311631
->isAnyExistentialType()) {
16321632
Out << "Member reference into an unopened existential type\n";
16331633
E->dump(Out);
@@ -1646,7 +1646,7 @@ class Verifier : public ASTWalker {
16461646
}
16471647

16481648
// The base of a subscript cannot be an existential type.
1649-
if (E->getBase()->getType()->getLValueOrInOutObjectType()
1649+
if (E->getBase()->getType()->getWithoutSpecifierType()
16501650
->isAnyExistentialType()) {
16511651
Out << "Member reference into an unopened existential type\n";
16521652
E->dump(Out);
@@ -1662,7 +1662,7 @@ class Verifier : public ASTWalker {
16621662
PrettyStackTraceExpr debugStack(Ctx, "verifying DynamicSubscriptExpr", E);
16631663

16641664
// The base of a subscript cannot be an existential type.
1665-
if (E->getBase()->getType()->getLValueOrInOutObjectType()
1665+
if (E->getBase()->getType()->getWithoutSpecifierType()
16661666
->isAnyExistentialType()) {
16671667
Out << "Member reference into an unopened existential type\n";
16681668
E->dump(Out);

lib/IRGen/DebugTypeInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ class DebugTypeInfo {
8585
GenericEnvironment *getGenericEnvironment() const { return GenericEnv; }
8686

8787
void unwrapLValueOrInOutType() {
88-
Type = Type->getLValueOrInOutObjectType().getPointer();
88+
Type = Type->getWithoutSpecifierType().getPointer();
8989
}
9090

9191
// Determine whether this type is an Archetype itself.
9292
bool isArchetype() const {
93-
return Type->getLValueOrInOutObjectType()->is<ArchetypeType>();
93+
return Type->getWithoutSpecifierType()->is<ArchetypeType>();
9494
}
9595

9696
/// LValues, inout args, and Archetypes are implicitly indirect by

lib/IRGen/GenKeyPath.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ IRGenModule::getAddrOfKeyPathPattern(KeyPathPattern *pattern,
173173
Lowering::GenericContextScope scope(getSILTypes(),
174174
pattern->getGenericSignature());
175175
loweredBaseTy = getLoweredType(AbstractionPattern::getOpaque(),
176-
baseTy->getLValueOrInOutObjectType());
176+
baseTy->getWithoutSpecifierType());
177177
auto &component = pattern->getComponents()[i];
178178
switch (auto kind = component.getKind()) {
179179
case KeyPathPatternComponent::Kind::StoredProperty: {

lib/SIL/AbstractionPattern.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ AbstractionPattern AbstractionPattern::dropLastTupleElement() const {
588588
llvm_unreachable("bad kind");
589589
}
590590

591-
AbstractionPattern AbstractionPattern::getLValueOrInOutObjectType() const {
591+
AbstractionPattern AbstractionPattern::getWithoutSpecifierType() const {
592592
switch (getKind()) {
593593
case Kind::Invalid:
594594
llvm_unreachable("querying invalid abstraction pattern!");
@@ -607,13 +607,13 @@ AbstractionPattern AbstractionPattern::getLValueOrInOutObjectType() const {
607607
return *this;
608608
case Kind::Type:
609609
return AbstractionPattern(getGenericSignature(),
610-
getType().getLValueOrInOutObjectType());
610+
getType().getWithoutSpecifierType());
611611
case Kind::Discard:
612612
return AbstractionPattern::getDiscard(getGenericSignature(),
613-
getType().getLValueOrInOutObjectType());
613+
getType().getWithoutSpecifierType());
614614
case Kind::ClangType:
615615
return AbstractionPattern(getGenericSignature(),
616-
getType().getLValueOrInOutObjectType(),
616+
getType().getWithoutSpecifierType(),
617617
getClangType());
618618
}
619619
llvm_unreachable("bad kind");

lib/SIL/TypeLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ static CanTupleType getLoweredTupleType(TypeConverter &tc,
14441444

14451445
CanType loweredSubstEltType;
14461446
if (auto substLV = dyn_cast<InOutType>(substEltType)) {
1447-
SILType silType = tc.getLoweredType(origType.getLValueOrInOutObjectType(),
1447+
SILType silType = tc.getLoweredType(origType.getWithoutSpecifierType(),
14481448
substLV.getObjectType());
14491449
loweredSubstEltType = CanInOutType::get(silType.getSwiftRValueType());
14501450

@@ -1527,8 +1527,8 @@ TypeConverter::getTypeLowering(AbstractionPattern origType,
15271527
// completely removed and represented as 'address' SILTypes.
15281528
if (isa<InOutType>(substType)) {
15291529
// Derive SILType for InOutType from the object type.
1530-
CanType substObjectType = substType.getLValueOrInOutObjectType();
1531-
AbstractionPattern origObjectType = origType.getLValueOrInOutObjectType();
1530+
CanType substObjectType = substType.getWithoutSpecifierType();
1531+
AbstractionPattern origObjectType = origType.getWithoutSpecifierType();
15321532

15331533
SILType loweredType = getLoweredType(origObjectType, substObjectType)
15341534
.getAddressType();

lib/SILGen/SILGenBridging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) {
13201320
if (thunk.kind == SILDeclRef::Kind::Allocator) {
13211321
allocatorSelfType = forwardedParameters[0]
13221322
->getInterfaceType(getASTContext())
1323-
->getLValueOrInOutObjectType();
1323+
->getWithoutSpecifierType();
13241324
if (F.getGenericEnvironment())
13251325
allocatorSelfType = F.getGenericEnvironment()
13261326
->mapTypeIntoContext(allocatorSelfType);

lib/SILGen/SILGenExpr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,7 +2390,7 @@ RValue RValueEmitter::visitTupleShuffleExpr(TupleShuffleExpr *E,
23902390
}
23912391

23922392
SILValue SILGenFunction::emitMetatypeOfValue(SILLocation loc, Expr *baseExpr) {
2393-
Type formalBaseType = baseExpr->getType()->getLValueOrInOutObjectType();
2393+
Type formalBaseType = baseExpr->getType()->getWithoutSpecifierType();
23942394
CanType baseTy = formalBaseType->getCanonicalType();
23952395

23962396
// For class, archetype, and protocol types, look up the dynamic metatype.
@@ -2840,7 +2840,7 @@ RValue RValueEmitter::visitKeyPathExpr(KeyPathExpr *E, SGFContext C) {
28402840
// If the stored value would need to be reabstracted in fully opaque
28412841
// context, then we have to treat the component as computed.
28422842
auto componentObjTy =
2843-
component.getComponentType()->getLValueOrInOutObjectType();
2843+
component.getComponentType()->getWithoutSpecifierType();
28442844
auto storageTy = SGF.SGM.Types.getSubstitutedStorageType(decl,
28452845
componentObjTy);
28462846
auto opaqueTy = SGF.getLoweredType(AbstractionPattern::getOpaque(),
@@ -3277,7 +3277,7 @@ RValue RValueEmitter::visitRebindSelfInConstructorExpr(
32773277
}
32783278

32793279
static bool isVerbatimNullableTypeInC(SILModule &M, Type ty) {
3280-
ty = ty->getLValueOrInOutObjectType()->getReferenceStorageReferent();
3280+
ty = ty->getWithoutSpecifierType()->getReferenceStorageReferent();
32813281

32823282
// Class instances, and @objc existentials are all nullable.
32833283
if (ty->hasReferenceSemantics()) {
@@ -4184,7 +4184,7 @@ void SILGenFunction::emitOpenExistentialExprImpl(
41844184
writebackScope.emplace(*this);
41854185

41864186
Type formalRValueType =
4187-
E->getOpaqueValue()->getType()->getLValueOrInOutObjectType();
4187+
E->getOpaqueValue()->getType()->getWithoutSpecifierType();
41884188

41894189
accessKind = E->getExistentialValue()->getLValueAccessKind();
41904190
auto lv = emitLValue(E->getExistentialValue(), accessKind);

lib/SILGen/SILGenLValue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2085,7 +2085,7 @@ LValue SILGenLValue::visitOpaqueValueExpr(OpaqueValueExpr *e,
20852085
lv = SGF.emitOpenExistentialLValue(
20862086
opened, std::move(lv),
20872087
CanArchetypeType(opened->getOpenedArchetype()),
2088-
e->getType()->getLValueOrInOutObjectType()->getCanonicalType(),
2088+
e->getType()->getWithoutSpecifierType()->getCanonicalType(),
20892089
accessKind);
20902090
return lv;
20912091
}

lib/Sema/CSApply.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ namespace {
15081508
if (selfTy->hasReferenceSemantics()) {
15091509
auto covariantTy = resultTy
15101510
->replaceCovariantResultType(cs.getType(base)
1511-
->getLValueOrInOutObjectType(),
1511+
->getWithoutSpecifierType(),
15121512
ctor->getNumParameterLists());
15131513
if (!covariantTy->isEqual(resultTy))
15141514
ctorRef = cs.cacheType(
@@ -4020,7 +4020,7 @@ namespace {
40204020
case KeyPathExpr::Component::Kind::OptionalChain: {
40214021
didOptionalChain = true;
40224022
// Chaining always forces the element to be an rvalue.
4023-
auto objectTy = baseTy->getLValueOrInOutObjectType()
4023+
auto objectTy = baseTy->getWithoutSpecifierType()
40244024
->getAnyOptionalObjectType();
40254025
if (baseTy->hasUnresolvedType() && !objectTy) {
40264026
objectTy = baseTy;
@@ -4072,7 +4072,7 @@ namespace {
40724072
!baseTy->hasUnresolvedType() &&
40734073
!baseTy->isEqual(leafTy)) {
40744074
assert(leafTy->getAnyOptionalObjectType()
4075-
->isEqual(baseTy->getLValueOrInOutObjectType()));
4075+
->isEqual(baseTy->getWithoutSpecifierType()));
40764076
auto component = KeyPathExpr::Component::forOptionalWrap(leafTy);
40774077
resolvedComponents.push_back(component);
40784078
baseTy = leafTy;
@@ -4098,7 +4098,7 @@ namespace {
40984098

40994099
// The final component type ought to line up with the leaf type of the
41004100
// key path.
4101-
assert(!baseTy || baseTy->getLValueOrInOutObjectType()->isEqual(leafTy));
4101+
assert(!baseTy || baseTy->getWithoutSpecifierType()->isEqual(leafTy));
41024102
return E;
41034103
}
41044104

@@ -5235,8 +5235,8 @@ Expr *ExprRewriter::coerceCallArguments(
52355235

52365236
for (size_t i = 0; i < params.size(); i++) {
52375237
if (auto dotExpr = dyn_cast<DotSyntaxCallExpr>(argElts[i])) {
5238-
auto paramTy = params[i].getType()->getLValueOrInOutObjectType();
5239-
auto argTy = cs.getType(dotExpr)->getLValueOrInOutObjectType();
5238+
auto paramTy = params[i].getType()->getWithoutSpecifierType();
5239+
auto argTy = cs.getType(dotExpr)->getWithoutSpecifierType();
52405240
if (!paramTy->isEqual(argTy)) {
52415241
allParamsMatch = false;
52425242
break;
@@ -5548,7 +5548,7 @@ ClosureExpr *ExprRewriter::coerceClosureExprToVoid(ClosureExpr *closureExpr) {
55485548
// necessary any more, but it's probably still a good idea.
55495549
if (cs.getType(singleExpr)->is<LValueType>())
55505550
cs.setType(singleExpr,
5551-
cs.getType(singleExpr)->getLValueOrInOutObjectType());
5551+
cs.getType(singleExpr)->getWithoutSpecifierType());
55525552

55535553
tc.checkIgnoredExpr(singleExpr);
55545554

@@ -6246,7 +6246,7 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
62466246
static Type adjustSelfTypeForMember(Type baseTy, ValueDecl *member,
62476247
AccessSemantics semantics,
62486248
DeclContext *UseDC) {
6249-
auto baseObjectTy = baseTy->getLValueOrInOutObjectType();
6249+
auto baseObjectTy = baseTy->getWithoutSpecifierType();
62506250
if (auto func = dyn_cast<AbstractFunctionDecl>(member)) {
62516251
// If 'self' is an inout type, turn the base type into an lvalue
62526252
// type with the same qualifiers.
@@ -6732,7 +6732,7 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
67326732
assert(arg->getNumElements() == 2 && "should have two arguments");
67336733
auto nonescaping = arg->getElements()[0];
67346734
auto body = arg->getElements()[1];
6735-
auto bodyTy = cs.getType(body)->getLValueOrInOutObjectType();
6735+
auto bodyTy = cs.getType(body)->getWithoutSpecifierType();
67366736
auto bodyFnTy = bodyTy->castTo<FunctionType>();
67376737
auto escapableType = bodyFnTy->getInput();
67386738
auto resultType = bodyFnTy->getResult();

lib/Sema/CSDiag.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ void CalleeCandidateInfo::collectCalleeCandidates(Expr *fn,
15891589
Type baseType;
15901590
if (isa<SelfApplyExpr>(AE) &&
15911591
!isUnresolvedOrTypeVarType(CS->getType(AE->getArg())))
1592-
baseType = CS->getType(AE->getArg())->getLValueOrInOutObjectType();
1592+
baseType = CS->getType(AE->getArg())->getWithoutSpecifierType();
15931593

15941594
for (auto &C : candidates) {
15951595
C.level += 1;
@@ -1599,7 +1599,7 @@ void CalleeCandidateInfo::collectCalleeCandidates(Expr *fn,
15991599
// Compute a new substituted type if we have a base type to apply.
16001600
if (baseType && C.level == 1 && C.getDecl()) {
16011601
baseType = baseType
1602-
->getLValueOrInOutObjectType()
1602+
->getWithoutSpecifierType()
16031603
->getRValueInstanceType();
16041604
C.entityType = baseType->getTypeOfMember(CS->DC->getParentModule(),
16051605
C.getDecl(), nullptr);
@@ -1652,7 +1652,7 @@ void CalleeCandidateInfo::collectCalleeCandidates(Expr *fn,
16521652
// If we have useful information about the type we're
16531653
// initializing, provide it.
16541654
if (UDE->getName().getBaseName() == CS->TC.Context.Id_init) {
1655-
auto selfTy = CS->getType(UDE->getBase())->getLValueOrInOutObjectType();
1655+
auto selfTy = CS->getType(UDE->getBase())->getWithoutSpecifierType();
16561656
if (!selfTy->hasTypeVariable())
16571657
declName = selfTy.getString() + "." + declName;
16581658
}
@@ -1786,7 +1786,7 @@ CalleeCandidateInfo::CalleeCandidateInfo(Type baseType,
17861786
auto substType = replaceTypeVariablesWithUnresolved(baseType);
17871787
if (substType)
17881788
substType = substType
1789-
->getLValueOrInOutObjectType()
1789+
->getWithoutSpecifierType()
17901790
->getRValueInstanceType();
17911791

17921792
// If this is a DeclViaUnwrappingOptional, then we're actually looking
@@ -5931,7 +5931,7 @@ bool FailureDiagnosis::diagnoseArgumentGenericRequirements(
59315931
// Bindings specify the arguments that source the parameter. The only case
59325932
// this returns a non-singular value is when there are varargs in play.
59335933
for (auto argNo : bindings[i]) {
5934-
auto argType = args[argNo].getType()->getLValueOrInOutObjectType();
5934+
auto argType = args[argNo].getType()->getWithoutSpecifierType();
59355935

59365936
if (argType->is<ArchetypeType>()) {
59375937
diagnoseUnboundArchetype(archetype, fnExpr);
@@ -8285,7 +8285,7 @@ bool FailureDiagnosis::diagnoseMemberFailures(
82858285
if (!baseExpr)
82868286
return true;
82878287

8288-
baseTy = CS->getType(baseExpr)->getLValueOrInOutObjectType();
8288+
baseTy = CS->getType(baseExpr)->getWithoutSpecifierType();
82898289
baseObjTy = baseTy;
82908290
}
82918291

@@ -8855,7 +8855,7 @@ FailureDiagnosis::validateContextualType(Type contextualType,
88558855
};
88568856

88578857
bool shouldNullify = false;
8858-
if (auto objectType = contextualType->getLValueOrInOutObjectType()) {
8858+
if (auto objectType = contextualType->getWithoutSpecifierType()) {
88598859
// Note that simply checking for `objectType->hasUnresolvedType()` is not
88608860
// appropriate in this case standalone, because if it's in a function,
88618861
// for example, or inout type, we still want to preserve it's skeleton

0 commit comments

Comments
 (0)