Skip to content

Commit 90fa96d

Browse files
committed
Sema: Fold SubscriptDecl::computeType() into validateDecl()
1 parent 09034fd commit 90fa96d

File tree

5 files changed

+14
-23
lines changed

5 files changed

+14
-23
lines changed

include/swift/AST/Decl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5484,10 +5484,6 @@ class SubscriptDecl : public GenericContext, public AbstractStorageDecl {
54845484
TypeLoc &getElementTypeLoc() { return ElementTy; }
54855485
const TypeLoc &getElementTypeLoc() const { return ElementTy; }
54865486

5487-
/// Compute the interface type of this subscript from the parameter and
5488-
/// element types.
5489-
void computeType();
5490-
54915487
/// Determine the kind of Objective-C subscripting this declaration
54925488
/// implies.
54935489
ObjCSubscriptKind getObjCSubscriptKind() const;

lib/AST/Decl.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6145,22 +6145,6 @@ Type SubscriptDecl::getElementInterfaceType() const {
61456145
ErrorType::get(ctx));
61466146
}
61476147

6148-
void SubscriptDecl::computeType() {
6149-
auto elementTy = getElementInterfaceType();
6150-
6151-
SmallVector<AnyFunctionType::Param, 2> argTy;
6152-
getIndices()->getParams(argTy);
6153-
6154-
Type funcTy;
6155-
if (auto sig = getGenericSignature())
6156-
funcTy = GenericFunctionType::get(sig, argTy, elementTy);
6157-
else
6158-
funcTy = FunctionType::get(argTy, elementTy);
6159-
6160-
// Record the interface type.
6161-
setInterfaceType(funcTy);
6162-
}
6163-
61646148
ObjCSubscriptKind SubscriptDecl::getObjCSubscriptKind() const {
61656149
// If the index type is an integral type, we have an indexed
61666150
// subscript.

lib/ClangImporter/ImportDecl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6734,7 +6734,6 @@ SwiftDeclConverter::importSubscript(Decl *decl,
67346734

67356735
subscript->setIsSetterMutating(false);
67366736
makeComputed(subscript, getterThunk, setterThunk);
6737-
subscript->computeType();
67386737

67396738
Impl.recordImplicitUnwrapForDecl(subscript, isIUO);
67406739

lib/Sema/TypeCheckDecl.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4285,7 +4285,20 @@ void TypeChecker::validateDecl(ValueDecl *D) {
42854285
case DeclKind::Subscript: {
42864286
auto *SD = cast<SubscriptDecl>(D);
42874287
DeclValidationRAII IBV(SD);
4288-
SD->computeType();
4288+
4289+
auto elementTy = SD->getElementInterfaceType();
4290+
4291+
SmallVector<AnyFunctionType::Param, 2> argTy;
4292+
SD->getIndices()->getParams(argTy);
4293+
4294+
Type funcTy;
4295+
if (auto sig = SD->getGenericSignature())
4296+
funcTy = GenericFunctionType::get(sig, argTy, elementTy);
4297+
else
4298+
funcTy = FunctionType::get(argTy, elementTy);
4299+
4300+
// Record the interface type.
4301+
SD->setInterfaceType(funcTy);
42894302
break;
42904303
}
42914304

lib/Serialization/Deserialization.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3691,7 +3691,6 @@ class swift::DeclDeserializer {
36913691
auto elemInterfaceType = MF.getType(elemInterfaceTypeID);
36923692
subscript->getElementTypeLoc().setType(elemInterfaceType);
36933693
subscript->setImplicitlyUnwrappedOptional(isIUO);
3694-
subscript->computeType();
36953694

36963695
if (isImplicit)
36973696
subscript->setImplicit();

0 commit comments

Comments
 (0)