Skip to content

Commit a1e59b6

Browse files
authored
Merge pull request #27806 from CodaFi/it-isnt-about-computers-and-it-isnt-about-science
[NFC] Remove AbstractFunctionDecl::computeType()
2 parents 7be975c + 497a222 commit a1e59b6

11 files changed

+32
-86
lines changed

include/swift/AST/Decl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5834,10 +5834,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
58345834
}
58355835

58365836
public:
5837-
/// Compute the interface type of this function declaration from the
5838-
/// parameter types.
5839-
void computeType(AnyFunctionType::ExtInfo Info = FunctionType::ExtInfo());
5840-
58415837
/// Retrieve the source range of the function body.
58425838
SourceRange getBodySourceRange() const;
58435839

lib/AST/Builtins.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ StringRef swift::getBuiltinBaseName(ASTContext &C, StringRef Name,
149149

150150
/// Build a builtin function declaration.
151151
static FuncDecl *
152-
getBuiltinFunction(Identifier Id, ArrayRef<Type> argTypes, Type ResType,
153-
FunctionType::ExtInfo Info = FunctionType::ExtInfo()) {
152+
getBuiltinFunction(Identifier Id, ArrayRef<Type> argTypes, Type ResType) {
154153
auto &Context = ResType->getASTContext();
155154

156155
ModuleDecl *M = Context.TheBuiltinModule;
@@ -177,7 +176,7 @@ getBuiltinFunction(Identifier Id, ArrayRef<Type> argTypes, Type ResType,
177176
/*GenericParams=*/nullptr,
178177
paramList,
179178
TypeLoc::withoutLoc(ResType), DC);
180-
FD->computeType(Info);
179+
(void)FD->getInterfaceType();
181180
FD->setImplicit();
182181
FD->setAccess(AccessLevel::Public);
183182
return FD;
@@ -224,7 +223,7 @@ getBuiltinGenericFunction(Identifier Id,
224223
TypeLoc::withoutLoc(ResType), DC);
225224

226225
func->setGenericSignature(Sig);
227-
func->computeType();
226+
(void)func->getInterfaceType();
228227
func->setImplicit();
229228
func->setAccess(AccessLevel::Public);
230229

lib/AST/Decl.cpp

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3921,7 +3921,7 @@ GetDestructorRequest::evaluate(Evaluator &evaluator, ClassDecl *CD) const {
39213921
CD->recordObjCMethod(DD, DD->getObjCSelector());
39223922

39233923
// Assign DD the interface type (Self) -> () -> ()
3924-
DD->computeType();
3924+
(void)DD->getInterfaceType();
39253925

39263926
return DD;
39273927
}
@@ -6628,55 +6628,6 @@ Identifier OpaqueTypeDecl::getOpaqueReturnTypeIdentifier() const {
66286628
return OpaqueReturnTypeIdentifier;
66296629
}
66306630

6631-
void AbstractFunctionDecl::computeType(AnyFunctionType::ExtInfo info) {
6632-
auto sig = getGenericSignature();
6633-
bool hasSelf = hasImplicitSelfDecl();
6634-
6635-
// Result
6636-
Type resultTy;
6637-
if (auto fn = dyn_cast<FuncDecl>(this)) {
6638-
resultTy = fn->getResultInterfaceType();
6639-
} else if (auto ctor = dyn_cast<ConstructorDecl>(this)) {
6640-
resultTy = ctor->getResultInterfaceType();
6641-
} else {
6642-
assert(isa<DestructorDecl>(this));
6643-
resultTy = TupleType::getEmpty(getASTContext());
6644-
}
6645-
6646-
// (Args...) -> Result
6647-
Type funcTy;
6648-
6649-
{
6650-
SmallVector<AnyFunctionType::Param, 4> argTy;
6651-
getParameters()->getParams(argTy);
6652-
6653-
// 'throws' only applies to the innermost function.
6654-
info = info.withThrows(hasThrows());
6655-
// Defer bodies must not escape.
6656-
if (auto fd = dyn_cast<FuncDecl>(this))
6657-
info = info.withNoEscape(fd->isDeferBody());
6658-
6659-
if (sig && !hasSelf) {
6660-
funcTy = GenericFunctionType::get(sig, argTy, resultTy, info);
6661-
} else {
6662-
funcTy = FunctionType::get(argTy, resultTy, info);
6663-
}
6664-
}
6665-
6666-
// (Self) -> (Args...) -> Result
6667-
if (hasSelf) {
6668-
// Substitute in our own 'self' parameter.
6669-
auto selfParam = computeSelfParam(this);
6670-
if (sig)
6671-
funcTy = GenericFunctionType::get(sig, {selfParam}, funcTy);
6672-
else
6673-
funcTy = FunctionType::get({selfParam}, funcTy);
6674-
}
6675-
6676-
// Record the interface type.
6677-
setInterfaceType(funcTy);
6678-
}
6679-
66806631
bool AbstractFunctionDecl::hasInlinableBodyText() const {
66816632
switch (getBodyKind()) {
66826633
case BodyKind::Deserialized:

lib/ClangImporter/ImportDecl.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ makeEnumRawValueConstructor(ClangImporter::Implementation &Impl,
541541
ctorDecl->setImplicit();
542542
ctorDecl->setAccess(AccessLevel::Public);
543543

544-
ctorDecl->computeType();
544+
(void)ctorDecl->getInterfaceType();
545545
ctorDecl->setBodySynthesizer(synthesizeEnumRawValueConstructorBody, enumDecl);
546546
return ctorDecl;
547547
}
@@ -617,7 +617,7 @@ static void makeEnumRawValueGetter(ClangImporter::Implementation &Impl,
617617
getterDecl->setIsDynamic(false);
618618
getterDecl->setIsTransparent(false);
619619

620-
getterDecl->computeType();
620+
(void)getterDecl->getInterfaceType();
621621

622622
getterDecl->setAccess(AccessLevel::Public);
623623
getterDecl->setBodySynthesizer(synthesizeEnumRawValueGetterBody, enumDecl);
@@ -698,7 +698,7 @@ static AccessorDecl *makeStructRawValueGetter(
698698
getterDecl->setIsDynamic(false);
699699
getterDecl->setIsTransparent(false);
700700

701-
getterDecl->computeType();
701+
(void)getterDecl->getInterfaceType();
702702

703703
getterDecl->setAccess(AccessLevel::Public);
704704
getterDecl->setBodySynthesizer(synthesizeStructRawValueGetterBody, storedVar);
@@ -729,7 +729,7 @@ static AccessorDecl *makeFieldGetterDecl(ClangImporter::Implementation &Impl,
729729
getterDecl->setIsObjC(false);
730730
getterDecl->setIsDynamic(false);
731731

732-
getterDecl->computeType();
732+
(void)getterDecl->getInterfaceType();
733733

734734
return getterDecl;
735735
}
@@ -765,7 +765,7 @@ static AccessorDecl *makeFieldSetterDecl(ClangImporter::Implementation &Impl,
765765
setterDecl->setSelfAccessKind(SelfAccessKind::Mutating);
766766
setterDecl->setAccess(AccessLevel::Public);
767767

768-
setterDecl->computeType();
768+
(void)setterDecl->getInterfaceType();
769769

770770
return setterDecl;
771771
}
@@ -1309,7 +1309,7 @@ createDefaultConstructor(ClangImporter::Implementation &Impl,
13091309
/*GenericParams=*/nullptr, structDecl);
13101310

13111311
// Set the constructor's type.
1312-
constructor->computeType();
1312+
(void)constructor->getInterfaceType();
13131313

13141314
constructor->setAccess(AccessLevel::Public);
13151315

@@ -1438,7 +1438,7 @@ createValueConstructor(ClangImporter::Implementation &Impl,
14381438
/*GenericParams=*/nullptr, structDecl);
14391439

14401440
// Set the constructor's type.
1441-
constructor->computeType();
1441+
(void)constructor->getInterfaceType();
14421442

14431443
constructor->setAccess(AccessLevel::Public);
14441444

@@ -1714,7 +1714,7 @@ buildSubscriptGetterDecl(ClangImporter::Implementation &Impl,
17141714
TypeLoc::withoutLoc(elementTy), dc,
17151715
getter->getClangNode());
17161716

1717-
thunk->computeType();
1717+
(void)thunk->getInterfaceType();
17181718

17191719
thunk->setAccess(getOverridableAccessLevel(dc));
17201720

@@ -1767,7 +1767,7 @@ buildSubscriptSetterDecl(ClangImporter::Implementation &Impl,
17671767
valueIndicesPL,
17681768
TypeLoc::withoutLoc(TupleType::getEmpty(C)), dc,
17691769
setter->getClangNode());
1770-
thunk->computeType();
1770+
(void)thunk->getInterfaceType();
17711771

17721772
thunk->setAccess(getOverridableAccessLevel(dc));
17731773

@@ -1952,7 +1952,7 @@ static bool addErrorDomain(NominalTypeDecl *swiftDecl,
19521952
/*GenericParams=*/nullptr,
19531953
params,
19541954
TypeLoc::withoutLoc(stringTy), swiftDecl);
1955-
getterDecl->computeType();
1955+
(void)getterDecl->getInterfaceType();
19561956
getterDecl->setIsObjC(false);
19571957
getterDecl->setIsDynamic(false);
19581958
getterDecl->setIsTransparent(false);
@@ -3736,7 +3736,7 @@ namespace {
37363736

37373737
result->setIsObjC(false);
37383738
result->setIsDynamic(false);
3739-
result->computeType();
3739+
(void)result->getInterfaceType();
37403740

37413741
Impl.recordImplicitUnwrapForDecl(result,
37423742
importedType.isImplicitlyUnwrapped());
@@ -4320,7 +4320,7 @@ namespace {
43204320
result->setImplicit();
43214321

43224322
// Compute the interface type.
4323-
result->computeType();
4323+
(void)result->getInterfaceType();
43244324

43254325
Impl.recordImplicitUnwrapForDecl(result, isIUO);
43264326

@@ -5792,7 +5792,7 @@ Decl *SwiftDeclConverter::importGlobalAsInitializer(
57925792
result->setImportAsStaticMember();
57935793

57945794
// Set the constructor's type.
5795-
result->computeType();
5795+
(void)result->getInterfaceType();
57965796
Impl.recordImplicitUnwrapForDecl(result,
57975797
importedType.isImplicitlyUnwrapped());
57985798
result->setOverriddenDecls({ });
@@ -6300,7 +6300,7 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
63006300
addObjCAttribute(result, selector);
63016301

63026302
// Calculate the function type of the result.
6303-
result->computeType();
6303+
(void)result->getInterfaceType();
63046304

63056305
Impl.recordImplicitUnwrapForDecl(result,
63066306
importedType.isImplicitlyUnwrapped());
@@ -8342,7 +8342,7 @@ ClangImporter::Implementation::createConstant(Identifier name, DeclContext *dc,
83428342
params,
83438343
TypeLoc::withoutLoc(type), dc);
83448344
func->setStatic(isStatic);
8345-
func->computeType();
8345+
(void)func->getInterfaceType();
83468346
func->setAccess(getOverridableAccessLevel(dc));
83478347
func->setIsObjC(false);
83488348
func->setIsDynamic(false);

lib/Sema/CodeSynthesis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ createDesignatedInitOverride(ClassDecl *classDecl,
685685

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

690690
ctor->setImplicitlyUnwrappedOptional(
691691
superclassCtor->isImplicitlyUnwrappedOptional());

lib/Sema/DerivedConformanceCodable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ static FuncDecl *deriveEncodable_encode(DerivedConformance &derived) {
750750
encodeDecl->getAttrs().add(attr);
751751
}
752752

753-
encodeDecl->computeType(FunctionType::ExtInfo().withThrows());
753+
(void)encodeDecl->getInterfaceType();
754754

755755
encodeDecl->copyFormalAccessFrom(derived.Nominal,
756756
/*sourceIsParentContext*/ true);
@@ -1030,7 +1030,7 @@ static ValueDecl *deriveDecodable_init(DerivedConformance &derived) {
10301030
initDecl->getAttrs().add(reqAttr);
10311031
}
10321032

1033-
initDecl->computeType(AnyFunctionType::ExtInfo().withThrows());
1033+
(void)initDecl->getInterfaceType();
10341034

10351035
initDecl->copyFormalAccessFrom(derived.Nominal,
10361036
/*sourceIsParentContext*/ true);

lib/Sema/DerivedConformanceCodingKey.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static ValueDecl *deriveInitDecl(DerivedConformance &derived, Type paramType,
144144
synthesizer(initDecl);
145145

146146
// Compute the interface type of the initializer.
147-
initDecl->computeType();
147+
(void)initDecl->getInterfaceType();
148148

149149
initDecl->setAccess(derived.Nominal->getFormalAccess());
150150

lib/Sema/DerivedConformanceEquatableHashable.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ deriveEquatable_eq(
768768
eqDecl->setBodySynthesizer(bodySynthesizer);
769769

770770
// Compute the interface type.
771-
eqDecl->computeType();
771+
(void)eqDecl->getInterfaceType();
772772

773773
eqDecl->copyFormalAccessFrom(derived.Nominal, /*sourceIsParentContext*/ true);
774774

@@ -892,7 +892,7 @@ deriveHashable_hashInto(
892892
hashDecl->setImplicit();
893893
hashDecl->setBodySynthesizer(bodySynthesizer);
894894

895-
hashDecl->computeType();
895+
(void)hashDecl->getInterfaceType();
896896
hashDecl->copyFormalAccessFrom(derived.Nominal);
897897

898898
C.addSynthesizedDecl(hashDecl);
@@ -1241,7 +1241,7 @@ static ValueDecl *deriveHashable_hashValue(DerivedConformance &derived) {
12411241
getterDecl->setIsTransparent(false);
12421242

12431243
// Compute the interface type of hashValue().
1244-
getterDecl->computeType();
1244+
(void)getterDecl->getInterfaceType();
12451245

12461246
getterDecl->copyFormalAccessFrom(derived.Nominal,
12471247
/*sourceIsParentContext*/ true);

lib/Sema/DerivedConformanceRawRepresentable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ deriveRawRepresentable_init(DerivedConformance &derived) {
430430
initDecl->setBodySynthesizer(&deriveBodyRawRepresentable_init);
431431

432432
// Compute the interface type of the initializer.
433-
initDecl->computeType();
433+
(void)initDecl->getInterfaceType();
434434

435435
initDecl->copyFormalAccessFrom(enumDecl, /*sourceIsParentContext*/true);
436436

lib/Sema/DerivedConformances.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ DerivedConformance::declareDerivedPropertyGetter(VarDecl *property,
309309
getterDecl->setIsTransparent(false);
310310

311311
// Compute the interface type of the getter.
312-
getterDecl->computeType();
312+
(void)getterDecl->getInterfaceType();
313313

314314
getterDecl->copyFormalAccessFrom(property);
315315

lib/Serialization/Deserialization.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,7 +2564,7 @@ class swift::DeclDeserializer {
25642564
}
25652565

25662566
ctor->setImplicitlyUnwrappedOptional(isIUO);
2567-
ctor->computeType();
2567+
(void)ctor->getInterfaceType();
25682568

25692569
return ctor;
25702570
}
@@ -3036,8 +3036,8 @@ class swift::DeclDeserializer {
30363036
cast<OpaqueTypeDecl>(MF.getDecl(opaqueReturnTypeID)));
30373037
}
30383038

3039-
// Set the interface type.
3040-
fn->computeType();
3039+
// Compute the interface type.
3040+
(void)fn->getInterfaceType();
30413041

30423042
return fn;
30433043
}
@@ -3820,7 +3820,7 @@ class swift::DeclDeserializer {
38203820

38213821
dtor->setAccess(std::max(cast<ClassDecl>(DC)->getFormalAccess(),
38223822
AccessLevel::Internal));
3823-
dtor->computeType();
3823+
(void)dtor->getInterfaceType();
38243824

38253825
if (isImplicit)
38263826
dtor->setImplicit();

0 commit comments

Comments
 (0)