1- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GLOBAL_FUNC | %FileCheck %s -check-prefix=BEGINNING_WITH_SOME
2- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GLOBAL_VAR | %FileCheck %s -check-prefix=BEGINNING_WITHOUT_SOME
3-
4- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=PROTOCOL_ASSOCIATEDTYPE | %FileCheck %s -check-prefix=BEGINNING_WITHOUT_SOME
5- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=PROTOCOL_METHOD_REQUIREMENT | %FileCheck %s -check-prefix=BEGINNING_WITHOUT_SOME
6- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=PROTOCOL_VAR_REQUIREMENT | %FileCheck %s -check-prefix=BEGINNING_WITHOUT_SOME
7- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=PROTOCOL_SUBSCRIPT_REQUIREMENT | %FileCheck %s -check-prefix=BEGINNING_WITHOUT_SOME
8-
9- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=PROTOCOL_METHOD_EXTENSION | %FileCheck %s -check-prefix=BEGINNING_WITH_SOME
10- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=PROTOCOL_VAR_EXTENSION | %FileCheck %s -check-prefix=BEGINNING_WITH_SOME
11- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=PROTOCOL_SUBSCRIPT_EXTENSION | %FileCheck %s -check-prefix=BEGINNING_WITH_SOME
12-
13- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_METHOD | %FileCheck %s -check-prefix=BEGINNING_WITH_SOME
14- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_VAR | %FileCheck %s -check-prefix=BEGINNING_WITH_SOME
15- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_SUBSCRIPT | %FileCheck %s -check-prefix=BEGINNING_WITH_SOME
16- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_TYPEALIAS_RHS | %FileCheck %s -check-prefix=BEGINNING_WITHOUT_SOME
17-
18- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=OVERRIDE_TestClass | %FileCheck %s -check-prefix=OVERRIDE
19- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=OVERRIDE_TestStruct | %FileCheck %s -check-prefix=OVERRIDE
20- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=OVERRIDE_HasTypealias | %FileCheck %s -check-prefix=OVERRIDE_HasTypealias
21-
22- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=POSTFIX_TestProtocol_DOT | %FileCheck %s -check-prefix=POSTFIX_TestProtocol_DOT
23- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=POSTFIX_TestProtocol_NODOT | %FileCheck %s -check-prefix=POSTFIX_TestProtocol_NODOT
24-
25- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=OVERRIDE_TestProtocol2 | %FileCheck %s -check-prefix=OVERRIDE_TestProtocol2
26- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=POSTFIX_ConcreteTestProtocol2 | %FileCheck %s -check-prefix=POSTFIX_ConcreteTestProtocol2
1+ // RUN: %empty-directory(%t)
2+ // RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
273
284protocol MyProtocol {
295 associatedtype Mistery
@@ -52,27 +28,27 @@ struct ConcreteMyProtocol : MyProtocol {
5228// BEGINNING_WITHOUT_SOME-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
5329// BEGINNING_WITHOUT_SOME-NOT: Keyword/None: some
5430
55- func gloabalFunc( ) -> #^GLOBAL_FUNC^#
56- var globalVar: #^GLOBAL_VAR^#
31+ func gloabalFunc( ) -> #^GLOBAL_FUNC? check = BEGINNING_WITH_SOME ^#
32+ var globalVar: #^GLOBAL_VAR? check = BEGINNING_WITHOUT_SOME ^#
5733
5834protocol SomeProto {
59- associatedtype protoAssocTy : #^PROTOCOL_ASSOCIATEDTYPE^#
60- func protoMethodReq( ) -> #^PROTOCOL_METHOD_REQUIREMENT^#
61- var protoVarReq: #^PROTOCOL_VAR_REQUIREMENT^#
62- subscript( req: Int ) -> #^PROTOCOL_SUBSCRIPT_REQUIREMENT^#
35+ associatedtype protoAssocTy : #^PROTOCOL_ASSOCIATEDTYPE? check = BEGINNING_WITHOUT_SOME ^#
36+ func protoMethodReq( ) -> #^PROTOCOL_METHOD_REQUIREMENT? check = BEGINNING_WITHOUT_SOME ^#
37+ var protoVarReq: #^PROTOCOL_VAR_REQUIREMENT? check = BEGINNING_WITHOUT_SOME ^#
38+ subscript( req: Int ) -> #^PROTOCOL_SUBSCRIPT_REQUIREMENT? check = BEGINNING_WITHOUT_SOME ^#
6339}
6440
6541extension SomeProto {
66- func protoMethodExt( ) -> #^PROTOCOL_METHOD_EXTENSION^#
67- var protoVarExt: #^PROTOCOL_VAR_EXTENSION^#
68- subscript( ext: Int ) -> #^PROTOCOL_SUBSCRIPT_EXTENSION^#
42+ func protoMethodExt( ) -> #^PROTOCOL_METHOD_EXTENSION? check = BEGINNING_WITH_SOME ^#
43+ var protoVarExt: #^PROTOCOL_VAR_EXTENSION? check = BEGINNING_WITH_SOME ^#
44+ subscript( ext: Int ) -> #^PROTOCOL_SUBSCRIPT_EXTENSION? check = BEGINNING_WITH_SOME ^#
6945}
7046
7147struct SomeStruct {
72- typealias TyAlias = #^STRUCT_TYPEALIAS_RHS^#
73- func structMethodExt( ) -> #^STRUCT_METHOD^#
74- var structVarExt : #^STRUCT_VAR^#
75- subscript ( struct: Int) - > #^STRUCT_SUBSCRIPT^#
48+ typealias TyAlias = #^STRUCT_TYPEALIAS_RHS? check = BEGINNING_WITHOUT_SOME ^#
49+ func structMethodExt( ) -> #^STRUCT_METHOD? check = BEGINNING_WITH_SOME ^#
50+ var structVarExt: #^STRUCT_VAR? check = BEGINNING_WITH_SOME ^#
51+ subscript ( struct: Int) - > #^STRUCT_SUBSCRIPT? check = BEGINNING_WITH_SOME ^#
7652}
7753
7854// MARK: Conformance.
@@ -129,7 +105,7 @@ class TestClass :
129105 HasAssocWithConstraintOnProto ,
130106 HasAssocWithSameTypeConstraint ,
131107 HasAssocWithConformanceConstraintGeneric {
132- #^OVERRIDE_TestClass^#
108+ #^OVERRIDE_TestClass? check = OVERRIDE ^#
133109// OVERRIDE-DAG: Decl[InstanceMethod]/Super: func returnAssocPlain() -> AssocPlain {|};
134110// OVERRIDE-DAG: Decl[InstanceMethod]/Super: func returnAssocWithConformanceConstraint(fn: (Int) -> Int) -> some MyProtocol {|};
135111// OVERRIDE-DAG: Decl[InstanceVar]/Super: var valAssocWithSuperClassConstraint: some MyClass;
@@ -153,7 +129,7 @@ struct TestStruct :
153129 HasAssocWithConstraintOnProto ,
154130 HasAssocWithSameTypeConstraint ,
155131 HasAssocWithConformanceConstraintGeneric {
156- #^OVERRIDE_TestStruct^#
132+ #^OVERRIDE_TestStruct? check = OVERRIDE ^#
157133}
158134
159135class HasTypealias : HasAssocWithConformanceConstraint {
@@ -222,3 +198,16 @@ func testUseTestProtocol2(value: ConcreteTestProtocol2) {
222198// POSTFIX_ConcreteTestProtocol2-DAG: Decl[InstanceMethod]/Super: baz({#x: ConcreteTestProtocol2.Assoc#})[#(ConcreteTestProtocol2.Assoc) -> ConcreteTestProtocol2.Assoc#];
223199// POSTFIX_ConcreteTestProtocol2-DAG: Decl[InstanceMethod]/Super: inExt()[#ConcreteTestProtocol2.Assoc#];
224200}
201+
202+ struct Generic < T> {
203+ func returnMyProto( ) -> some MyProtocol { ConcreteMyProtocol ( ) }
204+ }
205+ func overloaded( ) -> Generic < Int > { fatalError ( ) }
206+ func overloaded( ) -> Generic < Float > { fatalError ( ) }
207+ // Tests that ambiguous doesn't result duplicated 'returnMyProto()'.
208+ func testDupGenericReturningOpaque( ) {
209+ overloaded ( ) . #^DupGenericReturningOpaque^#
210+ // DupGenericReturningOpaque-NOT: returnMyProto()
211+ // DupGenericReturningOpaque: Decl[InstanceMethod]/CurrNominal: returnMyProto()[#MyProtocol#]; name=returnMyProto()
212+ // DupGenericReturningOpaque-NOT: returnMyProto()
213+ }
0 commit comments