File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -5409,7 +5409,11 @@ class CodeCompletionTypeContextAnalyzer {
5409
5409
// We cannot analyze without target.
5410
5410
if (!ParsedExpr)
5411
5411
return false ;
5412
- DC->walkContext (Finder);
5412
+
5413
+ // For 'Initializer' context, we need to look into its parent because it
5414
+ // might constrain the initializer's type.
5415
+ auto analyzeDC = isa<Initializer>(DC) ? DC->getParent () : DC;
5416
+ analyzeDC->walkContext (Finder);
5413
5417
5414
5418
for (auto It = Finder.Ancestors .rbegin (); It != Finder.Ancestors .rend ();
5415
5419
++ It) {
Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ func returnsInt() -> Int {}
150
150
151
151
// WITH_MEMBER_DECLS_INIT: Begin completions
152
152
// WITH_MEMBER_DECLS_INIT-DAG: Decl[Struct]/CurrModule: FooStruct[#FooStruct#]{{; name=.+$}}
153
- // WITH_MEMBER_DECLS_INIT-DAG: Decl[FreeFunction]/CurrModule: returnsInt()[#Int#]{{; name=.+$}}
153
+ // WITH_MEMBER_DECLS_INIT-DAG: Decl[FreeFunction]/CurrModule/TypeRelation[Identical]: returnsInt()[#Int#]{{; name=.+$}}
154
154
// WITH_MEMBER_DECLS_INIT-DAG: Decl[InstanceMethod]/CurrNominal: instanceFunc({#self: MemberAccessors#})[#(Int) -> Float#]{{; name=.+$}}
155
155
// WITH_MEMBER_DECLS_INIT: End completions
156
156
Original file line number Diff line number Diff line change 78
78
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=OVERLOADED_INIT_1 | %FileCheck %s -check-prefix=OVERLOADED_METHOD_1
79
79
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=OVERLOADED_INIT_2 | %FileCheck %s -check-prefix=OVERLOADED_METHOD_1
80
80
81
+ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DECL_MEMBER_INIT_1 | %FileCheck %s -check-prefix=UNRESOLVED_3
82
+
81
83
enum SomeEnum1 {
82
84
case South
83
85
case North
@@ -535,3 +537,7 @@ func testOverload(val: HasOverloaded) {
535
537
let _ = HasOverloaded ( e: . #^OVERLOADED_INIT_2 ^#)
536
538
// Same as OVERLOADED_METHOD_1.
537
539
}
540
+
541
+ struct TestingStruct {
542
+ var value : SomeEnum1 = . #^DECL_MEMBER_INIT_1 ^#
543
+ }
You can’t perform that action at this time.
0 commit comments