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,
520
520
}
521
521
522
522
// Look for a base of 'self' or 'super'.
523
- BodyInitKind myKind;
523
+ arg = arg->getSemanticsProvidingExpr ();
524
+
525
+ auto myKind = BodyInitKind::None;
524
526
if (arg->isSuperExpr ())
525
527
myKind = BodyInitKind::Chained;
526
528
else if (arg->isSelfExprOf (Decl, /* sameBase*/ true ))
527
529
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
+ }
531
545
}
532
546
547
+ if (myKind == BodyInitKind::None)
548
+ return { true , E };
549
+
533
550
if (Kind == BodyInitKind::None) {
534
551
Kind = myKind;
535
552
You can’t perform that action at this time.
0 commit comments