Skip to content

Commit a650d65

Browse files
committed
Simplify findAbstractFunctionDecl.
If `lookupContext` is a type context, use its `self` type for member lookup.
1 parent e618365 commit a650d65

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3195,23 +3195,15 @@ static AbstractFunctionDecl *findAbstractFunctionDecl(
31953195

31963196
// Perform lookup.
31973197
LookupResult results;
3198+
// If `baseType` is not null but `lookupContext` is a type context, set
3199+
// `baseType` to the `self` type of `lookupContext` to perform member lookup.
3200+
if (!baseType && lookupContext->isTypeContext())
3201+
baseType = lookupContext->getSelfTypeInContext();
31983202
if (baseType) {
31993203
results = TypeChecker::lookupMember(lookupContext, baseType, funcName);
3200-
} else if (auto *typeDecl = lookupContext->getSelfNominalTypeDecl()) {
3201-
results = TypeChecker::lookupMember(lookupContext,
3202-
typeDecl->getDeclaredType(), funcName);
32033204
} else {
32043205
results = TypeChecker::lookupUnqualified(lookupContext, funcName,
32053206
funcNameLoc, lookupOptions);
3206-
3207-
// If looking up an operator within a type context, look specifically within
3208-
// the type context.
3209-
// This tries to resolve unqualified operators, like `+`.
3210-
if (funcName.isOperator() && lookupContext->isTypeContext()) {
3211-
if (auto tmp = TypeChecker::lookupMember(
3212-
lookupContext, lookupContext->getSelfTypeInContext(), funcName))
3213-
results = tmp;
3214-
}
32153207
}
32163208

32173209
// Initialize error flags.

0 commit comments

Comments
 (0)