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
3
6
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
7
9
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
17
13
18
- struct A {
19
- // implicit init()
14
+ //--- InitTypes.swift
15
+ public struct A {
16
+ public init ( ) { }
20
17
}
21
18
22
- struct B {
19
+ public struct B {
23
20
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
+ }
25
26
}
26
27
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 ( ) ) { }
31
32
}
32
33
33
- class D {
34
- // implicit init()
34
+ public class D {
35
+ public init ( ) { }
35
36
}
36
- class E {
37
- init ( x: A ) { }
37
+ public class E {
38
+ public init ( x: A ) { }
38
39
}
39
40
40
- class F : E {
41
+ public class F : E {
41
42
// inherited init(x: A)
42
- convenience init ( ) { }
43
+ public convenience init ( ) {
44
+ self . init ( x: A ( ) )
45
+ }
43
46
}
44
47
45
- protocol G {
48
+ public protocol G {
46
49
init ( x: A )
47
50
}
48
51
49
- struct H : G {
50
- init ( x: A ) { }
52
+ public struct H : G {
53
+ public init ( x: A ) { }
51
54
}
52
55
53
- protocol I : G {
56
+ public protocol I : G {
54
57
init ( y: A )
55
58
}
56
59
57
- typealias J = A
60
+ public typealias J = A
58
61
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
+ }
62
67
}
63
68
64
- struct L < X: G > {
65
- typealias Y = X
69
+ public struct L < X: G > {
70
+ public typealias Y = X
66
71
}
67
72
68
- // NO_ERRORS_UP_TO_HERE
69
-
73
+ //--- InitUses.swift
74
+ #if SEPARATED
75
+ import InitTypes
76
+ #endif
70
77
71
78
func 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(
88
95
89
96
func testQualified0( ) {
90
97
K. #^K_QUALIFIED_0^#
@@ -95,11 +102,11 @@ func testQualified0() {
95
102
func testQualified1( ) {
96
103
L. #^L_QUALIFIED_0^#
97
104
}
105
+ // L_QUALIFIED_0-NOT: X({#x: A#})
98
106
// L_QUALIFIED_0-DAG: Decl[Constructor]/CurrNominal: Y({#x: A#})[#G#]{{; name=.+}}
99
- // NEGATIVE_L_QUALIFIED_0-NOT: X({#x: A#})
100
107
101
108
func testGenericParam< T: I , U: G > ( ) {
102
- #^TOP_LEVEL_1 ^#
109
+ #^TOP_LEVEL_1 ? check = TOP_LEVEL_0;check = GENERIC_PARAM_0 ^#
103
110
}
104
111
// GENERIC_PARAM_0-DAG: Decl[Constructor]/Local: T({#x: A#})[#I#]{{; name=.+}}
105
112
// GENERIC_PARAM_0-DAG: Decl[Constructor]/Local: T({#y: A#})[#I#]{{; name=.+}}
0 commit comments