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 16
16
#include " swift/AST/Decl.h"
17
17
#include " swift/AST/DeclContext.h"
18
18
#include " swift/AST/Expr.h"
19
+ #include " swift/AST/Initializer.h"
19
20
#include " swift/AST/LazyResolver.h"
20
21
#include " swift/AST/Module.h"
21
22
#include " swift/AST/Pattern.h"
@@ -691,7 +692,11 @@ class ExprContextAnalyzer {
691
692
} else
692
693
return false ;
693
694
});
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);
695
700
696
701
if (Finder.Ancestors .empty ())
697
702
return ;
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 100
100
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENERICPARAM_20 | %FileCheck %s -check-prefix=GENERICPARAM_1
101
101
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENERICPARAM_21 | %FileCheck %s -check-prefix=GENERICPARAM_1
102
102
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
+
103
105
enum SomeEnum1 {
104
106
case South
105
107
case North
@@ -645,3 +647,7 @@ func testingGenericParam2<X>(obj: C<X>) {
645
647
obj. t = . #^GENERICPARAM_21 ^#
646
648
// Same as GENERICPARAM_1.
647
649
}
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