1- // RUN: sed -n -e '1,/NO_ERRORS_UP_TO_HERE$/ p' %s > %t_no_errors.swift
2- // RUN: %target-swift-frontend -typecheck -verify %t_no_errors.swift
1+ // RUN: %empty-directory(%t)
2+ // RUN: %empty-directory(%t/mods)
3+ // RUN: %empty-directory(%t/co-same)
4+ // RUN: %empty-directory(%t/co-across)
5+ // RUN: split-file %s %t --leading-lines
36
4- // RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=TOP_LEVEL_0 > %t
5- // RUN: %FileCheck %s -check-prefix=TOP_LEVEL_0 < %t
6- // RUN: %FileCheck %s -check-prefix=NEGATIVE_TOP_LEVEL_0 < %t
7+ // Completion in the current file/module
8+ // RUN: %target-swift-ide-test -batch-code-completion -code-complete-inits-in-postfix-expr -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t/co-same
79
8- // RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=TOP_LEVEL_1 > %t.generic
9- // RUN: %FileCheck %s -check-prefix=TOP_LEVEL_0 < %t.generic
10- // RUN: %FileCheck %s -check-prefix=GENERIC_PARAM_0 < %t.generic
11- // RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=K_QUALIFIED_0 | %FileCheck %s -check-prefix=K_QUALIFIED_0
12- // RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=L_QUALIFIED_0 | %FileCheck %s -check-prefix=L_QUALIFIED_0
13- // RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=L_QUALIFIED_0 | %FileCheck %s -check-prefix=NEGATIVE_L_QUALIFIED_0
14- // RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=INSIDE_L_0 | %FileCheck %s -check-prefix=INSIDE_L_0
15- // RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=INSIDE_M_0 | %FileCheck %s -check-prefix=INSIDE_M_0
16- // RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=ALIAS_CONSTRUCTOR_0 | %FileCheck %s -check-prefix=ALIAS_CONSTRUCTOR_0
10+ // Completion across modules
11+ // RUN: %target-swift-frontend -emit-module %t/InitTypes.swift -o %t/mods/
12+ // RUN: %target-swift-ide-test -batch-code-completion -code-complete-inits-in-postfix-expr -source-filename %t/InitUses.swift -filecheck %raw-FileCheck -completion-output-dir %t/co-across -I %t/mods -D SEPARATED
1713
18- struct A {
19- // implicit init()
14+ //--- InitTypes.swift
15+ public struct A {
16+ public init ( ) { }
2017}
2118
22- struct B {
19+ public struct B {
2320 let x : A , y : A , z : A
24- // implicit init(x:,y:,z:)
21+ public init ( x: A , y: A , z: A ) {
22+ self . x = x
23+ self . y = y
24+ self . z = z
25+ }
2526}
2627
27- struct C {
28- init ( ) { }
29- init ( x: A ) { }
30- init ( y: A = A ( ) ) { }
28+ public struct C {
29+ public init ( ) { }
30+ public init ( x: A ) { }
31+ public init ( y: A = A ( ) ) { }
3132}
3233
33- class D {
34- // implicit init()
34+ public class D {
35+ public init ( ) { }
3536}
36- class E {
37- init ( x: A ) { }
37+ public class E {
38+ public init ( x: A ) { }
3839}
3940
40- class F : E {
41+ public class F : E {
4142 // inherited init(x: A)
42- convenience init ( ) { }
43+ public convenience init ( ) {
44+ self . init ( x: A ( ) )
45+ }
4346}
4447
45- protocol G {
48+ public protocol G {
4649 init ( x: A )
4750}
4851
49- struct H : G {
50- init ( x: A ) { }
52+ public struct H : G {
53+ public init ( x: A ) { }
5154}
5255
53- protocol I : G {
56+ public protocol I : G {
5457 init ( y: A )
5558}
5659
57- typealias J = A
60+ public typealias J = A
5861
59- struct K {
60- typealias X = A
61- struct Y { }
62+ public struct K {
63+ public typealias X = A
64+ public struct Y {
65+ public init ( ) { }
66+ }
6267}
6368
64- struct L < X: G > {
65- typealias Y = X
69+ public struct L < X: G > {
70+ public typealias Y = X
6671}
6772
68- // NO_ERRORS_UP_TO_HERE
69-
73+ //--- InitUses.swift
74+ #if SEPARATED
75+ import InitTypes
76+ #endif
7077
7178func testTopLevel( ) {
72- #^TOP_LEVEL_0 ^#
73- }
74- // TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule : A()[#A#]{{; name=.+}}
75- // TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule : B({#x: A#}, {#y: A#}, {#z: A#})[#B#]{{; name=.+}}
76- // TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule : C()[#C#]{{; name=.+}}
77- // TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule : C({#x: A#})[#C#]{{; name=.+}}
78- // TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule : C({#y: A#})[#C#]{{; name=.+}}
79- // TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule : D()[#D#]{{; name=.+}}
80- // TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule : E({#x: A#})[#E#]{{; name=.+}}
81- // TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule : F({#x: A#})[#F#]{{; name=.+}}
82- // TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule : F()[#F#]{{; name=.+}}
83- // TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule : H({#x: A#})[#H#]{{; name=.+}}
84- // TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule : J()[#A#]{{; name=.+}}
85- // NEGATIVE_TOP_LEVEL_0-NOT: Decl[Constructor]/CurrModule : E()
86- // NEGATIVE_TOP_LEVEL_0-NOT: Decl[Constructor]/CurrModule : G(
87- // NEGATIVE_TOP_LEVEL_0-NOT: Decl[Constructor]/CurrModule : I(
79+ #^TOP_LEVEL_0 ? check = TOP_LEVEL_0;check = NEGATIVE_TOP_LEVEL_0 ^#
80+ }
81+ // TOP_LEVEL_0-DAG: Decl[Constructor]/{{.*}} : A()[#A#]{{; name=.+}}
82+ // TOP_LEVEL_0-DAG: Decl[Constructor]/{{.*}} : B({#x: A#}, {#y: A#}, {#z: A#})[#B#]{{; name=.+}}
83+ // TOP_LEVEL_0-DAG: Decl[Constructor]/{{.*}} : C()[#C#]{{; name=.+}}
84+ // TOP_LEVEL_0-DAG: Decl[Constructor]/{{.*}} : C({#x: A#})[#C#]{{; name=.+}}
85+ // TOP_LEVEL_0-DAG: Decl[Constructor]/{{.*}} : C({#y: A#})[#C#]{{; name=.+}}
86+ // TOP_LEVEL_0-DAG: Decl[Constructor]/{{.*}} : D()[#D#]{{; name=.+}}
87+ // TOP_LEVEL_0-DAG: Decl[Constructor]/{{.*}} : E({#x: A#})[#E#]{{; name=.+}}
88+ // TOP_LEVEL_0-DAG: Decl[Constructor]/{{.*}} : F({#x: A#})[#F#]{{; name=.+}}
89+ // TOP_LEVEL_0-DAG: Decl[Constructor]/{{.*}} : F()[#F#]{{; name=.+}}
90+ // TOP_LEVEL_0-DAG: Decl[Constructor]/{{.*}} : H({#x: A#})[#H#]{{; name=.+}}
91+ // TOP_LEVEL_0-DAG: Decl[Constructor]/{{.*}} : J()[#A#]{{; name=.+}}
92+ // NEGATIVE_TOP_LEVEL_0-NOT: Decl[Constructor]/{{.*}} : E()
93+ // NEGATIVE_TOP_LEVEL_0-NOT: Decl[Constructor]/{{.*}} : G(
94+ // NEGATIVE_TOP_LEVEL_0-NOT: Decl[Constructor]/{{.*}} : I(
8895
8996func testQualified0( ) {
9097 K. #^K_QUALIFIED_0^#
@@ -95,11 +102,11 @@ func testQualified0() {
95102func testQualified1( ) {
96103 L. #^L_QUALIFIED_0^#
97104}
105+ // L_QUALIFIED_0-NOT: X({#x: A#})
98106// L_QUALIFIED_0-DAG: Decl[Constructor]/CurrNominal: Y({#x: A#})[#G#]{{; name=.+}}
99- // NEGATIVE_L_QUALIFIED_0-NOT: X({#x: A#})
100107
101108func testGenericParam< T: I , U: G > ( ) {
102- #^TOP_LEVEL_1 ^#
109+ #^TOP_LEVEL_1 ? check = TOP_LEVEL_0;check = GENERIC_PARAM_0 ^#
103110}
104111// GENERIC_PARAM_0-DAG: Decl[Constructor]/Local: T({#x: A#})[#I#]{{; name=.+}}
105112// GENERIC_PARAM_0-DAG: Decl[Constructor]/Local: T({#y: A#})[#I#]{{; name=.+}}
0 commit comments