Skip to content

Commit 35a439d

Browse files
committed
Sema: Remove replacements parameter from getMemberReferenceTypeFromOpenedType()
1 parent 1efc9a6 commit 35a439d

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4520,8 +4520,7 @@ class ConstraintSystem {
45204520
/// determine the reference type of the member reference.
45214521
Type getMemberReferenceTypeFromOpenedType(
45224522
Type type, Type baseObjTy, ValueDecl *value,
4523-
ConstraintLocator *locator, bool hasAppliedSelf, bool isDynamicLookup,
4524-
ArrayRef<OpenedType> replacements);
4523+
ConstraintLocator *locator, bool hasAppliedSelf, bool isDynamicLookup);
45254524

45264525
/// Add the constraints needed to bind an overload's type variable.
45274526
void bindOverloadType(const SelectedOverload &overload, Type boundType,

lib/Sema/TypeOfReference.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -814,27 +814,24 @@ void ConstraintSystem::recordOpenedTypes(
814814

815815
// If the last path element is an archetype or associated type, ignore it.
816816
SmallVector<LocatorPathElt, 2> pathElts;
817-
auto anchor = locator.getLocatorParts(pathElts);
817+
(void) locator.getLocatorParts(pathElts);
818818
if (!pathElts.empty() &&
819819
pathElts.back().getKind() == ConstraintLocator::GenericParameter)
820820
return;
821821

822-
// If the locator is empty, ignore it.
823-
if (!anchor && pathElts.empty())
824-
return;
825-
826822
ConstraintLocator *locatorPtr = getConstraintLocator(locator);
827823
assert(locatorPtr && "No locator for opened types?");
828824

829-
OpenedType *openedTypes
830-
= Allocator.Allocate<OpenedType>(replacements.size());
831-
std::copy(replacements.begin(), replacements.end(), openedTypes);
832-
833825
// FIXME: Get rid of fixmeAllowDuplicates.
834-
if (!fixmeAllowDuplicates || OpenedTypes.count(locatorPtr) == 0)
826+
if (!fixmeAllowDuplicates || OpenedTypes.count(locatorPtr) == 0) {
827+
OpenedType *openedTypes
828+
= Allocator.Allocate<OpenedType>(replacements.size());
829+
std::copy(replacements.begin(), replacements.end(), openedTypes);
830+
835831
recordOpenedType(
836832
locatorPtr, llvm::ArrayRef(openedTypes, replacements.size()),
837833
preparedOverload);
834+
}
838835
}
839836

840837
/// Determine how many levels of argument labels should be removed from the
@@ -1757,8 +1754,7 @@ static bool isExistentialMemberAccessWithExplicitBaseExpression(
17571754

17581755
Type ConstraintSystem::getMemberReferenceTypeFromOpenedType(
17591756
Type type, Type baseObjTy, ValueDecl *value,
1760-
ConstraintLocator *locator, bool hasAppliedSelf, bool isDynamicLookup,
1761-
ArrayRef<OpenedType> replacements) {
1757+
ConstraintLocator *locator, bool hasAppliedSelf, bool isDynamicLookup) {
17621758
auto *outerDC = value->getDeclContext();
17631759

17641760
// Cope with dynamic 'Self'.
@@ -1790,8 +1786,8 @@ Type ConstraintSystem::getMemberReferenceTypeFromOpenedType(
17901786
baseObjTy, value, locator, isDynamicLookup) &&
17911787
// If there are no type variables, there were no references to 'Self'.
17921788
type->hasTypeVariable()) {
1793-
auto selfGP = outerDC->getSelfInterfaceType();
1794-
ASSERT(selfGP->isEqual(replacements[0].first));
1789+
auto replacements = getOpenedTypes(locator);
1790+
ASSERT(replacements[0].first->isEqual(getASTContext().TheSelfType));
17951791
auto openedTypeVar = replacements[0].second;
17961792

17971793
type = typeEraseOpenedExistentialReference(type, baseObjTy, openedTypeVar,
@@ -2072,14 +2068,14 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
20722068
// Handle DynamicSelfType and a couple of other things.
20732069
Type type = getMemberReferenceTypeFromOpenedType(
20742070
openedType, baseObjTy, value, locator, hasAppliedSelf,
2075-
isDynamicLookup, replacements);
2071+
isDynamicLookup);
20762072

20772073
// Do the same thing for the original type, if there can be any difference.
20782074
Type origType = type;
20792075
if (openedType.getPointer() != origOpenedType.getPointer()) {
20802076
origType = getMemberReferenceTypeFromOpenedType(
20812077
origOpenedType, baseObjTy, value, locator, hasAppliedSelf,
2082-
isDynamicLookup, replacements);
2078+
isDynamicLookup);
20832079
}
20842080

20852081
return { origOpenedType, openedType, origType, type, thrownErrorType };

0 commit comments

Comments
 (0)