Skip to content

Commit ae8c85e

Browse files
committed
Sema: Remove some unnecessary (void) getInterfaceType() calls
1 parent 3b7a0b2 commit ae8c85e

14 files changed

+2
-102
lines changed

lib/Sema/CodeSynthesis.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,6 @@ createDesignatedInitOverride(ClassDecl *classDecl,
685685

686686
// Set the interface type of the initializer.
687687
ctor->setGenericSignature(genericSig);
688-
(void)ctor->getInterfaceType();
689688

690689
ctor->setImplicitlyUnwrappedOptional(
691690
superclassCtor->isImplicitlyUnwrappedOptional());

lib/Sema/DerivedConformanceCodable.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,6 @@ static FuncDecl *deriveEncodable_encode(DerivedConformance &derived) {
738738
encodeDecl->getAttrs().add(attr);
739739
}
740740

741-
(void)encodeDecl->getInterfaceType();
742-
743741
encodeDecl->copyFormalAccessFrom(derived.Nominal,
744742
/*sourceIsParentContext*/ true);
745743

@@ -1018,8 +1016,6 @@ static ValueDecl *deriveDecodable_init(DerivedConformance &derived) {
10181016
initDecl->getAttrs().add(reqAttr);
10191017
}
10201018

1021-
(void)initDecl->getInterfaceType();
1022-
10231019
initDecl->copyFormalAccessFrom(derived.Nominal,
10241020
/*sourceIsParentContext*/ true);
10251021

lib/Sema/DerivedConformanceCodingKey.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@ static ValueDecl *deriveInitDecl(DerivedConformance &derived, Type paramType,
143143
// Synthesize the body.
144144
synthesizer(initDecl);
145145

146-
// Compute the interface type of the initializer.
147-
(void)initDecl->getInterfaceType();
148-
149146
initDecl->setAccess(derived.Nominal->getFormalAccess());
150147

151148
C.addSynthesizedDecl(initDecl);

lib/Sema/DerivedConformanceEquatableHashable.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,6 @@ deriveEquatable_eq(
767767

768768
eqDecl->setBodySynthesizer(bodySynthesizer);
769769

770-
// Compute the interface type.
771-
(void)eqDecl->getInterfaceType();
772-
773770
eqDecl->copyFormalAccessFrom(derived.Nominal, /*sourceIsParentContext*/ true);
774771

775772
C.addSynthesizedDecl(eqDecl);
@@ -891,7 +888,6 @@ deriveHashable_hashInto(
891888
hashDecl->setImplicit();
892889
hashDecl->setBodySynthesizer(bodySynthesizer);
893890

894-
(void)hashDecl->getInterfaceType();
895891
hashDecl->copyFormalAccessFrom(derived.Nominal);
896892

897893
C.addSynthesizedDecl(hashDecl);
@@ -1238,9 +1234,6 @@ static ValueDecl *deriveHashable_hashValue(DerivedConformance &derived) {
12381234
getterDecl->setBodySynthesizer(&deriveBodyHashable_hashValue);
12391235
getterDecl->setIsTransparent(false);
12401236

1241-
// Compute the interface type of hashValue().
1242-
(void)getterDecl->getInterfaceType();
1243-
12441237
getterDecl->copyFormalAccessFrom(derived.Nominal,
12451238
/*sourceIsParentContext*/ true);
12461239

lib/Sema/DerivedConformanceRawRepresentable.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,6 @@ deriveRawRepresentable_init(DerivedConformance &derived) {
428428
initDecl->setImplicit();
429429
initDecl->setBodySynthesizer(&deriveBodyRawRepresentable_init);
430430

431-
// Compute the interface type of the initializer.
432-
(void)initDecl->getInterfaceType();
433-
434431
initDecl->copyFormalAccessFrom(enumDecl, /*sourceIsParentContext*/true);
435432

436433
// If the containing module is not resilient, make sure clients can construct

lib/Sema/DerivedConformances.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,6 @@ DerivedConformance::declareDerivedPropertyGetter(VarDecl *property,
309309
getterDecl->setImplicit();
310310
getterDecl->setIsTransparent(false);
311311

312-
// Compute the interface type of the getter.
313-
(void)getterDecl->getInterfaceType();
314-
315312
getterDecl->copyFormalAccessFrom(property);
316313

317314
C.addSynthesizedDecl(getterDecl);

lib/Sema/LookupVisibleDecls.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,6 @@ static void doDynamicLookup(VisibleDeclConsumer &Consumer,
282282
if (D->isRecursiveValidation())
283283
return;
284284

285-
// FIXME: This is used to compute isInvalid() below.
286-
(void) D->getInterfaceType();
287-
288285
switch (D->getKind()) {
289286
#define DECL(ID, SUPER) \
290287
case DeclKind::ID:
@@ -430,8 +427,6 @@ static void lookupDeclsFromProtocolsBeingConformedTo(
430427
continue;
431428
}
432429
if (auto *VD = dyn_cast<ValueDecl>(Member)) {
433-
// FIXME(InterfaceTypeRequest): Remove this.
434-
(void)VD->getInterfaceType();
435430
if (auto *TypeResolver = VD->getASTContext().getLazyResolver()) {
436431
if (!NormalConformance->hasWitness(VD) &&
437432
(Conformance->getDeclContext()->getParentSourceFile() !=

lib/Sema/TypeCheckAttr.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,6 @@ bool swift::isValidDynamicCallableMethod(FuncDecl *decl, DeclContext *DC,
10711071
// `ExpressibleByStringLiteral`.
10721072
// `D.Value` and the return type can be arbitrary.
10731073

1074-
// FIXME(InterfaceTypeRequest): Remove this.
1075-
(void)decl->getInterfaceType();
10761074
auto paramList = decl->getParameters();
10771075
if (paramList->size() != 1 || paramList->get(0)->isVariadic()) return false;
10781076
auto argType = paramList->get(0)->getType();
@@ -1242,8 +1240,6 @@ visitDynamicMemberLookupAttr(DynamicMemberLookupAttr *attr) {
12421240
auto oneCandidate = candidates.front().getValueDecl();
12431241
candidates.filter([&](LookupResultEntry entry, bool isOuter) -> bool {
12441242
auto cand = cast<SubscriptDecl>(entry.getValueDecl());
1245-
// FIXME(InterfaceTypeRequest): Remove this.
1246-
(void)cand->getInterfaceType();
12471243
return isValidDynamicMemberLookupSubscript(cand, decl);
12481244
});
12491245

@@ -1266,8 +1262,6 @@ visitDynamicMemberLookupAttr(DynamicMemberLookupAttr *attr) {
12661262
// Validate the candidates while ignoring the label.
12671263
newCandidates.filter([&](const LookupResultEntry entry, bool isOuter) {
12681264
auto cand = cast<SubscriptDecl>(entry.getValueDecl());
1269-
// FIXME(InterfaceTypeRequest): Remove this.
1270-
(void)cand->getInterfaceType();
12711265
return isValidDynamicMemberLookupSubscript(cand, decl,
12721266
/*ignoreLabel*/ true);
12731267
});
@@ -2111,9 +2105,6 @@ static Type getDynamicComparisonType(ValueDecl *value) {
21112105
}
21122106

21132107
auto interfaceType = value->getInterfaceType();
2114-
if (!interfaceType)
2115-
return ErrorType::get(value->getASTContext());
2116-
21172108
return interfaceType->removeArgumentLabels(numArgumentLabels);
21182109
}
21192110

@@ -2177,8 +2168,6 @@ static FuncDecl *findReplacedAccessor(DeclName replacedVarName,
21772168

21782169
assert(!isa<FuncDecl>(results[0]));
21792170

2180-
// FIXME(InterfaceTypeRequest): Remove this.
2181-
(void)results[0]->getInterfaceType();
21822171
auto *origStorage = cast<AbstractStorageDecl>(results[0]);
21832172
if (!origStorage->isDynamic()) {
21842173
Diags.diagnose(attr->getLocation(),
@@ -2194,8 +2183,6 @@ static FuncDecl *findReplacedAccessor(DeclName replacedVarName,
21942183
if (!origAccessor)
21952184
return nullptr;
21962185

2197-
// FIXME(InterfaceTypeRequest): Remove this.
2198-
(void)origAccessor->getInterfaceType();
21992186
if (origAccessor->isImplicit() &&
22002187
!(origStorage->getReadImpl() == ReadImplKind::Stored &&
22012188
origStorage->getWriteImpl() == WriteImplKind::Stored)) {
@@ -2348,8 +2335,6 @@ void AttributeChecker::visitDynamicReplacementAttr(DynamicReplacementAttr *attr)
23482335
if (attr->isInvalid())
23492336
return;
23502337

2351-
// FIXME(InterfaceTypeRequest): Remove this.
2352-
(void)accessor->getInterfaceType();
23532338
auto *orig = findReplacedAccessor(attr->getReplacedFunctionName(),
23542339
accessor, attr, Ctx);
23552340
if (!orig)

lib/Sema/TypeCheckConstraints.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static bool containsDeclRefKind(LookupResult &lookupResult,
229229
DeclRefKind refKind) {
230230
for (auto candidate : lookupResult) {
231231
ValueDecl *D = candidate.getValueDecl();
232-
if (!D || !D->hasInterfaceType())
232+
if (!D)
233233
continue;
234234
if (matchesDeclRefKind(D, refKind))
235235
return true;

lib/Sema/TypeCheckDeclObjC.cpp

+1-46
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,7 @@ bool swift::isRepresentableInObjC(
487487

488488
// If you change this function, you must add or modify a test in PrintAsObjC.
489489
ASTContext &ctx = AFD->getASTContext();
490-
// FIXME(InterfaceTypeRequest): Remove this.
491-
(void)AFD->getInterfaceType();
490+
492491
bool Diagnose = shouldDiagnoseObjCReason(Reason, ctx);
493492

494493
if (checkObjCInForeignClassContext(AFD, Reason))
@@ -982,50 +981,6 @@ Type TypeChecker::getObjCSelectorType(DeclContext *dc) {
982981
dc);
983982
}
984983

985-
#pragma mark Bridging support
986-
987-
/// Check runtime functions responsible for implicit bridging of Objective-C
988-
/// types.
989-
static void checkObjCBridgingFunctions(ModuleDecl *mod,
990-
StringRef bridgedTypeName,
991-
StringRef forwardConversion,
992-
StringRef reverseConversion) {
993-
assert(mod);
994-
SmallVector<ValueDecl *, 4> results;
995-
996-
auto &ctx = mod->getASTContext();
997-
mod->lookupValue(ctx.getIdentifier(bridgedTypeName),
998-
NLKind::QualifiedLookup, results);
999-
mod->lookupValue(ctx.getIdentifier(forwardConversion),
1000-
NLKind::QualifiedLookup, results);
1001-
mod->lookupValue(ctx.getIdentifier(reverseConversion),
1002-
NLKind::QualifiedLookup, results);
1003-
1004-
for (auto D : results) {
1005-
// FIXME(InterfaceTypeRequest): Remove this.
1006-
(void)D->getInterfaceType();
1007-
}
1008-
}
1009-
1010-
void swift::checkBridgedFunctions(ASTContext &ctx) {
1011-
#define BRIDGE_TYPE(BRIDGED_MOD, BRIDGED_TYPE, _, NATIVE_TYPE, OPT) \
1012-
Identifier ID_##BRIDGED_MOD = ctx.getIdentifier(#BRIDGED_MOD);\
1013-
if (ModuleDecl *module = ctx.getLoadedModule(ID_##BRIDGED_MOD)) {\
1014-
checkObjCBridgingFunctions(module, #BRIDGED_TYPE, \
1015-
"_convert" #BRIDGED_TYPE "To" #NATIVE_TYPE, \
1016-
"_convert" #NATIVE_TYPE "To" #BRIDGED_TYPE); \
1017-
}
1018-
#include "swift/SIL/BridgedTypes.def"
1019-
1020-
if (ModuleDecl *module = ctx.getLoadedModule(ctx.Id_Foundation)) {
1021-
checkObjCBridgingFunctions(module,
1022-
ctx.getSwiftName(
1023-
KnownFoundationEntity::NSError),
1024-
"_convertNSErrorToError",
1025-
"_convertErrorToNSError");
1026-
}
1027-
}
1028-
1029984
#pragma mark "@objc declaration handling"
1030985

1031986
/// Whether this declaration is a member of a class extension marked @objc.

lib/Sema/TypeCheckObjC.h

-5
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ bool isRepresentableInObjC(const SubscriptDecl *SD, ObjCReason Reason);
135135
/// Check whether the given declaration can be represented in Objective-C.
136136
bool canBeRepresentedInObjC(const ValueDecl *decl);
137137

138-
/// Check that specific, known bridging functions are fully type-checked.
139-
///
140-
/// NOTE: This is only here to support the --enable-source-import hack.
141-
void checkBridgedFunctions(ASTContext &ctx);
142-
143138
/// Attach Fix-Its to the given diagnostic that updates the name of the
144139
/// given declaration to the desired target name.
145140
///

lib/Sema/TypeCheckPropertyWrapper.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,6 @@ PropertyWrapperBackingPropertyTypeRequest::evaluate(
546546
}
547547

548548
// Compute the type of the property to plug in to the wrapper type.
549-
// FIXME(InterfaceTypeRequest): Remove this.
550-
(void)var->getInterfaceType();
551549
Type propertyType = var->getType();
552550
if (!propertyType || propertyType->hasError())
553551
return Type();

lib/Sema/TypeCheckStmt.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -2065,9 +2065,6 @@ TypeCheckFunctionBodyUntilRequest::evaluate(Evaluator &evaluator,
20652065
if (tc.DebugTimeFunctionBodies || tc.WarnLongFunctionBodies)
20662066
timer.emplace(AFD, tc.DebugTimeFunctionBodies, tc.WarnLongFunctionBodies);
20672067

2068-
// FIXME(InterfaceTypeRequest): Remove this.
2069-
(void)AFD->getInterfaceType();
2070-
20712068
BraceStmt *body = AFD->getBody();
20722069
if (!body || AFD->isBodyTypeChecked())
20732070
return false;

lib/Sema/TypeChecker.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,6 @@ void swift::performTypeChecking(SourceFile &SF, TopLevelContext &TLC,
424424
// to work.
425425
bindExtensions(SF);
426426

427-
// Look for bridging functions. This only matters when
428-
// -enable-source-import is provided.
429-
checkBridgedFunctions(TC.Context);
430-
431427
// Type check the top-level elements of the source file.
432428
for (auto D : llvm::makeArrayRef(SF.Decls).slice(StartElem)) {
433429
if (auto *TLCD = dyn_cast<TopLevelCodeDecl>(D)) {

0 commit comments

Comments
 (0)