Skip to content

Commit fe24ede

Browse files
committed
IDE: Fix another usage of lookupVisibleMemberDecls() to not pass in an existential type
It's better to use the 'Self' archetype here.
1 parent 7c2c34f commit fe24ede

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,6 +3184,21 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
31843184

31853185
this->ExprType = ExprType;
31863186

3187+
// Open existential types, so that lookupVisibleMemberDecls() can properly
3188+
// substitute them.
3189+
bool WasOptional = false;
3190+
if (auto OptionalType = ExprType->getOptionalObjectType()) {
3191+
ExprType = OptionalType;
3192+
WasOptional = true;
3193+
}
3194+
3195+
if (!ExprType->getMetatypeInstanceType()->isAnyObject())
3196+
if (ExprType->isAnyExistentialType())
3197+
ExprType = ArchetypeType::getAnyOpened(ExprType);
3198+
3199+
if (WasOptional)
3200+
ExprType = OptionalType::get(ExprType);
3201+
31873202
// Handle special cases
31883203
bool isIUO = VD && VD->getAttrs()
31893204
.hasAttribute<ImplicitlyUnwrappedOptionalAttr>();

0 commit comments

Comments
 (0)