[CodeCompletion] Don't emit member type construction for the same type

in unresolved member completion. e.g.

  struct Node {
    typealias Child = Node
    init(children: [Child]) {}
  }
  let node: Node = .#^COMPLETE^#

This used to emit `.init(children:)` and `.Child(children:)`.
This commit is contained in:
Rintaro Ishizaki
2018-10-17 18:01:24 +09:00
parent 54f2aa3147
commit 04aba4465b
2 changed files with 8 additions and 3 deletions

View File

@@ -3825,7 +3825,12 @@ public:
// convertible to the contextual type.
if (auto CD = dyn_cast<TypeDecl>(VD)) {
declTy = declTy->getMetatypeInstanceType();
return declTy->isEqual(T) || swift::isConvertibleTo(declTy, T, *DC);
// Emit construction for the same type via typealias doesn't make sense
// because we are emitting all `.init()`s.
if (declTy->isEqual(T))
return false;
return swift::isConvertibleTo(declTy, T, *DC);
}
// Only static member can be referenced.