File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -520,16 +520,33 @@ BodyInitKindRequest::evaluate(Evaluator &evaluator,
520520 }
521521
522522 // Look for a base of 'self' or 'super'.
523- BodyInitKind myKind;
523+ arg = arg->getSemanticsProvidingExpr ();
524+
525+ auto myKind = BodyInitKind::None;
524526 if (arg->isSuperExpr ())
525527 myKind = BodyInitKind::Chained;
526528 else if (arg->isSelfExprOf (Decl, /* sameBase*/ true ))
527529 myKind = BodyInitKind::Delegating;
528- else {
529- // We're constructing something else.
530- return { true , E };
530+ else if (auto *declRef = dyn_cast<UnresolvedDeclRefExpr>(arg)) {
531+ // FIXME: We can see UnresolvedDeclRefExprs here because we have
532+ // not yet run preCheckExpression() on the entire function body
533+ // yet.
534+ //
535+ // We could consider pre-checking more eagerly.
536+ auto name = declRef->getName ();
537+ auto loc = declRef->getLoc ();
538+ if (name.isSimpleName (ctx.Id_self )) {
539+ auto *otherSelfDecl =
540+ ASTScope::lookupSingleLocalDecl (Decl->getParentSourceFile (),
541+ name.getFullName (), loc);
542+ if (otherSelfDecl == Decl->getImplicitSelfDecl ())
543+ myKind = BodyInitKind::Delegating;
544+ }
531545 }
532546
547+ if (myKind == BodyInitKind::None)
548+ return { true , E };
549+
533550 if (Kind == BodyInitKind::None) {
534551 Kind = myKind;
535552
You can’t perform that action at this time.
0 commit comments