- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathmembers_transitive_compiler_protocols.swift
149 lines (110 loc) · 5.77 KB
/
members_transitive_compiler_protocols.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: %target-swift-frontend -emit-module -o %t %t/lib.swift
// RUN: %target-swift-frontend -typecheck -primary-file %t/main.swift %t/other.swift -I %t -verify -enable-upcoming-feature MemberImportVisibility
// REQUIRES: swift_feature_MemberImportVisibility
//--- main.swift
import Swift
// expected-note 15 {{add import of module 'lib'}}
for_inmakeSequence(){}
// expected-error@-1 {{instance method 'makeIterator()' is not available due to missing import of defining module 'lib'}}
// expected-error@-2 {{instance method 'next()' is not available due to missing import of defining module 'lib'}}
takesNilExpressible(nil)
// expected-error@-1 {{initializer 'init(nilLiteral:)' is not available due to missing import of defining module 'lib'}}
takesIntExpressible(1)
// expected-error@-1 {{initializer 'init(integerLiteral:)' is not available due to missing import of defining module 'lib'}}
takesFloatExpressible(1.0)
// expected-error@-1 {{initializer 'init(floatLiteral:)' is not available due to missing import of defining module 'lib'}}
takesBoolExpressible(true)
// expected-error@-1 {{initializer 'init(booleanLiteral:)' is not available due to missing import of defining module 'lib'}}
takesUnicodeScalarExpressible("🐦")
// expected-error@-1 {{initializer 'init(unicodeScalarLiteral:)' is not available due to missing import of defining module 'lib'}}
takesExtendedGraphemeClusterExpressible("🦸🏾♀️")
// expected-error@-1 {{initializer 'init(extendedGraphemeClusterLiteral:)' is not available due to missing import of defining module 'lib'}}
takesStringLiteralExpressible("Hello world")
// expected-error@-1 {{initializer 'init(stringLiteral:)' is not available due to missing import of defining module 'lib'}}
takesArrayExpressible([1])
// expected-error@-1 {{initializer 'init(arrayLiteral:)' is not available due to missing import of defining module 'lib'}}
takesDictionaryExpressible(["one":1])
// expected-error@-1 {{initializer 'init(dictionaryLiteral:)' is not available due to missing import of defining module 'lib'}}
takesMessage("\(1)")
// expected-error@-1 {{initializer 'init(stringInterpolation:)' is not available due to missing import of defining module 'lib'}}
// expected-error@-2 {{instance method 'appendInterpolation' is not available due to missing import of defining module 'lib'}}
// expected-error@-3 2 {{instance method 'appendLiteral' is not available due to missing import of defining module 'lib'}}
takesColorExpressible(#colorLiteral(red:0.0, green:0.0, blue:0.0, alpha:1))
// FIXME: Missing diangostic
takesImageExpressible(#imageLiteral(resourceName:"image.png"))
// FIXME: Missing diangostic
takesFileReferenceExpressible(#fileLiteral(resourceName:"file.txt"))
// FIXME: Missing diangostic
//--- other.swift
import lib
func makeSequence()->EmptySequence{
returnMySequence()
}
func takesNilExpressible(_ x:NilExpressible){}
func takesIntExpressible(_ x:IntExpressible){}
func takesFloatExpressible(_ x:FloatExpressible){}
func takesBoolExpressible(_ x:BoolExpressible){}
func takesUnicodeScalarExpressible(_ x:UnicodeScalarExpressible){}
func takesExtendedGraphemeClusterExpressible(_ x:ExtendedGraphemeClusterExpressible){}
func takesStringLiteralExpressible(_ x:StringExpressible){}
func takesArrayExpressible<E>(_ x:ArrayExpressible<E>){}
func takesDictionaryExpressible<K, V>(_ x:DictionaryExpressible<K,V>){}
func takesMessage(_ x:Message){}
func takesColorExpressible(_ x:ColorExpressible){}
func takesImageExpressible(_ x:ImageExpressible){}
func takesFileReferenceExpressible(_ x:FileReferenceExpressible){}
//--- lib.swift
publicstructEmptySequence:Sequence{
publicstructIterator:IteratorProtocol{
publicmutatingfunc next()->Int?{nil}
}
publicfunc makeIterator()->Iterator{Iterator()}
publicinit(){}
}
publicstructNilExpressible:ExpressibleByNilLiteral{
publicinit(nilLiteral:()){}
}
publicstructIntExpressible:ExpressibleByIntegerLiteral{
publicinit(integerLiteral value:Int){}
}
publicstructFloatExpressible:ExpressibleByFloatLiteral{
publicinit(floatLiteral value:Float){}
}
publicstructBoolExpressible:ExpressibleByBooleanLiteral{
publicinit(booleanLiteral value:Bool){}
}
publicstructUnicodeScalarExpressible:ExpressibleByUnicodeScalarLiteral{
publicinit(unicodeScalarLiteral value:Unicode.Scalar){}
}
publicstructExtendedGraphemeClusterExpressible:ExpressibleByExtendedGraphemeClusterLiteral{
publicinit(extendedGraphemeClusterLiteral value:Character){}
}
publicstructStringExpressible:ExpressibleByStringLiteral{
publicinit(stringLiteral value:String){}
}
publicstructArrayExpressible<Element>:ExpressibleByArrayLiteral{
publicinit(arrayLiteral elements:Element...){}
}
publicstructDictionaryExpressible<Key, Value>:ExpressibleByDictionaryLiteral{
publicinit(dictionaryLiteral elements:(Key,Value)...){}
}
publicstructMessageInterpolation:StringInterpolationProtocol{
publicinit(literalCapacity:Int, interpolationCount:Int){}
publicmutatingfunc appendInterpolation(_ value:@autoclosure()->Int){}
publicmutatingfunc appendLiteral(_ literal:String){}
}
publicstructMessage:ExpressibleByStringInterpolation{
publicinit(stringInterpolation:MessageInterpolation){}
publicinit(stringLiteral:String){}
}
publicstructColorExpressible:_ExpressibleByColorLiteral{
publicinit(_colorLiteralRed red:Float, green:Float, blue:Float, alpha:Float){}
}
publicstructImageExpressible:_ExpressibleByImageLiteral{
publicinit(imageLiteralResourceName path:String){}
}
publicstructFileReferenceExpressible:_ExpressibleByFileReferenceLiteral{
publicinit(fileReferenceLiteralResourceName path:String){}
}