Skip to content

Commit be0f6f9

Browse files
committed
[Completion] NFC: Factor out getMemberBaseType()
1 parent f73054a commit be0f6f9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

include/swift/IDE/CompletionLookup.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
185185
/// \p selfTy must be a \c Self type of the context.
186186
static bool canBeUsedAsRequirementFirstType(Type selfTy, TypeAliasDecl *TAD);
187187

188+
/// Retrieve the type to use as the base for a member completion.
189+
Type getMemberBaseType() const {
190+
return BaseType ? BaseType : ExprType;
191+
}
192+
188193
public:
189194
struct RequestedResultsTy {
190195
const ModuleDecl *TheModule;

lib/IDE/CompletionLookup.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,7 @@ Type CompletionLookup::getTypeOfMember(const ValueDecl *VD, Type ExprType) {
763763
}
764764

765765
Type CompletionLookup::getAssociatedTypeType(const AssociatedTypeDecl *ATD) {
766-
Type BaseTy = BaseType;
767-
if (!BaseTy)
768-
BaseTy = ExprType;
766+
Type BaseTy = getMemberBaseType();
769767
if (!BaseTy && CurrDeclContext)
770768
BaseTy =
771769
CurrDeclContext->getInnermostTypeContext()->getDeclaredTypeInContext();

0 commit comments

Comments
 (0)