@@ -51,47 +51,8 @@ Type swift::ide::getTypeForCompletion(const constraints::Solution &S,
5151
5252 Type Result;
5353
54- // To aid code completion, we need to attempt to convert type placeholders
55- // back into underlying generic parameters if possible, since type
56- // of the code completion expression is used as "expected" (or contextual)
57- // type so it's helpful to know what requirements it has to filter
58- // the list of possible member candidates e.g.
59- //
60- // \code
61- // func test<T: P>(_: [T]) {}
62- //
63- // test(42.#^MEMBERS^#)
64- // \code
65- //
66- // It's impossible to resolve `T` in this case but code completion
67- // expression should still have a type of `[T]` instead of `[<<hole>>]`
68- // because it helps to produce correct contextual member list based on
69- // a conformance requirement associated with generic parameter `T`.
7054 if (isExpr<CodeCompletionExpr>(Node)) {
71- auto completionTy = S.getType (Node).transform ([&](Type type) -> Type {
72- if (auto *typeVar = type->getAs <TypeVariableType>())
73- return S.getFixedType (typeVar);
74- return type;
75- });
76-
77- Result = S.simplifyType (completionTy.transform ([&](Type type) {
78- if (auto *placeholder = type->getAs <PlaceholderType>()) {
79- if (auto *typeVar =
80- placeholder->getOriginator ().dyn_cast <TypeVariableType *>()) {
81- if (auto *GP = typeVar->getImpl ().getGenericParameter ()) {
82- // Code completion depends on generic parameter type being
83- // represented in terms of `ArchetypeType` since it's easy
84- // to extract protocol requirements from it.
85- if (auto *GPD = GP->getDecl ())
86- return GPD->getInnermostDeclContext ()->mapTypeIntoContext (GP);
87- }
88- }
89-
90- return Type (CS.getASTContext ().TheUnresolvedType );
91- }
92-
93- return type;
94- }));
55+ Result = S.simplifyTypeForCodeCompletion (S.getType (Node));
9556 } else {
9657 Result = S.getResolvedType (Node);
9758 }
0 commit comments