Skip to content

[Gardening] Rename getInOutOrLValueObjectType to getWithoutSpecifierType #10790

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 6, 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
6 changes: 3 additions & 3 deletions include/swift/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class CanType : public Type {
static CanType getAnyOptionalObjectTypeImpl(CanType type,
OptionalTypeKind &kind);
static CanType getReferenceStorageReferentImpl(CanType type);
static CanType getLValueOrInOutObjectTypeImpl(CanType type);
static CanType getWithoutSpecifierTypeImpl(CanType type);

public:
explicit CanType(TypeBase *P = 0) : Type(P) {
Expand Down Expand Up @@ -459,8 +459,8 @@ class CanType : public Type {
return getReferenceStorageReferentImpl(*this);
}

CanType getLValueOrInOutObjectType() const {
return getLValueOrInOutObjectTypeImpl(*this);
CanType getWithoutSpecifierType() const {
return getWithoutSpecifierTypeImpl(*this);
}

// Direct comparison is allowed for CanTypes - they are known canonical.
Expand Down
16 changes: 9 additions & 7 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -838,9 +838,10 @@ class alignas(1 << TypeAlignInBits) TypeBase {
/// type. Otherwise, returns the type itself.
Type getInOutObjectType();

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

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

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

inline CanType CanType::getLValueOrInOutObjectTypeImpl(CanType type) {
inline CanType CanType::getWithoutSpecifierTypeImpl(CanType type) {
if (auto refType = dyn_cast<InOutType>(type))
return refType.getObjectType();
if (auto refType = dyn_cast<LValueType>(type))
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SIL/AbstractionPattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ class AbstractionPattern {

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

/// Given that the value being abstracted is a function, return the
/// abstraction pattern for its result type.
Expand Down
8 changes: 4 additions & 4 deletions lib/AST/ASTVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ class Verifier : public ASTWalker {
}

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

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

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

// The base of a subscript cannot be an existential type.
if (E->getBase()->getType()->getLValueOrInOutObjectType()
if (E->getBase()->getType()->getWithoutSpecifierType()
->isAnyExistentialType()) {
Out << "Member reference into an unopened existential type\n";
E->dump(Out);
Expand Down
4 changes: 2 additions & 2 deletions lib/IRGen/DebugTypeInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ class DebugTypeInfo {
GenericEnvironment *getGenericEnvironment() const { return GenericEnv; }

void unwrapLValueOrInOutType() {
Type = Type->getLValueOrInOutObjectType().getPointer();
Type = Type->getWithoutSpecifierType().getPointer();
}

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

/// LValues, inout args, and Archetypes are implicitly indirect by
Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/GenKeyPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ IRGenModule::getAddrOfKeyPathPattern(KeyPathPattern *pattern,
Lowering::GenericContextScope scope(getSILTypes(),
pattern->getGenericSignature());
loweredBaseTy = getLoweredType(AbstractionPattern::getOpaque(),
baseTy->getLValueOrInOutObjectType());
baseTy->getWithoutSpecifierType());
auto &component = pattern->getComponents()[i];
switch (auto kind = component.getKind()) {
case KeyPathPatternComponent::Kind::StoredProperty: {
Expand Down
8 changes: 4 additions & 4 deletions lib/SIL/AbstractionPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ AbstractionPattern AbstractionPattern::dropLastTupleElement() const {
llvm_unreachable("bad kind");
}

AbstractionPattern AbstractionPattern::getLValueOrInOutObjectType() const {
AbstractionPattern AbstractionPattern::getWithoutSpecifierType() const {
switch (getKind()) {
case Kind::Invalid:
llvm_unreachable("querying invalid abstraction pattern!");
Expand All @@ -607,13 +607,13 @@ AbstractionPattern AbstractionPattern::getLValueOrInOutObjectType() const {
return *this;
case Kind::Type:
return AbstractionPattern(getGenericSignature(),
getType().getLValueOrInOutObjectType());
getType().getWithoutSpecifierType());
case Kind::Discard:
return AbstractionPattern::getDiscard(getGenericSignature(),
getType().getLValueOrInOutObjectType());
getType().getWithoutSpecifierType());
case Kind::ClangType:
return AbstractionPattern(getGenericSignature(),
getType().getLValueOrInOutObjectType(),
getType().getWithoutSpecifierType(),
getClangType());
}
llvm_unreachable("bad kind");
Expand Down
6 changes: 3 additions & 3 deletions lib/SIL/TypeLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ static CanTupleType getLoweredTupleType(TypeConverter &tc,

CanType loweredSubstEltType;
if (auto substLV = dyn_cast<InOutType>(substEltType)) {
SILType silType = tc.getLoweredType(origType.getLValueOrInOutObjectType(),
SILType silType = tc.getLoweredType(origType.getWithoutSpecifierType(),
substLV.getObjectType());
loweredSubstEltType = CanInOutType::get(silType.getSwiftRValueType());

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

SILType loweredType = getLoweredType(origObjectType, substObjectType)
.getAddressType();
Expand Down
2 changes: 1 addition & 1 deletion lib/SILGen/SILGenBridging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) {
if (thunk.kind == SILDeclRef::Kind::Allocator) {
allocatorSelfType = forwardedParameters[0]
->getInterfaceType(getASTContext())
->getLValueOrInOutObjectType();
->getWithoutSpecifierType();
if (F.getGenericEnvironment())
allocatorSelfType = F.getGenericEnvironment()
->mapTypeIntoContext(allocatorSelfType);
Expand Down
8 changes: 4 additions & 4 deletions lib/SILGen/SILGenExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,7 @@ RValue RValueEmitter::visitTupleShuffleExpr(TupleShuffleExpr *E,
}

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

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

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

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

Type formalRValueType =
E->getOpaqueValue()->getType()->getLValueOrInOutObjectType();
E->getOpaqueValue()->getType()->getWithoutSpecifierType();

accessKind = E->getExistentialValue()->getLValueAccessKind();
auto lv = emitLValue(E->getExistentialValue(), accessKind);
Expand Down
2 changes: 1 addition & 1 deletion lib/SILGen/SILGenLValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ LValue SILGenLValue::visitOpaqueValueExpr(OpaqueValueExpr *e,
lv = SGF.emitOpenExistentialLValue(
opened, std::move(lv),
CanArchetypeType(opened->getOpenedArchetype()),
e->getType()->getLValueOrInOutObjectType()->getCanonicalType(),
e->getType()->getWithoutSpecifierType()->getCanonicalType(),
accessKind);
return lv;
}
Expand Down
18 changes: 9 additions & 9 deletions lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ namespace {
if (selfTy->hasReferenceSemantics()) {
auto covariantTy = resultTy
->replaceCovariantResultType(cs.getType(base)
->getLValueOrInOutObjectType(),
->getWithoutSpecifierType(),
ctor->getNumParameterLists());
if (!covariantTy->isEqual(resultTy))
ctorRef = cs.cacheType(
Expand Down Expand Up @@ -4020,7 +4020,7 @@ namespace {
case KeyPathExpr::Component::Kind::OptionalChain: {
didOptionalChain = true;
// Chaining always forces the element to be an rvalue.
auto objectTy = baseTy->getLValueOrInOutObjectType()
auto objectTy = baseTy->getWithoutSpecifierType()
->getAnyOptionalObjectType();
if (baseTy->hasUnresolvedType() && !objectTy) {
objectTy = baseTy;
Expand Down Expand Up @@ -4072,7 +4072,7 @@ namespace {
!baseTy->hasUnresolvedType() &&
!baseTy->isEqual(leafTy)) {
assert(leafTy->getAnyOptionalObjectType()
->isEqual(baseTy->getLValueOrInOutObjectType()));
->isEqual(baseTy->getWithoutSpecifierType()));
auto component = KeyPathExpr::Component::forOptionalWrap(leafTy);
resolvedComponents.push_back(component);
baseTy = leafTy;
Expand All @@ -4098,7 +4098,7 @@ namespace {

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

Expand Down Expand Up @@ -5235,8 +5235,8 @@ Expr *ExprRewriter::coerceCallArguments(

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

tc.checkIgnoredExpr(singleExpr);

Expand Down Expand Up @@ -6246,7 +6246,7 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
static Type adjustSelfTypeForMember(Type baseTy, ValueDecl *member,
AccessSemantics semantics,
DeclContext *UseDC) {
auto baseObjectTy = baseTy->getLValueOrInOutObjectType();
auto baseObjectTy = baseTy->getWithoutSpecifierType();
if (auto func = dyn_cast<AbstractFunctionDecl>(member)) {
// If 'self' is an inout type, turn the base type into an lvalue
// type with the same qualifiers.
Expand Down Expand Up @@ -6732,7 +6732,7 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
assert(arg->getNumElements() == 2 && "should have two arguments");
auto nonescaping = arg->getElements()[0];
auto body = arg->getElements()[1];
auto bodyTy = cs.getType(body)->getLValueOrInOutObjectType();
auto bodyTy = cs.getType(body)->getWithoutSpecifierType();
auto bodyFnTy = bodyTy->castTo<FunctionType>();
auto escapableType = bodyFnTy->getInput();
auto resultType = bodyFnTy->getResult();
Expand Down
14 changes: 7 additions & 7 deletions lib/Sema/CSDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@ void CalleeCandidateInfo::collectCalleeCandidates(Expr *fn,
Type baseType;
if (isa<SelfApplyExpr>(AE) &&
!isUnresolvedOrTypeVarType(CS->getType(AE->getArg())))
baseType = CS->getType(AE->getArg())->getLValueOrInOutObjectType();
baseType = CS->getType(AE->getArg())->getWithoutSpecifierType();

for (auto &C : candidates) {
C.level += 1;
Expand All @@ -1599,7 +1599,7 @@ void CalleeCandidateInfo::collectCalleeCandidates(Expr *fn,
// Compute a new substituted type if we have a base type to apply.
if (baseType && C.level == 1 && C.getDecl()) {
baseType = baseType
->getLValueOrInOutObjectType()
->getWithoutSpecifierType()
->getRValueInstanceType();
C.entityType = baseType->getTypeOfMember(CS->DC->getParentModule(),
C.getDecl(), nullptr);
Expand Down Expand Up @@ -1652,7 +1652,7 @@ void CalleeCandidateInfo::collectCalleeCandidates(Expr *fn,
// If we have useful information about the type we're
// initializing, provide it.
if (UDE->getName().getBaseName() == CS->TC.Context.Id_init) {
auto selfTy = CS->getType(UDE->getBase())->getLValueOrInOutObjectType();
auto selfTy = CS->getType(UDE->getBase())->getWithoutSpecifierType();
if (!selfTy->hasTypeVariable())
declName = selfTy.getString() + "." + declName;
}
Expand Down Expand Up @@ -1786,7 +1786,7 @@ CalleeCandidateInfo::CalleeCandidateInfo(Type baseType,
auto substType = replaceTypeVariablesWithUnresolved(baseType);
if (substType)
substType = substType
->getLValueOrInOutObjectType()
->getWithoutSpecifierType()
->getRValueInstanceType();

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

if (argType->is<ArchetypeType>()) {
diagnoseUnboundArchetype(archetype, fnExpr);
Expand Down Expand Up @@ -8283,7 +8283,7 @@ bool FailureDiagnosis::diagnoseMemberFailures(
if (!baseExpr)
return true;

baseTy = CS->getType(baseExpr)->getLValueOrInOutObjectType();
baseTy = CS->getType(baseExpr)->getWithoutSpecifierType();
baseObjTy = baseTy;
}

Expand Down Expand Up @@ -8853,7 +8853,7 @@ FailureDiagnosis::validateContextualType(Type contextualType,
};

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