Skip to content

Commit 683c7ce

Browse files
committed
[CS] Simplify opened types earlier in buildMemberRef
Doesn't seem to be any reason not to do this up-front, cleans up the code a little. Should be NFC.
1 parent 4d668e7 commit 683c7ce

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

lib/Sema/CSApply.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,8 +1577,8 @@ namespace {
15771577
ConstraintLocatorBuilder memberLocator, bool Implicit,
15781578
AccessSemantics semantics) {
15791579
const auto &choice = overload.choice;
1580-
const auto openedType = overload.openedType;
1581-
const auto adjustedOpenedType = overload.adjustedOpenedType;
1580+
const auto openedType = simplifyType(overload.openedType);
1581+
const auto adjustedOpenedType = simplifyType(overload.adjustedOpenedType);
15821582

15831583
ValueDecl *member = choice.getDecl();
15841584

@@ -1639,7 +1639,7 @@ namespace {
16391639
// If we're referring to a member type, it's just a type
16401640
// reference.
16411641
if (auto *TD = dyn_cast<TypeDecl>(member)) {
1642-
Type refType = simplifyType(adjustedOpenedType);
1642+
Type refType = adjustedOpenedType;
16431643
auto ref = TypeExpr::createForDecl(memberLoc, TD, dc);
16441644
cs.setType(ref, refType);
16451645
auto *result = new (context) DotSyntaxBaseIgnoredExpr(
@@ -1770,10 +1770,8 @@ namespace {
17701770
ref->setImplicit(Implicit);
17711771
// FIXME: FunctionRefKind
17721772

1773-
auto computeRefType = [&](Type openedType) {
1774-
// Compute the type of the reference.
1775-
Type refType = simplifyType(openedType);
1776-
1773+
// Compute the type of the reference.
1774+
auto computeRefType = [&](Type refType) {
17771775
// If the base was an opened existential, erase the opened
17781776
// existential.
17791777
if (openedExistential) {
@@ -1859,7 +1857,7 @@ namespace {
18591857
// type having 'Self' swapped for the appropriate replacement
18601858
// type -- usually the base object type.
18611859
if (hasDynamicSelf) {
1862-
const auto conversionTy = simplifyType(adjustedOpenedType);
1860+
const auto conversionTy = adjustedOpenedType;
18631861
if (!containerTy->isEqual(conversionTy)) {
18641862
result = cs.cacheType(new (context) CovariantReturnConversionExpr(
18651863
result, conversionTy));
@@ -1967,7 +1965,7 @@ namespace {
19671965

19681966
auto *closure = buildSingleCurryThunk(
19691967
baseRef, declRefExpr, cast<AbstractFunctionDecl>(member),
1970-
simplifyType(adjustedOpenedType)->castTo<FunctionType>(),
1968+
adjustedOpenedType->castTo<FunctionType>(),
19711969
memberLocator);
19721970

19731971
// Wrap the closure in a capture list.
@@ -1994,7 +1992,7 @@ namespace {
19941992
// must be downcast to the opened archetype before being erased to the
19951993
// subclass existential to cope with the expectations placed
19961994
// on 'CovariantReturnConversionExpr'.
1997-
curryThunkTy = simplifyType(adjustedOpenedType)->castTo<FunctionType>();
1995+
curryThunkTy = adjustedOpenedType->castTo<FunctionType>();
19981996
} else {
19991997
curryThunkTy = adjustedRefTy->castTo<FunctionType>();
20001998

@@ -2060,7 +2058,7 @@ namespace {
20602058
apply = ConstructorRefCallExpr::create(context, ref, base);
20612059
} else if (isUnboundInstanceMember) {
20622060
ref = adjustTypeForDeclReference(
2063-
ref, cs.getType(ref), cs.simplifyType(adjustedOpenedType),
2061+
ref, cs.getType(ref), adjustedOpenedType,
20642062
locator);
20652063

20662064
// Reference to an unbound instance method.

0 commit comments

Comments
 (0)