|
34 | 34 | // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestNonSingleExprSubscriptUnresolved | %FileCheck %s -check-prefix=TestNonSingleExprSubscriptUnresolved
|
35 | 35 | // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestSingleExprSubscriptGlobal | %FileCheck %s -check-prefix=TestSingleExprSubscriptGlobal
|
36 | 36 |
|
| 37 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestSingeExprInitInvalid | %FileCheck %s -check-prefix=TestSingeExprInitInvalid |
| 38 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestSingeExprInitNone | %FileCheck %s -check-prefix=TestSingeExprInitNone |
| 39 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestSingeExprInitNilRet | %FileCheck %s -check-prefix=TestSingeExprInitNilRet |
| 40 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestSingeExprInitNil | %FileCheck %s -check-prefix=TestSingeExprInitNil |
| 41 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestNonSingeExprInitNil1 | %FileCheck %s -check-prefix=TestNonSingeExprInitNil |
| 42 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestNonSingeExprInitNil2 | %FileCheck %s -check-prefix=TestNonSingeExprInitNil |
| 43 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestSingeExprDeinitInvalid | %FileCheck %s -check-prefix=TestSingeExprDeinitInvalid |
| 44 | + |
| 45 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=testAccessorUnresolvedTopLevel | %FileCheck %s -check-prefix=TopLevelEnum |
| 46 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=testAccessorUnresolvedTopLevelGet | %FileCheck %s -check-prefix=TopLevelEnum |
| 47 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=testClosureUnresolvedTopLevelInit | %FileCheck %s -check-prefix=TopLevelEnum |
| 48 | + |
37 | 49 | // MARK: Single-expression closures
|
38 | 50 |
|
39 | 51 | struct TestSingleExprClosureRet {
|
@@ -548,3 +560,88 @@ struct TestSingleExprSubscriptGlobal {
|
548 | 560 | // TestSingleExprSubscriptGlobal-DAG: Decl[InstanceMethod]/CurrNominal: void()[#Void#];
|
549 | 561 | // TestSingleExprSubscriptGlobal: End completions
|
550 | 562 | }
|
| 563 | + |
| 564 | +// MARK: Single-expression initializers |
| 565 | + |
| 566 | +enum TestSingeExprInitInvalid { |
| 567 | + case foo |
| 568 | + init() { |
| 569 | + .#^TestSingeExprInitInvalid^# |
| 570 | + } |
| 571 | +// TestSingeExprInitInvalid-NOT: foo |
| 572 | +} |
| 573 | + |
| 574 | +enum TestSingeExprInitNone { |
| 575 | + case foo |
| 576 | + init?() { |
| 577 | + .#^TestSingeExprInitNone^# |
| 578 | + } |
| 579 | +// TestSingeExprInitNone-NOT: foo |
| 580 | +// Note: only `nil` is allowed here, not `.none`. |
| 581 | +// TestSingeExprInitNone-NOT: none |
| 582 | +} |
| 583 | + |
| 584 | +enum TestSingeExprInitNilRet { |
| 585 | + case foo |
| 586 | + init?() { |
| 587 | + return #^TestSingeExprInitNilRet^# |
| 588 | + } |
| 589 | +// TestSingeExprInitNilRet: Literal[Nil]/None/TypeRelation[Identical]: nil[#TestSingeExprInitNil{{(Ret)?}}?#]; |
| 590 | +} |
| 591 | + |
| 592 | +enum TestSingeExprInitNil { |
| 593 | + case foo |
| 594 | + init?() { |
| 595 | + #^TestSingeExprInitNil^# |
| 596 | + } |
| 597 | +// FIXME: For consistency, this should be same as TestSingeExprInitNilRet. |
| 598 | +// TestSingeExprInitNil: Literal[Nil]/None: nil; |
| 599 | +} |
| 600 | + |
| 601 | +enum TestNonSingeExprInitNil1 { |
| 602 | + case foo |
| 603 | + init?() { |
| 604 | + #^TestNonSingeExprInitNil1^# |
| 605 | + return nil |
| 606 | + } |
| 607 | +// No type relation. |
| 608 | +// TestNonSingeExprInitNil: Literal[Nil]/None: nil; |
| 609 | +} |
| 610 | + |
| 611 | +enum TestNonSingeExprInitNil2 { |
| 612 | + case foo |
| 613 | + init?() { |
| 614 | + #^TestNonSingeExprInitNil2^# |
| 615 | + self = .foo |
| 616 | + } |
| 617 | +} |
| 618 | + |
| 619 | +enum TestSingeExprDeinitInvalid { |
| 620 | + case foo |
| 621 | + deinit { |
| 622 | + .#^TestSingeExprDeinitInvalid^# |
| 623 | + } |
| 624 | +// TestSingeExprDeinitInvalid-NOT: foo |
| 625 | +} |
| 626 | + |
| 627 | +// MARK: Top-level code |
| 628 | + |
| 629 | +enum TopLevelEnum { |
| 630 | + case foo |
| 631 | +} |
| 632 | + |
| 633 | +// TopLevelEnum: Decl[EnumElement]/ExprSpecific: foo[#TopLevelEnum#]; |
| 634 | + |
| 635 | +var testAccessorUnresolvedTopLevel: TopLevelEnum { |
| 636 | + .#^testAccessorUnresolvedTopLevel^# |
| 637 | +} |
| 638 | + |
| 639 | +var testAccessorUnresolvedTopLevelGet: TopLevelEnum { |
| 640 | + get { |
| 641 | + .#^testAccessorUnresolvedTopLevelGet^# |
| 642 | + } |
| 643 | +} |
| 644 | + |
| 645 | +var testClosureUnresolvedTopLevelInit: TopLevelEnum = { |
| 646 | + .#^testClosureUnresolvedTopLevelInit^# |
| 647 | +}() |
0 commit comments