|
11 | 11 |
|
12 | 12 | // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNRESOLVED_8 | %FileCheck %s -check-prefix=UNRESOLVED_3
|
13 | 13 | // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNRESOLVED_9 | %FileCheck %s -check-prefix=UNRESOLVED_3
|
14 |
| -// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNRESOLVED_OPT_1 | %FileCheck %s -check-prefix=UNRESOLVED_3 |
15 |
| -// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNRESOLVED_OPT_2 | %FileCheck %s -check-prefix=UNRESOLVED_3 |
| 14 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNRESOLVED_OPT_1 | %FileCheck %s -check-prefix=UNRESOLVED_3_OPT |
| 15 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNRESOLVED_OPT_2 | %FileCheck %s -check-prefix=UNRESOLVED_3_OPT |
| 16 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNRESOLVED_OPT_3 | %FileCheck %s -check-prefix=UNRESOLVED_3_OPTOPTOPT |
16 | 17 |
|
17 | 18 | // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNRESOLVED_12 | %FileCheck %s -check-prefix=UNRESOLVED_3
|
18 | 19 | // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNRESOLVED_13 | %FileCheck %s -check-prefix=UNRESOLVED_3
|
|
54 | 55 |
|
55 | 56 | // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRING_INTERPOLATION_1 | %FileCheck %s -check-prefix=STRING_INTERPOLATION_1
|
56 | 57 | // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRING_INTERPOLATION_INVALID
|
| 58 | + |
| 59 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=SUBTYPE_1 | %FileCheck %s -check-prefix=SUBTYPE_1 |
| 60 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=SUBTYPE_2 | %FileCheck %s -check-prefix=SUBTYPE_2 |
| 61 | + |
| 62 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENERIC_1 | %FileCheck %s -check-prefix=GENERIC_1 -check-prefix=GENERIC_1_INT |
| 63 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENERIC_2 | %FileCheck %s -check-prefix=GENERIC_1 -check-prefix=GENERIC_1_INT |
| 64 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENERIC_3 | %FileCheck %s -check-prefix=GENERIC_1 -check-prefix=GENERIC_1_U |
| 65 | + |
| 66 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STATIC_CLOSURE_1 | %FileCheck %s -check-prefix=STATIC_CLOSURE_1 |
| 67 | + |
57 | 68 | enum SomeEnum1 {
|
58 | 69 | case South
|
59 | 70 | case North
|
@@ -188,12 +199,33 @@ class C4 {
|
188 | 199 | func f5() {
|
189 | 200 | optionalEnumTaker1(.#^UNRESOLVED_OPT_2^#)
|
190 | 201 | }
|
| 202 | + func f6() { |
| 203 | + var _: SomeEnum1??? = .#^UNRESOLVED_OPT_3^# |
| 204 | + } |
191 | 205 | }
|
192 | 206 | // UNRESOLVED_3: Begin completions
|
193 | 207 | // UNRESOLVED_3-DAG: Decl[EnumElement]/ExprSpecific: North[#SomeEnum1#]; name=North
|
194 | 208 | // UNRESOLVED_3-DAG: Decl[EnumElement]/ExprSpecific: South[#SomeEnum1#]; name=South
|
195 | 209 | // UNRESOLVED_3-NOT: SomeOptions1
|
196 | 210 | // UNRESOLVED_3-NOT: SomeOptions2
|
| 211 | +// UNRESOLVED_3-NOT: none |
| 212 | +// UNRESOLVED_3-NOT: some( |
| 213 | + |
| 214 | +// UNRESOLVED_3_OPT: Begin completions |
| 215 | +// UNRESOLVED_3_OPT-DAG: Decl[EnumElement]/ExprSpecific: North[#SomeEnum1#]; |
| 216 | +// UNRESOLVED_3_OPT-DAG: Decl[EnumElement]/ExprSpecific: South[#SomeEnum1#]; |
| 217 | +// UNRESOLVED_3_OPT-DAG: Decl[EnumElement]/ExprSpecific: none[#Optional<Wrapped>#]; name=none |
| 218 | +// UNRESOLVED_3_OPT-DAG: Decl[EnumElement]/ExprSpecific: some({#Wrapped#})[#(Wrapped) -> Optional<Wrapped>#]; |
| 219 | +// UNRESOLVED_3_OPT-DAG: Decl[Constructor]/CurrNominal: init({#(some): SomeEnum1#})[#Optional<SomeEnum1>#]; |
| 220 | +// UNRESOLVED_3_OPT-DAG: Decl[Constructor]/CurrNominal: init({#nilLiteral: ()#})[#Optional<SomeEnum1>#]; |
| 221 | + |
| 222 | +// UNRESOLVED_3_OPTOPTOPT: Begin completions |
| 223 | +// UNRESOLVED_3_OPTOPTOPT-DAG: Decl[EnumElement]/ExprSpecific: North[#SomeEnum1#]; |
| 224 | +// UNRESOLVED_3_OPTOPTOPT-DAG: Decl[EnumElement]/ExprSpecific: South[#SomeEnum1#]; |
| 225 | +// UNRESOLVED_3_OPTOPTOPT-DAG: Decl[EnumElement]/ExprSpecific: none[#Optional<Wrapped>#]; name=none |
| 226 | +// UNRESOLVED_3_OPTOPTOPT-DAG: Decl[EnumElement]/ExprSpecific: some({#Wrapped#})[#(Wrapped) -> Optional<Wrapped>#]; |
| 227 | +// UNRESOLVED_3_OPTOPTOPT-DAG: Decl[Constructor]/CurrNominal: init({#(some): SomeEnum1??#})[#Optional<SomeEnum1??>#]; |
| 228 | +// UNRESOLVED_3_OPTOPTOPT-DAG: Decl[Constructor]/CurrNominal: init({#nilLiteral: ()#})[#Optional<SomeEnum1??>#]; |
197 | 229 |
|
198 | 230 | class C5 {
|
199 | 231 | func f1() {
|
@@ -287,7 +319,7 @@ func testAvail1(_ x: EnumAvail1) {
|
287 | 319 | func testAvail2(_ x: OptionsAvail1) {
|
288 | 320 | testAvail2(.#^OPTIONS_AVAIL_1^#)
|
289 | 321 | }
|
290 |
| -// OPTIONS_AVAIL_1: Begin completions, 3 items |
| 322 | +// OPTIONS_AVAIL_1: Begin completions |
291 | 323 | // ENUM_AVAIL_1-NOT: AAA
|
292 | 324 | // OPTIONS_AVAIL_1-DAG: Decl[StaticVar]/CurrNominal/TypeRelation[Identical]: aaa[#OptionsAvail1#];
|
293 | 325 | // OPTIONS_AVAIL_1-DAG: Decl[StaticVar]/CurrNominal/NotRecommended/TypeRelation[Identical]: BBB[#OptionsAvail1#];
|
@@ -387,3 +419,66 @@ func testInStringInterpolation() {
|
387 | 419 | // STRING_INTERPOLATION_1-DAG: Decl[EnumElement]/ExprSpecific: foo[#MyEnum#];
|
388 | 420 | // STRING_INTERPOLATION_1-DAG: Decl[EnumElement]/ExprSpecific: bar[#MyEnum#];
|
389 | 421 | // STRING_INTERPOLATION_1: End completions
|
| 422 | + |
| 423 | +class BaseClass { |
| 424 | + class SubClass : BaseClass { init() {} } |
| 425 | + static var subInstance: SubClass = SubClass() |
| 426 | +} |
| 427 | +protocol MyProtocol { |
| 428 | + typealias Concrete1 = BaseClass |
| 429 | + typealias Concrete2 = AnotherTy |
| 430 | +} |
| 431 | +extension BaseClass : MyProtocol {} |
| 432 | +struct AnotherTy: MyProtocol {} |
| 433 | +func testSubType() { |
| 434 | + var _: BaseClass = .#^SUBTYPE_1^# |
| 435 | +} |
| 436 | +// SUBTYPE_1: Begin completions, 4 items |
| 437 | +// SUBTYPE_1-DAG: Decl[Constructor]/CurrNominal/TypeRelation[Identical]: init()[#BaseClass#]; |
| 438 | +// SUBTYPE_1-DAG: Decl[Constructor]/CurrNominal/TypeRelation[Convertible]: SubClass()[#BaseClass.SubClass#]; |
| 439 | +// SUBTYPE_1-DAG: Decl[StaticVar]/CurrNominal/TypeRelation[Convertible]: subInstance[#BaseClass.SubClass#]; |
| 440 | +// SUBTYPE_1-DAG: Decl[Constructor]/Super/TypeRelation[Identical]: Concrete1()[#BaseClass#]; |
| 441 | +// SUBTYPE_1: End completions |
| 442 | + |
| 443 | +func testMemberTypealias() { |
| 444 | + var _: MyProtocol = .#^SUBTYPE_2^# |
| 445 | +} |
| 446 | +// SUBTYPE_2: Begin completions, 2 items |
| 447 | +// SUBTYPE_2-DAG: Decl[Constructor]/CurrNominal/TypeRelation[Convertible]: Concrete1()[#BaseClass#]; |
| 448 | +// SUBTYPE_2-DAG: Decl[Constructor]/CurrNominal/TypeRelation[Convertible]: Concrete2()[#AnotherTy#]; |
| 449 | +// SUBTYPE_2: End completions |
| 450 | + |
| 451 | +enum Generic<T> { |
| 452 | + case contains(content: T) |
| 453 | + case empty |
| 454 | + static func create(_: T) -> Generic<T> { fatalError() } |
| 455 | +} |
| 456 | +func takeGenericInt(_: Generic<Int>) { } |
| 457 | +func takeGenericU<U>(_: Generic<U>) { } |
| 458 | +func testGeneric() { |
| 459 | + do { |
| 460 | + let _: Generic<Int> = .#^GENERIC_1^# |
| 461 | + } |
| 462 | + takeGenericInt(.#^GENERIC_2^#) |
| 463 | + takeGenericU(.#^GENERIC_3^#) |
| 464 | +} |
| 465 | +// GENERIC_1: Begin completions |
| 466 | +// GENERIC_1: Decl[EnumElement]/ExprSpecific: contains({#content: T#})[#(T) -> Generic<T>#]; |
| 467 | +// GENERIC_1: Decl[EnumElement]/ExprSpecific: empty[#Generic<T>#]; |
| 468 | +// GENERIC_1_INT: Decl[StaticMethod]/CurrNominal: create({#Int#})[#Generic<Int>#]; |
| 469 | +// GENERIC_1_U: Decl[StaticMethod]/CurrNominal: create({#U#})[#Generic<U>#]; |
| 470 | +// GENERIC_1: End completions |
| 471 | + |
| 472 | +struct HasCreator { |
| 473 | + static var create: () -> HasCreator = { fatalError() } |
| 474 | + static var create_curried: () -> () -> HasCreator = { fatalError() } |
| 475 | +} |
| 476 | +func testHasStaticClosure() { |
| 477 | + let _: HasCreator = .#^STATIC_CLOSURE_1^# |
| 478 | +} |
| 479 | +// STATIC_CLOSURE_1: Begin completions, 2 items |
| 480 | +// STATIC_CLOSURE_1-DAG: Decl[Constructor]/CurrNominal/TypeRelation[Identical]: init()[#HasCreator#]; |
| 481 | +// FIXME: Suggest 'create()[#HasCreateor#]', not 'create'. |
| 482 | +// STATIC_CLOSURE_1-DAG: Decl[StaticVar]/CurrNominal: create[#() -> HasCreator#]; |
| 483 | +// STATIC_CLOSURE_1-NOT: create_curried |
| 484 | +// STATIC_CLOSURE_1: End completions |
0 commit comments