File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 1616#include " swift/AST/Decl.h"
1717#include " swift/AST/DeclContext.h"
1818#include " swift/AST/Expr.h"
19+ #include " swift/AST/Initializer.h"
1920#include " swift/AST/LazyResolver.h"
2021#include " swift/AST/Module.h"
2122#include " swift/AST/Pattern.h"
@@ -691,7 +692,11 @@ class ExprContextAnalyzer {
691692 } else
692693 return false ;
693694 });
694- DC->walkContext (Finder);
695+
696+ // For 'Initializer' context, we need to look into its parent because it
697+ // might constrain the initializer's type.
698+ auto analyzeDC = isa<Initializer>(DC) ? DC->getParent () : DC;
699+ analyzeDC->walkContext (Finder);
695700
696701 if (Finder.Ancestors .empty ())
697702 return ;
Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ func returnsInt() -> Int {}
150150
151151// WITH_MEMBER_DECLS_INIT: Begin completions
152152// 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=.+$}}
154154// WITH_MEMBER_DECLS_INIT-DAG: Decl[InstanceMethod]/CurrNominal: instanceFunc({#self: MemberAccessors#})[#(Int) -> Float#]{{; name=.+$}}
155155// WITH_MEMBER_DECLS_INIT: End completions
156156
Original file line number Diff line number Diff line change 100100// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENERICPARAM_20 | %FileCheck %s -check-prefix=GENERICPARAM_1
101101// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENERICPARAM_21 | %FileCheck %s -check-prefix=GENERICPARAM_1
102102
103+ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DECL_MEMBER_INIT_1 | %FileCheck %s -check-prefix=UNRESOLVED_3
104+
103105enum SomeEnum1 {
104106 case South
105107 case North
@@ -645,3 +647,7 @@ func testingGenericParam2<X>(obj: C<X>) {
645647 obj. t = . #^GENERICPARAM_21 ^#
646648 // Same as GENERICPARAM_1.
647649}
650+
651+ struct TestingStruct {
652+ var value : SomeEnum1 = . #^DECL_MEMBER_INIT_1 ^#
653+ }
You can’t perform that action at this time.
0 commit comments