Skip to content

Commit a028eb3

Browse files
committed
Sema: Don't need to return new baseObjTy from getTypeOfMemberReferenceImpl()
1 parent d8ead6c commit a028eb3

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4459,8 +4459,8 @@ class ConstraintSystem {
44594459
DeclContext *useDC,
44604460
PreparedOverloadBuilder *preparedOverload);
44614461

4462-
/// \returns the opened type, the thrown error type, and the base object type.
4463-
std::tuple<Type, Type, Type> getTypeOfMemberReferenceImpl(
4462+
/// \returns the opened type and the thrown error type.
4463+
std::pair<Type, Type> getTypeOfMemberReferenceImpl(
44644464
OverloadChoice choice, DeclContext *useDC, ConstraintLocator *locator,
44654465
SmallVectorImpl<OpenedType> *replacements = nullptr,
44664466
PreparedOverloadBuilder *preparedOverload = nullptr);

lib/Sema/TypeOfReference.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,8 +1628,8 @@ std::pair<Type, Type> ConstraintSystem::getOpenedStorageType(
16281628
FunctionType::Param selfParam(selfTy, Identifier(), selfFlags);
16291629

16301630
FunctionType::ExtInfo info;
1631-
return std::make_pair(thrownErrorType,
1632-
FunctionType::get({selfParam}, refType, info));
1631+
return std::make_pair(FunctionType::get({selfParam}, refType, info),
1632+
thrownErrorType);
16331633
}
16341634

16351635
/// Add the constraint on the type used for the 'Self' type for a member
@@ -1855,7 +1855,7 @@ static FunctionType *applyOptionality(ValueDecl *value, FunctionType *fnTy) {
18551855
fnTy->getExtInfo());
18561856
}
18571857

1858-
std::tuple<Type, Type, Type>
1858+
std::pair<Type, Type>
18591859
ConstraintSystem::getTypeOfMemberReferenceImpl(
18601860
OverloadChoice choice, DeclContext *useDC,
18611861
ConstraintLocator *locator, SmallVectorImpl<OpenedType> *replacementsPtr,
@@ -1878,7 +1878,7 @@ ConstraintSystem::getTypeOfMemberReferenceImpl(
18781878
if (auto *typeDecl = dyn_cast<TypeDecl>(value)) {
18791879
openedType = getTypeOfMemberTypeReference(baseObjTy, typeDecl,
18801880
locator, preparedOverload);
1881-
return {openedType, thrownErrorType, baseObjTy};
1881+
return {openedType, thrownErrorType};
18821882
}
18831883

18841884
// Figure out the declaration context to use when opening this type.
@@ -1919,7 +1919,7 @@ ConstraintSystem::getTypeOfMemberReferenceImpl(
19191919
isa<MacroDecl>(value)) {
19201920
auto interfaceType = value->getInterfaceType();
19211921
if (interfaceType->is<ErrorType>() || isa<MacroDecl>(value))
1922-
return { interfaceType, Type(), baseObjTy };
1922+
return { interfaceType, Type() };
19231923

19241924
if (outerDC->getSelfClassDecl()) {
19251925
if (isa<ConstructorDecl>(value)) {
@@ -1939,7 +1939,7 @@ ConstraintSystem::getTypeOfMemberReferenceImpl(
19391939
} else {
19401940
auto *storage = cast<AbstractStorageDecl>(value);
19411941

1942-
std::tie(thrownErrorType, openedType) = getOpenedStorageType(
1942+
std::tie(openedType, thrownErrorType) = getOpenedStorageType(
19431943
baseTy, storage, useDC, hasAppliedSelf, replacements, locator,
19441944
preparedOverload);
19451945
}
@@ -1976,7 +1976,6 @@ ConstraintSystem::getTypeOfMemberReferenceImpl(
19761976
// to make sure that it's opened before use.
19771977
baseOpenedTy = openType(concreteSelf, replacements, locator,
19781978
preparedOverload);
1979-
baseObjTy = baseOpenedTy;
19801979
}
19811980
}
19821981
} else {
@@ -2035,7 +2034,7 @@ ConstraintSystem::getTypeOfMemberReferenceImpl(
20352034
}
20362035
}
20372036

2038-
return { openedType, thrownErrorType, baseObjTy };
2037+
return { openedType, thrownErrorType };
20392038
}
20402039

20412040
DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
@@ -2047,15 +2046,16 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
20472046
auto *value = choice.getDecl();
20482047

20492048
// Figure out the instance type used for the base.
2050-
Type baseRValueTy = choice.getBaseType();
2049+
Type baseTy = choice.getBaseType();
2050+
Type baseRValueTy = baseTy->getRValueType();
20512051
Type baseObjTy = baseRValueTy->getMetatypeInstanceType();
20522052

20532053
// A reference to a module member is really unqualified, and should
20542054
// be handled by the caller via getTypeOfReference().
20552055
ASSERT(!baseObjTy->is<ModuleType>());
20562056

20572057
Type openedType, thrownErrorType;
2058-
std::tie(openedType, thrownErrorType, baseObjTy)
2058+
std::tie(openedType, thrownErrorType)
20592059
= getTypeOfMemberReferenceImpl(choice, useDC, locator, replacementsPtr,
20602060
preparedOverload);
20612061

0 commit comments

Comments
 (0)