11import errors
22
3- func foo ( ) {
3+ func testInvalidGlobalCursor ( ) {
44 invalidGlobalMissingInit = " "
5+ }
56
6- let bar : InvalidStruct
7- bar. memberB
7+ func testInvalidFuncCursor( ) {
88 invalidPartialFunc ( )
9- bar.
9+ }
10+
11+ func testInvalidStructCursor( ) {
12+ let foo : InvalidStruct
13+ foo. memberB
14+ }
1015
11- let baz: ;
16+ func testInvalidStructMemberCompletion( ) {
17+ let foo : InvalidStruct
18+ foo. #^INVALID- MEMBER^#
19+ // INVALID-MEMBER: Begin completions
20+ // INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberA[#Int#];
21+ // INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberB[#<<error type>>#];
22+ // INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberC[#<<error type>>#];
23+ // INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberD[#<<error type>>#];
24+ // INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberE[#<<error type>>#];
25+ // INVALID-MEMBER-DAG: Decl[InstanceMethod]/Super: add({#<<error type>>#})[#Void#];
26+ // INVALID-MEMBER-DAG: Decl[InstanceMethod]/Super: get()[#InvalidStruct.Item#];
27+ // INVALID-MEMBER-DAG: Decl[InstanceMethod]/Super: set({#item: InvalidStruct.Item#})[#Void#];
28+ // INVALID-MEMBER: End completions
29+ }
1230
31+ func testInvalidTypeCompletion( ) {
32+ let foo : #^INVALID- TYPE^#;
33+ // INVALID-TYPE: Begin completions
34+ // INVALID-TYPE-DAG: Decl[Enum]/OtherModule[errors]: InvalidEnum[#InvalidEnum#];
35+ // INVALID-TYPE-DAG: Decl[Class]/OtherModule[errors]: InvalidClass[#InvalidClass#];
36+ // INVALID-TYPE-DAG: Decl[Struct]/OtherModule[errors]: InvalidGenericStruct[#InvalidGenericStruct#];
37+ // INVALID-TYPE-DAG: Decl[Struct]/OtherModule[errors]: InvalidStruct[#InvalidStruct#];
38+ // INVALID-TYPE-DAG: Decl[TypeAlias]/OtherModule[errors]: InvalidAlias[#InvalidAlias#];
39+ // INVALID-TYPE-DAG: Decl[Class]/OtherModule[errors]: InvalidClassSub1[#InvalidClassSub1#];
40+ // INVALID-TYPE-DAG: Decl[Class]/OtherModule[errors]: InvalidClassSub2[#InvalidClassSub2#];
41+ // INVALID-TYPE-DAG: Decl[Protocol]/OtherModule[errors]: InvalidProtocol[#InvalidProtocol#];
42+ // INVALID-TYPE: End completions
43+ }
44+
45+ func testInvalidTopLevelCompletion( ) {
46+ #^INVALID- TOP^#
47+ // INVALID-TOP: Begin completions
48+ // INVALID-TOP-DAG: Decl[Enum]/OtherModule[errors]: InvalidEnum[#InvalidEnum#];
49+ // INVALID-TOP-DAG: Decl[Class]/OtherModule[errors]: InvalidClass[#InvalidClass#];
50+ // INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidGenericFuncBody({#param: T#})[#T#];
51+ // INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidPartialFunc()[#Void#];
52+ // INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncBody()[#Void#];
53+ // INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalClosureBody[#<<error type>>#];
54+ // INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncSignature()[#Void#];
55+ // INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalMissingInit[#String#];
56+ // INVALID-TOP-DAG: Decl[Struct]/OtherModule[errors]: InvalidGenericStruct[#InvalidGenericStruct#];
57+ // INVALID-TOP-DAG: Decl[Struct]/OtherModule[errors]: InvalidStruct[#InvalidStruct#];
58+ // INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: typeUsesFunc({#pe: InvalidEnum#}, {#pa: <<error type>>#}, {#pp: InvalidProtocol#}, {#ps: InvalidStruct#}, {#pg: <<error type>>#}, {#pc: InvalidClass#})[#Int#];
59+ // INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalKeypath[#InvalidStruct.Type#];
60+ // INVALID-TOP-DAG: Decl[TypeAlias]/OtherModule[errors]: InvalidAlias[#InvalidAlias#];
61+ // INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidGenericFuncType({#param: T#})[#<<error type>>#];
62+ // INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncType()[#<<error type>>#];
63+ // INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalClosureType[#() -> ()#];
64+ // INVALID-TOP-DAG: Decl[Class]/OtherModule[errors]: InvalidClassSub1[#InvalidClassSub1#];
65+ // INVALID-TOP-DAG: Decl[Class]/OtherModule[errors]: InvalidClassSub2[#InvalidClassSub2#];
66+ // INVALID-TOP-DAG: Decl[Protocol]/OtherModule[errors]: InvalidProtocol[#InvalidProtocol#];
67+ // INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncThrows()[' throws'][#<<error type>>#];
68+ // INVALID-TOP: End completions
1369}
1470
1571// RUN: %empty-directory(%t)
16- // RUN: %target-swift-frontend -emit-module -experimental-allow-module-with-compiler-errors -primary-file %S/Inputs/errors-a.swift %S/Inputs/errors-b.swift -module-name errors -o %t/errors.a.swiftmodule
17- // RUN: %target-swift-frontend -emit-module -experimental-allow-module-with-compiler-errors %S/Inputs/errors-a.swift -primary-file %S/Inputs/errors-b.swift -module-name errors -o %t/errors.b.swiftmodule
18- // RUN: %target-swift-frontend -merge-modules -emit-module -experimental-allow-module-with-compiler-errors %t/errors.a.swiftmodule %t/errors.b.swiftmodule -module-name errors -o %t/errors.swiftmodule
72+
73+ // RUN: %target-swift-frontend -emit-module -experimental-allow-module-with-compiler-errors -primary-file %S/Inputs/errors-a.swift %S/Inputs/errors-b.swift %S/Inputs/errors-c.swift -module-name errors -o %t/errors.a.swiftmodule
74+ // RUN: %target-swift-frontend -emit-module -experimental-allow-module-with-compiler-errors %S/Inputs/errors-a.swift -primary-file %S/Inputs/errors-b.swift %S/Inputs/errors-c.swift -module-name errors -o %t/errors.b.swiftmodule
75+ // RUN: %target-swift-frontend -emit-module -experimental-allow-module-with-compiler-errors %S/Inputs/errors-a.swift %S/Inputs/errors-b.swift -primary-file %S/Inputs/errors-c.swift -module-name errors -o %t/errors.c.swiftmodule
76+ // RUN: %target-swift-frontend -merge-modules -emit-module -experimental-allow-module-with-compiler-errors %t/errors.a.swiftmodule %t/errors.b.swiftmodule %t/errors.c.swiftmodule -module-name errors -o %t/errors.swiftmodule
1977
2078// Read the module back in to make sure it can be deserialized
2179// RUN: %target-swift-ide-test -print-module -source-filename dummy -module-to-print errors -I %t | %FileCheck %s
@@ -47,8 +105,8 @@ func foo() {
47105// CHECK: typealias Item = <<error type>>
48106// CHECK: let memberA: Int
49107// CHECK: let memberB: <<error type>>
50- // CHECK: var memberC: <<error type>> { get }
51- // CHECK: lazy var memberD: <<error type>> { mutating get }
108+ // CHECK: var memberC: <<error type>>
109+ // CHECK: lazy var memberD: <<error type>>
52110// CHECK: var memberE: <<error type>>
53111// CHECK: mutating func set(item: <<error type>>)
54112// CHECK: func invalidFuncBody()
@@ -64,62 +122,23 @@ func foo() {
64122// CHECK: func invalidPartialFunc()
65123// CHECK: func typeUsesFunc
66124
125+ // Check completions
126+ // RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t-completions -I %t
127+
67128// Check cursor info for the various symbols
68129// RUN: %sourcekitd-test -req=cursor -pos=4:3 %s -- -I %t -target %target-triple %s | %FileCheck %s -check-prefix=CHECK-GLOBAL
69130// CHECK-GLOBAL: source.lang.swift.ref.var.global
70131// CHECK-GLOBAL: invalidGlobalMissingInit
71132
72- // RUN: %sourcekitd-test -req=cursor -pos=6:12 %s -- -I %t -target %target-triple %s | %FileCheck %s -check-prefix=CHECK-STRUCT
73- // CHECK-STRUCT: source.lang.swift.ref.struct
74- // CHECK-STRUCT: InvalidStruct
75-
76- // : %sourcekitd-test -req=cursor -pos=7:7 %s -- -I %t -target %target-triple %s | %FileCheck %s -check-prefix=CHECK-MEMBER
77- // CHECK-MEMBER: source.lang.swift.ref.var.instance
78- // CHECK-MEMBER: memberB
79-
80133// RUN: %sourcekitd-test -req=cursor -pos=8:3 %s -- -I %t -target %target-triple %s | %FileCheck %s -check-prefix=CHECK-FUNC
81134// CHECK-FUNC: source.lang.swift.ref.function.free
82135// CHECK-FUNC: invalidPartialFunc
83136
84- // Check completions
85- // RUN: %sourcekitd-test -req=complete -pos=9:7 %s -- -I %t -target %target-triple %s | %FileCheck %s -check-prefix=CHECK-MEMBER-COMPLETE
86- // CHECK-MEMBER-COMPLETE: key.name: "add(
87- // CHECK-MEMBER-COMPLETE: key.name: "get(
88- // CHECK-MEMBER-COMPLETE: key.name: "memberA"
89- // CHECK-MEMBER-COMPLETE: key.name: "memberB"
90- // CHECK-MEMBER-COMPLETE: key.name: "memberC"
91- // CHECK-MEMBER-COMPLETE: key.name: "memberD"
92- // CHECK-MEMBER-COMPLETE: key.name: "memberE"
93- // CHECK-MEMBER-COMPLETE: key.name: "set(
94-
95- // RUN: %sourcekitd-test -req=complete -pos=11:11 %s -- -I %t -target %target-triple %s | %FileCheck %s -check-prefix=CHECK-TYPE-COMPLETE
96- // CHECK-TYPE-COMPLETE: key.name: "InvalidAlias"
97- // CHECK-TYPE-COMPLETE: key.name: "InvalidClass"
98- // CHECK-TYPE-COMPLETE: key.name: "InvalidClassSub1"
99- // CHECK-TYPE-COMPLETE: key.name: "InvalidClassSub2"
100- // CHECK-TYPE-COMPLETE: key.name: "InvalidEnum"
101- // CHECK-TYPE-COMPLETE: key.name: "InvalidGenericStruct"
102- // CHECK-TYPE-COMPLETE: key.name: "InvalidProtocol"
103- // CHECK-TYPE-COMPLETE: key.name: "InvalidStruct"
137+ // RUN: %sourcekitd-test -req=cursor -pos=12:12 %s -- -I %t -target %target-triple %s | %FileCheck %s -check-prefix=CHECK-STRUCT
138+ // CHECK-STRUCT: source.lang.swift.ref.struct
139+ // CHECK-STRUCT: InvalidStruct
104140
105- // RUN: %sourcekitd-test -req=complete -pos=12:1 %s -- -I %t -target %target-triple %s | %FileCheck %s -check-prefix=CHECK-GLOBAL-COMPLETE
106- // CHECK-GLOBAL-COMPLETE: key.name: "InvalidAlias"
107- // CHECK-GLOBAL-COMPLETE: key.name: "InvalidClass"
108- // CHECK-GLOBAL-COMPLETE: key.name: "InvalidClassSub1"
109- // CHECK-GLOBAL-COMPLETE: key.name: "InvalidClassSub2"
110- // CHECK-GLOBAL-COMPLETE: key.name: "InvalidEnum"
111- // CHECK-GLOBAL-COMPLETE: key.name: "invalidFuncBody(
112- // CHECK-GLOBAL-COMPLETE: key.name: "invalidFuncSignature(
113- // CHECK-GLOBAL-COMPLETE: key.name: "invalidFuncThrows(
114- // CHECK-GLOBAL-COMPLETE: key.name: "invalidFuncType(
115- // CHECK-GLOBAL-COMPLETE: key.name: "invalidGenericFuncBody(
116- // CHECK-GLOBAL-COMPLETE: key.name: "invalidGenericFuncType(
117- // CHECK-GLOBAL-COMPLETE: key.name: "InvalidGenericStruct"
118- // CHECK-GLOBAL-COMPLETE: key.name: "invalidGlobalClosureBody"
119- // CHECK-GLOBAL-COMPLETE: key.name: "invalidGlobalClosureType
120- // CHECK-GLOBAL-COMPLETE: key.name: "invalidGlobalKeypath
121- // CHECK-GLOBAL-COMPLETE: key.name: "invalidGlobalMissingInit
122- // CHECK-GLOBAL-COMPLETE: key.name: "invalidPartialFunc(
123- // CHECK-GLOBAL-COMPLETE: key.name: "InvalidProtocol"
124- // CHECK-GLOBAL-COMPLETE: key.name: "InvalidStruct"
125- // CHECK-GLOBAL-COMPLETE: key.name: "typeUsesFunc(
141+ // Currently doesn't work for any members with invalid types, even within the same module: rdar://71514163
142+ // RUN: %sourcekitd-test -req=cursor -pos=13:7 %s -- -I %t -target %target-triple %s | not %FileCheck %s -check-prefix=CHECK-MEMBER
143+ // CHECK-MEMBER: source.lang.swift.ref.var.instance
144+ // CHECK-MEMBER: memberB
0 commit comments