Skip to content

Commit 4d9e8d9

Browse files
committed
Constify several DeclContext parameters. NFC.
1 parent f952d2e commit 4d9e8d9

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

include/swift/AST/ASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ class ASTContext {
522522
ForeignRepresentationInfo
523523
getForeignRepresentationInfo(NominalTypeDecl *nominal,
524524
ForeignLanguage language,
525-
DeclContext *dc);
525+
const DeclContext *dc);
526526

527527
/// Add a declaration to a list of declarations that need to be emitted
528528
/// as part of the current module or source file, but are otherwise not

include/swift/AST/ProtocolConformance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance {
254254

255255
/// Determine whether this protocol conformance is visible from the
256256
/// given declaration context.
257-
bool isVisibleFrom(DeclContext *dc) const;
257+
bool isVisibleFrom(const DeclContext *dc) const;
258258

259259
/// Determine whether the witness for the given requirement
260260
/// is either the default definition or was otherwise deduced.

include/swift/AST/Types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,22 +712,22 @@ class alignas(1 << TypeAlignInBits) TypeBase {
712712
/// Determine whether the given type is representable in the given
713713
/// foreign language.
714714
std::pair<ForeignRepresentableKind, ProtocolConformance *>
715-
getForeignRepresentableIn(ForeignLanguage language, DeclContext *dc);
715+
getForeignRepresentableIn(ForeignLanguage language, const DeclContext *dc);
716716

717717
/// Determines whether the given Swift type is representable within
718718
/// the given foreign language.
719719
///
720720
/// A given Swift type is representable in the given foreign
721721
/// language if the Swift type can be used from source code written
722722
/// in that language.
723-
bool isRepresentableIn(ForeignLanguage language, DeclContext *dc);
723+
bool isRepresentableIn(ForeignLanguage language, const DeclContext *dc);
724724

725725
/// Determines whether the type is trivially representable within
726726
/// the foreign language, meaning that it is both representable in
727727
/// that language and that the runtime representations are
728728
/// equivalent.
729729
bool isTriviallyRepresentableIn(ForeignLanguage language,
730-
DeclContext *dc);
730+
const DeclContext *dc);
731731

732732
/// \brief Given that this is a nominal type or bound generic nominal
733733
/// type, return its parent type; this will be a null type if the type

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3795,7 +3795,7 @@ static NominalTypeDecl *findUnderlyingTypeInModule(ASTContext &ctx,
37953795
ForeignRepresentationInfo
37963796
ASTContext::getForeignRepresentationInfo(NominalTypeDecl *nominal,
37973797
ForeignLanguage language,
3798-
DeclContext *dc) {
3798+
const DeclContext *dc) {
37993799
if (Impl.ForeignRepresentableCache.empty()) {
38003800
// Local function to add a type with the given name and module as
38013801
// trivially-representable.

lib/AST/ProtocolConformance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ ProtocolConformance::getRootNormalConformance() const {
404404
return cast<NormalProtocolConformance>(C);
405405
}
406406

407-
bool ProtocolConformance::isVisibleFrom(DeclContext *dc) const {
407+
bool ProtocolConformance::isVisibleFrom(const DeclContext *dc) const {
408408
// FIXME: Implement me!
409409
return true;
410410
}

lib/AST/Type.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,8 +1930,8 @@ bool TypeBase::isPotentiallyBridgedValueType() {
19301930
}
19311931

19321932
/// Determine whether this is a representable Objective-C object type.
1933-
static ForeignRepresentableKind getObjCObjectRepresentable(Type type,
1934-
DeclContext *dc) {
1933+
static ForeignRepresentableKind
1934+
getObjCObjectRepresentable(Type type, const DeclContext *dc) {
19351935
// @objc metatypes are representable when their instance type is.
19361936
if (auto metatype = type->getAs<AnyMetatypeType>()) {
19371937
// If the instance type is not representable, the metatype is not
@@ -1986,7 +1986,8 @@ static ForeignRepresentableKind getObjCObjectRepresentable(Type type,
19861986
/// to be reflected in PrintAsObjC, so that the Swift type will be
19871987
/// properly printed for (Objective-)C and in SIL's bridging logic.
19881988
static std::pair<ForeignRepresentableKind, ProtocolConformance *>
1989-
getForeignRepresentable(Type type, ForeignLanguage language, DeclContext *dc) {
1989+
getForeignRepresentable(Type type, ForeignLanguage language,
1990+
const DeclContext *dc) {
19901991
// Look through one level of optional type, but remember that we did.
19911992
bool wasOptional = false;
19921993
if (auto valueType = type->getAnyOptionalObjectType()) {
@@ -2218,11 +2219,13 @@ getForeignRepresentable(Type type, ForeignLanguage language, DeclContext *dc) {
22182219
}
22192220

22202221
std::pair<ForeignRepresentableKind, ProtocolConformance *>
2221-
TypeBase::getForeignRepresentableIn(ForeignLanguage language, DeclContext *dc) {
2222+
TypeBase::getForeignRepresentableIn(ForeignLanguage language,
2223+
const DeclContext *dc) {
22222224
return getForeignRepresentable(Type(this), language, dc);
22232225
}
22242226

2225-
bool TypeBase::isRepresentableIn(ForeignLanguage language, DeclContext *dc) {
2227+
bool TypeBase::isRepresentableIn(ForeignLanguage language,
2228+
const DeclContext *dc) {
22262229
switch (getForeignRepresentableIn(language, dc).first) {
22272230
case ForeignRepresentableKind::None:
22282231
return false;
@@ -2236,7 +2239,7 @@ bool TypeBase::isRepresentableIn(ForeignLanguage language, DeclContext *dc) {
22362239
}
22372240

22382241
bool TypeBase::isTriviallyRepresentableIn(ForeignLanguage language,
2239-
DeclContext *dc) {
2242+
const DeclContext *dc) {
22402243
switch (getForeignRepresentableIn(language, dc).first) {
22412244
case ForeignRepresentableKind::None:
22422245
case ForeignRepresentableKind::Bridged:

0 commit comments

Comments
 (0)